DATA
STRUCTURES &
ALGORITHMS
THEORY
ALI MOBIN MEMON
FALL 2024
AGENDA
• Before we Start
• Why DSA in 2024 ?
• Course outline
• Grade marks distribution
• Final tips & takeaways
• Introduction
2
BEFORE WE START !
ARE YOU A GOOD
STUDENT PROGRAMMER ?
IF NOT, BETTER BE ONE !
THIS COURSE IS COMPLEX
This course requires extensive programming skills. If you are
weak, please start practicing and if you do then do more for even
better results
Don’t be terrified, I am showing you clear picture and want you to
overcome the fear
I will provide materials during the semester to help you
understand DSA fully
4
WHY DSA IN 2024?
Gain problem-solving skills
and technical knowledge on
how to overcome issues in
technical programming
scenarios.
COURSE OUTLINE
DSA
Course
Data
Introducti Algorithm Spanning
Structure BST Graphs
on s Trees
s
Searching Sorting Sorting Binary
Arrays Link Lists Stacks Queues Algorithm Algorithm Algorithm Search AVL Tree
s s part 1 s part 2 Tree
Priority
Queues
6
MARKS
DISTRIBUTION
MARKS DISTRIBUTION
Assignment • Assignment 1: Theoretical
(15 marks problem-solving task Midterm • Coding and
total) • Assignment 2: Coding problem (20 Subjective
marks)
Test (20 • Test 1: Theoretical Test
• Test 2: Coding Test
Final • Decisive
marks total): Exam result here
(40 • Coding and
Subjective
marks)
Class
participation
(5 marks)
8
FINAL TIPS
Do not do
all the
Do all the Don’t
study and But expect
class work expect Ill
class work Ill be easy
and study pass the
last day while
week by student
before checking
week with ease
deadline
or exam
9
CONSULTATION TIME
• There is no fix time, email me or visit my
office for appointment. Remember coming to
me during the weekly classes will surely be
helpful if you are struggling to understand
course.
• [email protected]
10
INTRODUCTION
DATA STRUCTURE?
And So, The Journey Begins!
INTRODUCTION – DATA STRUCTURE
• data structures are specialized ways of organizing, storing, and managing data to enable
efficient access and modification. They are essential for solving various computational problems,
as they determine the way data is arranged in memory and influence the performance of
algorithms. Different data structures are suited for different tasks and operations.
• Each data structure is optimized for specific operations, so selecting the right one is critical for
writing efficient and effective programs.
• Please don’t mix it with Data Type which holds value not data to process.
12
INTRODUCTION - DATA STRUCTURE
Benefits
Organizatio Algorithm
Efficiency Scalability
n Support
13
Data
DATA STRUCTURE Structur
e
Non-
Linear
• Data Structures are classified into two Linear
types Static Dynamic Trees
• Linear: Where data is in straight line
Array Queue Graphs
like in Static: Array, Dynamic: Queue
0 etc.
or Stack 1 2 3
Lists
• Array:
Stack
14
Data
DATA STRUCTURE Structur
e
Non-
Linear
• Data Structures are classified into two Linear
types Static Dynamic Trees
• Non-Linear: Where, data is structured
Array Queue Graphs
hierarchical like a tree
Lists
Stack
15
INTRODUCTION
ALGORITHMS
16
ALGORITHM
• Step by Step instructions, planning or strategy
• Programming means implementation of algorithm via any
computational language called programming language
• A finite number of steps/instructions to achieve a result
• Algorithm can be represented graphically to make it easily
understandable to audience such as you
17
ALGORITHM REPRESENTATION
• Natural Language:
• English or Chinese
• Graphical representation:
• Flowchart
• Computation language:
• C
• Java
• C++
• C#
• Or simple handwriting explaining steps
18
INTRODUCTION - DATA STRUCTURE
Benefits
Organizatio Algorithm
Efficiency Scalability
n Support
19
ALGORITHM EFFICIENCY
• Efficiency of algorithm is calculated by:
• How much time it takes to achieve favorable result
• Via a notation: BIG O, BIG THETA & BIG OMEGA
• How much space it takes to achieve favorable result
• Via a notation: BIG O, BIG THETA & BIG OMEGA
• In this course we will check performance via these notation
20
BIG O(N)
Each Loop is Big
bool findElement(int arr[], int n, int key) O(n). Which
{ means number of
steps to solve
for (int i = 0; i < n; i++) {
if (arr[i] == key) {
return true;
}
}
return false;
}
21
BIG O(N2)
Each Loop is Big
void bubbleSort(int arr[], int n) O(n). So Nested
Loop is Loop
{ Times Loop. N x N
= N2
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
swap(&arr[j], &arr[j + 1]);
}
}
}
}
22
BIG O(2N)
Each Loop is Big
void bubbleSort(int arr[], int n) O(n). 2 loops not
connected, rather
{ separate are n + n
= 2n
for (int i = 0; i < n - 1; i++) {
}
for (int j = 0; j < n - i - 1; j++) {
}
}
23
BIG O(log N)
int binarySearch(int arr[], int l, int r, int x)
{ Logarithmic time
complexity means that the
if (r >= l) { running time of an
int mid = l + (r - l) / 2; algorithm is proportional to
the logarithm of the input
if (arr[mid] == x) size. So as soon as you find
the target you stop the
return mid;
process and don’t iterate
if (arr[mid] > x) through whole array
return binarySearch(arr, l, mid - 1, x);
return binarySearch(arr, mid + 1, r, x);
}
return -1;
}
24
DATA STRUCTURE & ALGORITHM
Software Data Scientist / Systems
Database • Its clear here that if you
Engineer / Machine Architect /
Administrator
Software Learning Backend
(DBA) are doing Computer
Developer Engineer Developer
Science/ Software
Engineering, Data Science,
Security
DevOps
Engineer /
Game Mobile App AI then DSA is must to
Engineer Developer Developer
Ethical Hacker learn.
Embedded
Artificial • If you can't code
Algorithm Intelligence /
Systems
Engineer Robotics
Cloud Architect efficiently, you can't, call
Engineer
Engineer yourself expert in any of
the listed IT roles
Blockchain
Developer
25
THANK YOU
Next Week: Linear Data Structure, Arrays