Chapter 12 Questions
Short Answer
1. State three ways in which a sorted list may be implemented.
2. What does adding an entry to a sorted list require?
3. Given the following sorted chain of linked nodes.
According to the text, where would you insert a new node with the string “Sue”
4. What pointers are needed in the method getNodeBefore from the class
LinkedSortedList?
5. Deriving a class of sorted lists from a class of lists using public inheritance is not appropriate.
What extra steps must be taken to do this?
6. Given nameListPtr points to an empty ADT sorted list. Also given the following sequence of
names added to an ADT sorted list:
nameListPtr–>insertSorted(“Tammie”);
nameListPtr–>insertSorted(“Darlah”);
nameListPtr–>insertSorted(“Sarah”);
nameListPtr–>insertSorted(“Tom”);
nameListPtr–>insertSorted(“Carlos”);
What would be returned by the call nameListPtr–>getEntry(2)
7. Given nameListPtr points to an empty ADT sorted list. Also the following sequence of
method calls on this instance of the list.
nameListPtr–>insertSorted(“Tammie”);
nameListPtr–>insertSorted(“Darlah”);
nameListPtr–>insertSorted(“Sarah”);
nameListPtr–>insertSorted(“Tom”);
nameListPtr–>insertSorted(“Carlos”);
nameListPtr–>remove(“Carlos”);
nameListPtr–>remove(1);
What would be returned by the call nameListPtr–>getEntry(2);