1. Data Structures & Algorithms
Dr. Tehseen Ul Hassan
Computer Science Department & IT
December 10, 2021
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 1 / 22
2. Things You Need To Know
Text Book
Data Structures and Algorithms in C++ by Adam Drozdek
Reference Books
Data Structures and Algorithms in C++ by Adam Drozdek
Data Structures and Algorithm Analysis in Java by Mark A. Weiss
Prerequisites
Object Oriented Programming
Course Webpage
Join the Whatsapp Group.
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 2 / 22
3. Outline
1 Introduction to Data Structures and Algorithms
2 Goals of this Course
3 What you will Learn in the Course?
4 Good Computer Program
5 Terminologies in DSA
6 References
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 3 / 22
4. Outline
1 Introduction to Data Structures and Algorithms
2 Goals of this Course
3 What you will Learn in the Course?
4 Good Computer Program
5 Terminologies in DSA
6 References
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 4 / 22
5. Introduction to Data Structures and Algorithms
Data Structure is a way of collect-
ing and organizing data in such a
manner that we can perform oper-
ations on these data easily and ef-
fectively.
An algorithm is a finite set of se-
quential instructions to accomplish
a certain predefined task.
Steps of an algorithm may have
branching or repetition depending
upon the problem for which the al-
gorithm has been developed.
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 5 / 22
6. Introduction to Data Structures & Algorithms
.
An algorithm is a definite procedure for solving a problem in finite
number of steps.
Algorithm is a well defined computational procedure that takes some
value (s) as input, and produces some value (s) as output.
Algorithm is finite number of computational statements that transform
input into the output.
Tool to solve well defined computational problem.
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 6 / 22
7. Introduction to Data Structures & Algorithms
What kind of problems are solved by algorithms?
Human Genome Project
Internet: Routing, searches, security
Electronic commerce
Commercial enterprises
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 7 / 22
8. Outline
1 Introduction to Data Structures and Algorithms
2 Goals of this Course
3 What you will Learn in the Course?
4 Good Computer Program
5 Terminologies in DSA
6 References
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 8 / 22
9. Goals of this Course
Reinforce the concept that costs and benefits exist for every data struc-
ture.
Understand how to measure the cost of a data structure or program.
These techniques also allow you to judge the merits of new data struc-
tures that you or others might invent.
Test and review the solution
Step-1 Define the problem Perform.
Step-2 data Gathering To solve such problem you must know the how
to perform the addition (i.e. by using + operator)
Step-3 The problem can be solved in many ways like
Step-4 Select the best solution from these solutions and design the
algorithm
Step-5 Write the code for the algorithm in any language
Step-6 Test the solution
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 9 / 22
10. Outline
1 Introduction to Data Structures and Algorithms
2 Goals of this Course
3 What you will Learn in the Course?
4 Good Computer Program
5 Terminologies in DSA
6 References
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 10 / 22
11. What you will Learn in the Course?
What you will Learn in the Course?
How to think about data and operations on data.
How to design data structures for efficient use.
How to determine the efficiency of algorithms.
A set of common data structures and algorithms for typical operations
on data (e.g., searching, sorting, etc.)
Advanced programming techniques (e.g., recursion, etc.)
How to implement a larger software project with a professional IDE.
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 11 / 22
12. Outline
1 Introduction to Data Structures and Algorithms
2 Goals of this Course
3 What you will Learn in the Course?
4 Good Computer Program
5 Terminologies in DSA
6 References
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 12 / 22
13. Good Computer Program
Good Computer Program
A computer Program is a series of instruction to carry out a particular
task written in language that a computer can understand.
The process of preparing and feeding the instructions in to computer
for execution is referred as programming.
There are a numbers of features for a good program.
Run efficiently and correctly.
Have user friendly interface.
Be easy to read and understand.
Be easy to debug and maintain.
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 13 / 22
14. Outline
1 Introduction to Data Structures and Algorithms
2 Goals of this Course
3 What you will Learn in the Course?
4 Good Computer Program
5 Terminologies in DSA
6 References
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 14 / 22
15. Terminologies in DSA
Big Data
Big Data is a collection of data that is huge in volume, yet growing
exponentially with time.
It is a data with so large size and complexity that none of traditional
data management tools can store it or process it efficiently.
Big data is also a data but with huge size.
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 15 / 22
16. Terminologies in DSA
Artificial Intelligence
Artificial intelligence (AI), the ability of a digital computer or computer-
controlled robot to perform tasks commonly associated with intelligent
beings.
The term is frequently applied to the project of developing systems
endowed with the intellectual processes characteristic of humans, such
as the ability to reason, discover meaning, generalize, or learn from
past experience.
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 16 / 22
17. Terminologies in DSA
Complexity
Complexity of an algorithm is a measure of the amount of time and/or
space required by an algorithm for an input of a given size (n).
Complexity is the consumption of resources.
Most important aspect of complexity are
Space complexity
Time Complexity
Big O Notations
Big O Notation is a way to measure an algorithm’s efficiency.
It measures the time it takes to run your function as the input grows.
Or in other words, how well does the function scale.
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 17 / 22
18. Terminologies in DSA
Arrays, Stack , Queue and Graphs
Tree
A tree is a nonlinear hierarchi-
cal data structure that consists of
nodes connected by edges.
The tree has one node called root.
The tree originates from this, and
hence it does not have any parent.
Each node has one parent only but
can have multiple children.
Each node is connected to its chil-
dren via edge.
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 18 / 22
19. Terminologies in DSA
Arrays, Stack , Queue and Graphs
.
Arrays
Arrays Array is a container which can hold a fix number of items and
these items should be of the same type. Most of the data structures
make use of arrays to implement their algorithms.
Stack
Stack: Stack is an abstract data type with a bounded(predefined)
capacity. It is a simple data structure that allows adding and removing
elements in a particular order.
Every time an element is added, it goes on the top of the stack and
the only element that can be removed is the element that is at the top
of the stack, just like a pile of objects.
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 19 / 22
20. Terminologies in DSA
Arrays, Stack , Queue and Graphs
.
Queue
Queue: A Queue is a linear structure which follows a particular order
in which the operations are performed.
The order is First In First Out (FIFO). A good example of a queue is
any queue of consumers for a resource where the consumer that came
first is served first.
Graphs
Graphs: A Graph is a non-linear data structure consisting of nodes and
edges.
The nodes are sometimes also referred to as vertices and the edges are
lines or arcs that connect any two nodes in the graph.
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 20 / 22
21. Outline
1 Introduction to Data Structures and Algorithms
2 Goals of this Course
3 What you will Learn in the Course?
4 Good Computer Program
5 Terminologies in DSA
6 References
Dr. Tehseen Ul Hassan Data Structures & Algorithms December 10, 2021 21 / 22