Lecture 9
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.
- Perform average case analysis for operations on data structures.
Reading assignment
- Lecture notes. Also see: http://en.wikipedia.org/wiki/Self-organizing_list for additional information.
- Lecture: Self-organizing linked lists.
Exercises and review questions
- Exercises and review questions on current lecture's material
- Complete the table shown in class for operations on self-organizing linked lists.
- 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.- Give an application where one of the self organizing lists is preferable to others, and justify you choice. (Post your answer on the discussion board)
- Given a sorted vector, what is the average number of array elements accessed during an insertion (after the location to insert has been found), assuming that there is an equal probability of insertion at any permissible position in the array? (Note: (i) The vector should be in sorted order after the insertion too. (ii) Assume that an insert does not cause the capacity to be exceeded.)
- Given an unsorted vector, what is the worst case number of array elements accessed during a
push_back
operation? (Note: Assume that this operation does not cause the capacity to be exceeded.)- Given a vector, what is the average number of array elements accessed during a deletion (after the location to delete has been found), assuming that each element is equally likely to be deleted?
- Given a vector, what is the average number of array elements accessed in checking for membership of a given key in the vector? Assume that the probability of the key not being in the vector is
1/n
, and all members of the vector are equally likely to be the key.- Questions on next lecture's material
- None.
Last modified: 20 Sep 2011