SYSC 2006 Lecture Notes - Lecture 14: Linked List, Null Pointer, C Dynamic Memory Allocation

121 views2 pages

Document Summary

Node has a value and link to next node (kinda like a pointer) A node can have any arbitrary amount of data. If each node is linked to only one other node, the data structure is called a singly-linked list. Remember: names cannot be declared on the heap; variable names have to be declared globally or locally. If all nodes are on the heap, to get at the first node, we use a head pointer. Having a pointer to the last node (a. k. a. the tail node) can decrease the running time of certain operations. Nodes in a singly linked list of integers are modelled by and intnode_t type struct intnode { int value; struct intnode *next; //pointer to intnode struct typedef struct intnode intnode_t; Member next stores the pointer to the next node in the linked list, i. e. , points to the same type of instance in another intnode struct! Note a very long approach has been used.

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