An UnorderedList
class can be used to implement some of the Abstract Data Types that we've discussed already. For example:
List
We've used Python to create an UnorderedList
class, but Python already has a list
class. Which implementation is better? You can start your experiment by timing how long it takes, say, to fill up each list with a series of random numbers, and then to remove those numbers from the list.
More importantly, however, which strategy has the better big-O value? Ie. how does the time that it takes to work with the list vary with the increasing size of a list?
Stack
Write an implementation of a Stack--ULStack
--using the UnorderedList
class. Recall that a Stack has five methods:
push
pop
peek
size
is_empty
Once the ULStack
has been written, write a StackComparison
program that constructs both kinds of stacks--the ULStack
implemented with an UnorderedList and a Stack
implemented with a Python list--and see which strategy Stack strategy is better.
Note that this is determined not by finding out which strategy is faster, but by looking at which strategy has the better big-O value.