This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: CSE 2320 Notes 9: Linked Lists (Last updated 10/6/11 8:11 PM) Sedgewick 3.3, 2.6, 12.3, 3.5, 3.4 9.A. S INGLY- LINKED ( FORWARD ) L ISTS . Links may be: Pointers Subscripts Disk addresses Web URLs (a “logical” address vs. a “physical” address in the other three cases) If the nodes have a key (i.e. a dictionary), should the list be ordered (ascending) or unordered? Ordered: If node y is the physical successor of x , then y is the logical successor of x . Unordered: No relationship between adjacent nodes. ASSUMPTION: Uniform access probabilities – equal likelihood for accessing each of n keys expected probes hit miss unordered ordered n + 1 2 n + 1 2 n + 1 2 n 1 + 2 + + n n = n n + 1 ( ) 2 n = n + 1 2 Most applications have many more hits than misses. Many applications, however, need ordered retrieval (L OGICAL S UCCESSOR , L OGICAL P REDECESSOR ). 2 9.B. K EEPING L INKED L IST C ODE S IMPLE AND E FFICIENT . a. Header – dummy node at beginning of list (even if no other nodes). Avoids “first node special” cases: D ELETE U NION This pointer never changes Can be wasteful if an application needs large number of very short lists. b. Sentinel – dummy element at end of unordered table, unordered list, or tree....
View Full Document
- Spring '12