SYSC 2006 Lecture Notes - Lecture 3: Linked List, C Dynamic Memory Allocation

77 views3 pages
Introduction:
A singly linked list is where every node is connected to other node
A head pointer is a pointer to the list's first node (a.k.a. the head node)
typedef struct intnode {
int value;
struct intnode *next;
A tail pointer is a pointer to the last node (a.k.a the tail node) to decrease running time of
Nodes in the singly linked lists are modelled by an intnode_t "type"
Value stores an integer and next stores a pointer to the net node in the list
intnode_t *intnode_construct(int value, intnode_t *next)
{
intnode_t *ptr;
ptr = malloc(sizeof(intnode_t));
// assert(ptr != NULL);
ptr
-
>value = value;
ptr
-
>next = next;
return ptr;
}
How To Create a Node:
Introduction to Linked Lists
May 4, 2018
4:46 PM
New Section 1 Page 1
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

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