Data Structure and Algorithm
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
• A computer program is a collection of
instructions to perform a specific task. For this,
a computer program may need to store data,
retrieve data, and perform computations on the
data.
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
A data structure is named a location that can be
used to store and organize data.
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
• Linear data structure: Data structure in which
data elements are arranged sequentially or
linearly, where each element is attached to its
previous and next adjacent elements, is called a
linear data structure.
Examples of linear data structures are array,
stack, queue, linked list, etc.
• Static data structure: Static data structure has a
fixed memory size. It is easier to access the elements
in a static data structure.
An example of this data structure is an array.
• Dynamic data structure: In dynamic data structure,
the size is not fixed. It can be randomly updated during
the runtime which may be considered efficient
concerning the memory (space) complexity of the
code.
Examples of this data structure are queue, stack, etc.
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
• Non-linear data structure: Data
structures where data elements are
not placed sequentially or linearly are
called non-linear data structures. In a
non-linear data structure, we can’t
traverse all the elements in a single
run only.
Examples of non-linear data structures
are trees and graphs.
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
• Algorithm is a collection of steps to solve a
particular problem.
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
Qualities of a good
algorithm
• Input and output should be defined precisely.
• Each step in the algorithm should be clear and
unambiguous.
• Algorithms should be most effective among
many different ways to solve a problem.
• An algorithms shouldn’t include computer code.
Instead, the algorithm should be written in such
a way that it can be used in different
programming languages.
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
Examples of
Algorithm
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
Algorithm Examples
• Algorithm to add two numbers
• Algorithm to find the largest among three
numbers
• Algorithm to find all the roots of the quadratic
equation
• Algorithm to find the factorial
• Algorithm to check prime number
• Algorithm of Fibonacci series
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
• Programming is all about data structures
and algorithms.
• Data structures are used to hold data while
algorithms are used to solve the problem
using that data.
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
Use of Data Structures and
Algorithms to make your
code scalable
• Time is precious
• More on scalability
• Memory is expensive
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm
COLLEGE OF COMPUTER STUDIES: CSCC5 - Data Structures and Algorithm