CS 239 - More fun with implementing data structures
Prepping for the final
- The coding part of the final will be on Wednesday April 23 during
lab time. BE ON TIME...you won't have a lot of time to spare.
- Open book and open java api's and your editor of choice. That is all that can be open.
- I don't care if they compile...I will grade as if you were doing this on paper.
- A series of small exercises testing various techniques or tools that we have used this semester.
- I can promise you a recursive method.
- Review your labs from the past...what you had to do in the lab is fair game for the exam.
- But realize, there is only 50 minutes so what we do will be small.
- This is worth 50% of the final exam grade.
Java supports data structures with a number of classes. The
Collections framework is an interface that enforces similar tasks
across all classes which purport to be a Collection.
Examples: ArrayList implements Collection. (Along with a bunch of other interfaces).
Other classes of interest:
Queue - This is an interface, not a structure. Example
Stack - Is a class. Implements Collection and extends Vector.
HashTable - Is a class. It does not implement Collection. (Didn't this make the color search problem much easier?)
Set - Is an interface. Does not permit duplicate elements. extends Collection.
At this point, you just need to be
familiar with Stacks and Queues and some basic operations of data
structures. You will get into much more next semester.
In your groups, write the code to implement two methods in an
OrderedList class. The OrderedList class is a linked list that is
maintained in sorted order. Each node contains a rank (any
positive integer) and a value (an object) along with a link to the next
node object.
When you add a node, you must put it in order. Consider carefully
the different situations (empty list, adding to beginning, middle, and
end.)
When you take a node, you must be careful that you don't lose your list. How will you hang onto the pieces.
Post your algorithms on the board when done.