Course: Berkeley’s CS 61B: Data Structures.
Homework 5: Safer doubly linked lists and sets
This assignment solves the invariant violations possible in hw4 by introducing a smarter/safer
DListNode, the node knows the list it belongs into and some of the duties have been moved off the
DList class and into the
Part 1 of the assignment asks you to implement the stubs (unimplemented methods) in the two classes. Code from hw4 should fit here, with minor modifications.
Part2 of the assignment asks you to implement a
Set ADT that uses a
List to store elements and satisfies these invariants:
Set‘s elements must be precisely the elements of the
Listmust always contain
Comparableelements, and those elements must always be sorted in ascending order.
- No two elements in the List may be
If you need a brush up on Sets this should do it.
The rest of the files are not modified.