Transcript Introduction to Data Structure
Data Structure: Chapter 5
Min Chen School of Computer Science and Engineering Seoul National University
Understanding Linked List Operators for Linked List Insert Remove Display Search Sorted Lists
Defined by Relationship, not Position For array, stack, queue ▪
Value Field
Relationship is represented by position For linked list ▪ Relationship is represented by links
Link Field
There is no end in Circular List All items have next hop
Shortcoming of singly linked list Difficult to travel back!
Addressed by Doubly Linked List
Insert item into the linked list Fig.1 Insert Operator in Linked List
Remove item from the linked list Fig.2 Remove Operator in Linked List
Display all the items in the linked list 21 3 87 238 46 379 Fig.3 Display Operator in Linked List
Search value 238 in the linked list 21 3 87 238 46 379 Found 238 !
Fig.4 Search Operator in Linked List
Similar to Singly Linked Lists Pay attention to the link redirection
As implied by the name, the items in the sorted lists are sorted by a key as in ordered array 24 35 72 30