2. Target Audience
People who have coding experience limited to the basic
syntax of C++, pointers and structures, but didn’t take
CS101 seriously and want to learn some basics of coding
quickly.
If you already know how to implement a linked list, then
please spare me the pain of taking a lecture on linked
lists, and volunteer to deliver this lecture.
3. Motivation
Suppose I have an array: 1,4,10,19,6
I want to insert a 7 between the 4 and the 10
What do we need to do?
6. How to represent a Node in C++ ?
How to represnt integers in C++?
int x;
But Node is a combination of data + pointer
(int) + pointer
(char) + pointer
(string) + pointer
11. Struct Pointer revisited
Struct Pointer
stud *s;
Access members of struct
s->rollNo = 11010179
s->cpi = 8.1
s->gender = ‘M’
rollNo cpi gender
s
;
12. Accessing data/next node
node* head
Data stored at first node
head->data = ‘a’;
Pointer to second node
head->next
Data stored at second node
(head->next)->data = ‘b’;
head
;