1/13
flashcards made from Week 7: Linked Lists slides
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Structures
Structures help organize heterogeneous data.
A structure is a collection of variables of possibly different types. The variables are called structure members.
A structure has a single type-name, called the structure tag
Defining a struct and Accessing the struct members
Global operations
Illegal operations and Why not?
Example (1) and (2)
Size of a struct
Linked lists of structures and Implementation
Dynamical lists
Linked lists are useful if you do not know the number of nodes in advance.
The idea is to create new nodes when new data points arrive.
Creating a new node requires allocating a new memory slot of size sizeof(struct node).
The total amount of memory needed is unknown at compile time, i.e. you need to allocate nodes dynamically (using malloc).
The first node and The head
New nodes and Creating the list
Iterations
Printing the list and Freeing the list
Other linked lists
References