Lecture 1:introduction To Data Structure and Algorithms: Mohsin Raza Khan
Lecture 1:introduction To Data Structure and Algorithms: Mohsin Raza Khan
Lecture 1:introduction To Data Structure and Algorithms: Mohsin Raza Khan
Analysis in C”
Robert Lafore, “Data Structures and Algorithms in
24 Hours”, SAMS
Goals of this Course
The objective of this course is to introduce the
analysis and designing of data structures using
various standard algorithms.
Traversing
Accessing each record exactly once so that certain items in the record may be
processed.(This accessing or processing is sometimes called 'visiting" the
records.)
Searching
Finding the location of the record with a given key value, or finding the
locations of all records, which satisfy one or more conditions.
Inserting
Adding new records to the structure.
Deleting
Removing a record from the structure.
Types of Data Structure
Specification of output
Specification of input
as a function of input
A 3 4 6 8 9 7 2 5 1
1 n
INPUT: A[1….n]- an array of integers
Strategy OUTPUT: a permutation of A such that
A[1]<A[2]….<A[n]
•Start “empty handed”
•Insert a card in the right for j =2 to n
position of the already key = A[j]
sorted hand. Insert A[j] into the sorted sequence A[1…..j-1]
while i>0 and A[i] >key
•Continue until all cards
do A[i+1] = A[i]
are inserted/sorted i--
A[i+1] = key
Analysis of Insertion Sort
Depends on computer
Relative Speed(on same machine)
Absolute speed(on diff machine)