Linked Lists - Marquette University
[Pages:76]Linked Lists
Thomas Schwarz SJ
Linked Lists
? E ective container data structure
? Container ADT:
? Insert, Update, Read, Delete records
? Records can be anything
? e.g. strings
? e.g. BLOBs (binary large objects)
ff
Linked Lists
? Linked Lists consists of Nodes
? Nodes are connected by forward pointers ? And have pointers to the record contents
? Pointers: Addresses of objects in memory
? This is how Python nds objects
? E.g. if you de ne a class without __str__ and __repr__ dunder,
this is how an instance will be printed
? It prints the id of the object
? CPython: Guaranteed to be the memory location
? Unless ...
if if
Linked Lists
>>> class X: def __init__(self): self.x = 0
>>> x=X() >>> print(x) >>>
Linked Lists
? Implementing a node
? Need elds for
? next node (by default Null)
? object stored in linked list
if
Linked Lists
class Node: def __init__(self, my_record): self.next_node = None self.record = my_record
Linked Lists
class Node: def __repr__(self): string = "Class Node " string += str(id(self)) string += ", next is " + str(id(self.next_node)) string += ", record is " + str(self.record) return string
? We use the id-trick in order to nd the memory address of
the nodes in CPython
if
Linked Lists
? Next task is to link the nodes
? A linked list is given by its initial node, the head
Linked List
None
B
B
B
B
L
L
L
L
O
O
O
O
B
B
B
B
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- linked data structures
- linked lists copyright © tutorialspoint
- lecture notes on linked lists
- modul 6 single double linked list um
- linked structures swarthmore college
- lecture 36 review linked lists and trees linked list
- linked lists marquette university
- ods python open data structures
- linked lists in python kennesaw state university
- stacks queues and linked lists
Related searches
- linked lists in java
- marquette community federal credit union
- lists of lists epa
- epa lists of lists excel
- marquette university high school athletics
- marquette high school hockey schedule
- marquette university high school baseball
- marquette university high school basketball
- marquette university high school hockey
- marquette university high school football
- marquette university hockey
- marquette university hockey team