|
7.3.2 An Ordered ListBy ordered, we mean ordered according to the characters in the name. With an ordered array, a binary search could be done in O(log2n) time on the average, but the enter operation will take more time since elements may have to be moved. To do a binary search, however, we need to implement the ordered list as an array. Representing the list as an ordered linked list brings us back to O(n) for the lookup operation although the enter operation would, on the average, be simpler since only pointers need to be changed rather than changing the position of each element. Example 3 shows an ordered list. Notice that we cannot see whether this has been implemented as an array or as a linked list. Example 3 An ordered list structure
Send questions and comments to: Karen Lemone
|