CS234 Lecture Notes - Linked List, Reference Class Problem, Time Complexity
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.