CS 112
Lecture 16
Linked Lists
Reading for this topic
Textbook, Ch. 3. But careful, the linked list ADT in the book may be slightly
different from the one I will be discussing in class.
Today
-
list applet.
- Dynamic memory allocation: when having an upper bound on the allocated
memory is not good (e.g. for stacks and queues).
When space is allocated and deallocated in an
unpredictable fashion (as opposed to stacks and queues).
- Linked lists: motivation, definition, operations: insert, delete, empty.
- Informally drawing lists. Box representation.
- Implementing a node of a list in C/C++: struct and typedef; pointers; arrow
notation.
Example and
execution.
Next time
- Allocating a new node in C/C++: the new operator.
- Discussion of subtleties in implementing list operations. The
head of a list.
- Implementation of the operations on lists: insert,
delete, empty, etc. Implementation of the Linked List ADT.
- Next week: applications of lists, and: pointers, pointers, pointers...
Ileana Streinu