C
C
INTRO TO
INTRODUCTION
TO DSA
DSA
Contents
Algorithm
Data Structures
CS 131
DS Types
Why learn DSA?
DEFINITION 1
ALGORITHM
In computer programming terms, an algorithm is
a set of well-defined instructions to solve a
particular problem. It takes a set of input(s) and
produces the desired output.
2
A good-quality algorithm:
3
ALGORITHM
FINDING THE LARGEST NUMBER AMONG
THREE NUMBERS
2
5
EXAMPLES 1
ALGORITHM
FINDING FACTORIAL OF A NUMBER
2
5
1
STRUCTURE
2
DATA
DEFINITION
4
Data structure is a storage that is used to
store and organize data. It is a way of
arranging data on a computer so that it can
be accessed and updated efficiently. 5
DEFINITION 1
Linear data structures elements are arranged in
sequence one after the other, which makes it easy
to implement. 2
LINEAR DS
EXAMPLES
ARRAYS QUEUE
4
STACKS
LINKED LIST
As complexity of the program increases, the linear data structures might
5
not be the best choice because of operational complexities.
NONLINEAR DS
DEFINITION 1
Nonlinear data structures elements are not in any
sequence. They are arranged in a hierarchical
manner where one element will be connected to
one or more elements. 2
EXAMPLES
3
4
GRAPHS TREES
Each node is called vertex and A tree is also a collection of vertices and
each vertex is connected to edges. But there can only be one edge
other vertices through edges. between two vertices.
5
1
WHY LEARN
2
DSA?
structures and algorithms.
• Data structures are used to hold data
• Algorithms are used to solve the
problem using that data 5
1
WHY LEARN
2
DSA?
DSA gives you an the science of
insight into how evaluating the This enables you to
efficient it is to use efficiency of an choose the best of
each solutions. algorithm. various choices.
5
CS 131
Thank you!
CS 131