Professional Documents
Culture Documents
wk2 Lec1
wk2 Lec1
wk2 Lec1
2
fi
Clarifications - Process Memory
#include <iostream>
#include <stdlib.h> STACK
int globalVar; // BSS Segment - Uninitialized Global Variable
3
Clarifications - Inheritance Keywords
• Public Inheritance:
• Public members of Base —> Public
members of Derived
• Protected Inheritance:
• Public and Protected members of
Base —> Protected members of
Derived
• Private Inheritance:
• All derived members become private
4
int cols);
Clarifications - Pointers & Arrays
5
Clarifications — Variables escaping scope
6
fi
Debug Challenge
7
Debug Challenge
8
Linked Lists Head
• Homogeneous container
• Need not be contiguous
• Dynamic data structure:
• The list can grow and shrink
• E cient memory utilisation
• Inventors: Allen Newell, Cli
Shaw, Herbert Simon in 1955
(RAND Corp. + CMU)
9
ffi
ff
Insertion in a Linked List
Head
• Insert @ head
Data NULL
11
fi
Complexity of Operations in Linked List
Head
• Singly Linked List:
• Traversal of all elements: O(n)
5 Nxt 9 Nxt 2 NULL
• Insert/Delete from head: O(1)
• Insert/Delete from end: O(n)
12
Circular Linked List
Head
• The end node is connected
to the rst node