CS234 Lecture Notes - Linked List, Reference Class Problem, Time Complexity

71 views5 pages

Document Summary

They are referenced by the link in the preceding node. return str(self. item) self. item = item self. next = next # if . next is not assigned, none will automatically be assigned should be referenced by the external variable head. Null head reference indicates an empty list. The basic operations: list traversal, search for an item, insert an item, delete an item. We can traverse a list by creating a temporary reference currnode = head. Traverse the list by advancing the temporary reference. currnode = currnode. next. Repeat until currnode == none; you"ve reached the end of the list def traversal(head): currnode = head while currnode != none print currnode currnode = currnode. next. For large lists and want to dynamically allocate memory instead of allocating memory which you may or may not use. Using node structure will allocate memory only when needed. Searching for an item in the sll (singly linked list) Produce true if the item is in the list.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents