(Intro To DSA)
(Intro To DSA)
Algorithm
INRODUCTION TO DATA STRUCTURES
Course objective
Introduce methods for organizing data so that the data can be accessed
and updated efficiently within a computer program.
COURSE OUTLINE
Course/ Lab Marking
How does Google quickly find web pages that contain a search term?
How does your Operating System track which memory (disk or RAM) is
free?
How does the processor handles multitasking
Selection of Data Structure
What is an algorithm?
Data structures
Representation and organization of data
Algorithms
Methods for implementing operations on data structures
Data structures and algorithms are closely related
Data structures are often tuned for certain algorithms
What kind of problems are solved by
algorithms?
Step 1: Start
Step 2: Declare variables num1, num2 and sum
Step 3: Read values num1 and num2
Step 4: Add num1 and num2 and assign the result to sum
sum←num1+num2
Step 5: Display sum
Step 6: Stop
Types of Algorithms
Divide and conquer algorithms – divide the problem into smaller subproblems of the same type;
solve those smaller problems, and combine those solutions to solve the original problem.
Brute force algorithms – try all possible solutions until a satisfactory solution is found.
Randomized algorithms – use a random number at least once during the computation to find a
solution to the problem.
Greedy algorithms – find an optimal solution at the local level with the intent of finding an
optimal solution for the whole problem.
Recursive algorithms – solve the lowest and simplest version of a problem to then solve
increasingly larger versions of the problem until the solution to the original problem is found.
Backtracking algorithms – divide the problem into sub problems, each which can be
attempted to be solved; however, if the desired solution is not reached, move backwards in the
problem until a path is found that moves it forward.
Dynamic programming algorithms – break a complex problem into a collection of simpler sub
problems, then solve each of those sub problems only once, storing their solution for future use
instead of re-computing their solutions.
Analysis of Algorithm
Integer
Float
Character
Boolean
Non-Primitive Data Structure
Non-Primitive Data Structure (cot.)
Non-Primitive Data Structure (cot.)
Some Frequently Used DS
Array