A small note is that, yes
there are utilties that do most of the same things that these do, but this
is mainly just to prove to myself that I can do these. Though some
of these are mildly interesting from a programming perspective.
Any program below without a link in
the main tables is not currently linked, so if you get any errors... Re-read
Auxilliary Files, needed by some
of the above programs.
A really BAD
routine. It works, but quite poossibly the slowest sorting algorithm
I can think of. The most interesting thing about this program
is that it is so slow, and the method behind it is recursion.
is the calling of a function, by itself. As you can probably imagine,
this could be a really bad potential for an infinite loop, hence there
is always an initial condition where it will "bottom out."
This usually is set to work so that the initial condition is something
which can be done easily, and the conditions above it are performed by
putting the various initial conditions, gained through various calls to
This particular sorting algorithm
appears very similar to mergesort, or quicksort, though it sorts by a method
more similar to mergesort than to quicksort, but it overdoes the sorting,
and so does alot of redundant work. The algorithm is
such that it calls itself to find the minimum element of each half of the
array, and then compares these two minimum elements and places that element
at the beginning of the entire array, and then calls itself on the remaining
piece of the array. The joining step is the compare of the two minimum
elements, and then placing the true minimum at the beginning of the array.
Unfortunately the way the element is placed is what destroys the sorted
ordering that would otherwise be produced, and so we must continue to recurse
upon the array.
Thanks to UNM Computer Science
461 (Fall 99) for this algorithm.
If you cannot analyze the algorithm,
it comes out to roughly O(n^lgn) for running time. The recurrence
T(n) = 2T(n/2) + T(n-1)
Though the running time of this
program is even worse, considering the statistics it gathers:
T(n) = 2T(n/2) + T(n-1)
(This file requires int_table.C
Hmm.. I always forget what ascii
values correspond to which ascii characters, so a short program to print
out all the ascii values.
In order to make files with really
long lines print correctly on brain-dead printers, I created this program
to break long lines (more than 80 characters, though this is set-able by
an argument to the program) into multiple lines. The behavior of
this utility is controlled largely from the command line, but the program
takes input and places output into the stdio channels.
(This file requires
An interesting program which I
decided would help me with finding a random number generator which at least
passed for a uniform distribution...
A program which will produce a
list of random numbers (really useful for testing sorting programs).
Unlike most of my other programs, this will produce a list into a file,
as specified in one of the command line arguments.
For some reason, I chose to have
a random background on my X terminal sessions. For this reason, I
created this program which, from a list of words, will choose a random
word. This also works for space delimited list that you want to choose
a random member from. Just FYI, the line I use for choosing the random
xv -display $DISPLAY -root -quit `ls -1 imagedir/*.jpg | randomMember`
Well, a random background was not
enough, so I decided to compile a list of quotes into a file. In
this file, each quote was listed in plain text, followed by ~~ on
a newline. After this it was a simple manner to create a program
to read in each of the quotes and choose one of them at random. This
was more just a task to brush up on C++ after a year of pure C programming.
There are times you want to look
at code, commented, and there are times you don't, so we have a little
bit of both. You can actually do this with grep, though it is a bit
complex, and this was easier. This program removes all comments from
a file. The program takes an argument on the command line as to which
type of comments to remove from the file, and the default is removal of
script comments (lines beginning with the '#' character).
Another function that can actually
be done quite easily with grep... remove all blank lines from the
stdin. I actually created this little program before I realized that
I could do it with grep.
This particular program was developed
to deal with many tcsh/csh scripts, and developing them as tools (unfortunately
all of which are now proprietary...). For each of these tools, a
usage was developed, and had to be output if the -help option was used.
Although the same effect can be generated using a single shell variable,
sometimes the usage information outgrew the variables. This can happen
on csh, but tcsh must allocate more space for variables, as when I used
csh, they got truncated, but on tcsh, I was able to get up
to 800 characters into one variable.
( This file
A program that can greatly assist
in reducing percieved code size... Well, okay, it kind of helps to
obfuscate code as well. This program will remove all whitespace from
the input. I don't really know what this is helpful for, other than
intentionally obfuscating code (a practice I do not condone...), though
for real effect, one would want to run remove_comments
and whiteSpaceBeGone on something to obfuscate it. Anyways, a fun
little program I did just to do it.
file requires garray.C and garray.h)
This files is an example of how to make a
program that does simple
conversions of hexidecimal numbers to decimal numbers. The main point of this
program is that it does not do anything complicated, it only uses the features
of the language to perform the conversion. If nothing else, this program is an
example of what you can do if you read the documentation. This program also
has some interesting ideas on performing reading of numbers and strings both.
Often this is not performed well, or must be bug checked thoroughly. This is a
method of dealing with it that most people overlook. Anyways, check out the
program below, though it is a C program.
A function, designed to be part
of another program, which will print out a memory range. The output
is in pretty much three distinct columns: the memory address, the
memory contents, the memory contents translated into ascii. Each
line of the memPrint is 16 (10 hex) bytes. This is actually helpful
for interpreting where your program is putting data, EXACTLY.
This file is a collection of functions
which are basically designed for text parsing. There is not much
here, this is actually one of my fairly early efforts, but I figured that
it might help someone.
A rather simple binary queue implementation.
A growable table of ints.
This is primarily useful as an addition to sorting algorithms, as you can
simply read in more and more numbers, and never have to worry about directly
allocating more storage. For an example of the use of this, see SillySort
A growable array of characters...kind
of looks like a string class, but I won't admit it. If it were though,
anyone would notice that it was not a very full featured string class...
Really though, all this was made for is a general growable array, similar,
in use as the int_table above. A better way to do the two of these
would actually be a template.