Lecture 5 DS
Lecture 5 DS
and Algorithm
21COMP04C
2023
Lecture5
1
Labs and and tutorial
• In class test lecture 1:5 , Tutorial 1:3 and Lab 1:4
• Tutorial 3
• one hour online session (Saturday 7PM)
https://us04web.zoom.us/j/73416817706?pwd=nNtHvAGVvjSFJuwxKwagd7K
69dTjNd.1
• Lab4 submission
• Labs are ungraded
• Lab 4 submission is next Sunday
2
Our Course
Lecture Lecture Lecture Lecture
Lecture 4
1,2,3 5,6,7,8 9,10 11,12
Array Linked
OO Searching Trees
based lists lists
Algorithm
Recursion Graphics
analysis
Lecture Resources
Data-Structure Using C++ by D.S. Malik (chapter 5)
Operations
Searching (find the location)
Inserting (add new element)
Deleting
Sorting
Source: https://www.hellocodeclub.com/when-to-use-which-data-structure-top-6-data-structures
5
Content
• Linked list as list of integer
• Linked list as ADT (any type of element)
Linked List
• Linked lists overcome some of the problems of list (sequential lists)
• Problem of sequential lists
• Insert and remove elements is time consuming, especially with large lists because these
operations require data movement.
• Fixed size of array
• In linked lists, we use pointers to organize and process data in lists.
cout<<head->info;
cout<<head->link
Output [15 0]
11 Static Dynamic
Linked Lists: Some Properties
• Head stores address of first node
• Info stores information
• Link stores address of next node
• Assume info type int
TABLE 5-1 Values of head and some of
the nodes of the linked list in Figure 5-4
• p->link = p->link->link;
Abstract class
linkedListType • Not a complete class
• missing functions
• you cannot create objects
of that class.
unorderedLinkedList orderedLinkedList