Lecture 11
Learning objectives
After this class, you should be able to:
- Explain the purpose of self-organizing lists.
- Explain the method used by the following types of self-organizing lists: (i) move-to-front, (ii) transpose, (iii) count, and (iv) ordering.
- Given a sequence of operations on a self organizing list of one of the above types, or a new type that we define, show the relative positions of elements in the list.
- Write code to implement a specified operation on a self-organizing list, either of the above types, or of some new type.
- Given an application, state which type of self-organizing list would ideally suit it, and give a justification for your choice.
- Write code using the following features of an STL list class: back, front, push_back, pop_back, push_front, pop_front, begin, end, pop_back, pop_front, list(), erase, remove, size, merge, sort, and unique.
Reading assignment
- Section 3.5 (except the amortized analysis on pages 105-106), section 3.7.
- Section 2.8, page 63 and 64.
Exercises and review questions
- Exercises and review questions on current lecture's material
- Complete the table of figure 3.19, using the choices made in class. Note that our results differ from that in the book.
- Let
s
point to the node of a doubly linked list, which we have located in a search. Write code to adjust the position of this node in a move-to-front list.
- Let
s
point to the node of a doubly linked list, which we have located in a search. Write code to adjust the position of this node in a list that uses the count method. (Please do *NOT* post the solution on blackboard)
- Change the code of Lec10/toyll.cpp so that it uses the STL
list
class.
- Give an application where one of the self organizing lists is preferable to others, and justify you choice.
- Questions on next lecture's material
- When we search for an element in a linked list, we stop the search when we find an element. Assume that a list has
n
elements. What is the best case time complexity for the search? What is the worst case time complexity for the search?
Last modified: 28 Sep 2004