Dale - Computer Science Illuminated 312

Dale - Computer Science Illuminated 312 - length position....

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
9.3 Lists 285 Class Name: Host Superclass: Subclasses: Responsibilities Collaborations inotovdoae otsedI inse,t LoteGu Redete LoteGu p,ont (nr)HenDtc ,etl,ns onteDe, z z z iteGfdvss m iteGfdvss iteGfdvss mhsslGPtorn- iteGfdvss Glst P,rNoAe TrGPv,eEr GetcrA- oteGgzTrGPv,eErLoteGyu b0- oteGgboteGy 0- oteGg eqlvds oteGy >0- oteGg>oteGy The step Find where the item belongs is decomposed differently in these two subcategories. If the list is printed in the order in which the items are inserted (unsorted), the logical place for each item is at the end of the list. This is certainly efficient in the array-based implementation because the item would go into the
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: length position. However, in the linked implementa-tion, the end of the list can only be accessed by traversing the entire list. It would be more efficient to put each new item at the beginning of the list, but the Print would have them in reverse order rather than the order in which they were entered. We said that a sorted list was one in which the items were printed in order based on some information within the items on the list. This means that the list must be kept such that the Get an item within the print method gets the Find where the item belongs (Unsorted) Item belongs at length...
View Full Document

Ask a homework question - tutors are online