Sei sulla pagina 1di 17

Data Structures

and
Algorithms

Dr. Alekha Kumar Mishra


About the Course
Course Code : CSE2003
Course Title : Data Structures and Algorithms
No. of Hours : 30
No. of Digital Assignments : 3 (10+10+10 marks)
Embedded Project : 3 Reviews (20+30+50 marks)

Dr. Alekha Kumar Mishra


Course Objectives
Importance of Algorithms and Data structures in
computer science
Use of Algorithms and Data structures for
solving a problem
Modeling of the problem and possible solution
techniques
Designing solutions independent of languages,
paradigms, and hardware.

Dr. Alekha Kumar Mishra


Outcomes
Design an efficient algorithm for a problem
Choose appropriate data structure .
Choose appropriate paradigm
Map real-world problems to algorithmic solutions.
Analyze algorithms asymptotically
Compute the performance analysis of algorithms
Identify the existence of problems which defy
algorithmic solution.
Recognize a few problems which defy efficient solution

Dr. Alekha Kumar Mishra


Books
Thomas H. Cormen, C.E. Leiserson, R L.Rivest and C. Stein,
Introduction to Algorithms , Third edition, MIT Press, 2009.

Reference Books
A. V. Aho, J.E. Hopcroft and J. D. Ullman, The Design and Analysis
of Computer Algorithms ,Pearson,1st edition, 2006.
Ellis Horowitz, Sartaj Sahni, Fundamentals of Computer Algorithms
Seymour Lipschutz, Data Structures
Sanjoy Dasgupta, C.Papadimitriou and U.Vazirani , Algorithms ,
Tata McGraw-Hill, 2008.

Dr. Alekha Kumar Mishra


Data Structures (DS)
Representation of logical relationship that exists
between various data.
Represents the organization of data together with its
operation.
A logical or mathematical model for data.
Provides the structure of implementation in the
computer systems.
Aids to analyze efficiency of a structure with respect
to space and time.

Dr. Alekha Kumar Mishra


Basic operations on DS
Traversal (visit) :- Accessing each record/element exactly once to
process certain items.
Search :- Searching a particular data/location/record in the entire data
structure with a key value.
process of finding the location of all the records/data which satisfies one or
more conditions.
Insertion :- Adding a new data/record to the data structure.
Deletion :- Removing an existing record/data from the data structure.
Sort :- Arranging the records/data in some logical order; either
ascending (non-decreasing) or descending (non-increasing) order
using a given key.
Merge :- Combination of data present in two or more data structure into
a single data structure.
It is mostly performed on already sorted data structures.
7

Dr. Alekha Kumar Mishra


Algorithm
Algorithm consists of systematic sequence of finite set of steps
for solving a particular problem or task.
Provides the way to define various operations on data structures.
Algorithm must satisfy the following criteria:
Input : There are zero or more number of quantities which are supplied
to the algorithm externally.
Output: At least one quantity is produced as output.
Definiteness: Each instructions in algorithm must be clear and
unambiguous.
Finiteness: The algorithm should terminate after a finite number of
steps.
Effectiveness: Every instruction must be sufficiently basic that it can
easily converted to a computer program using any generic language.
8

Dr. Alekha Kumar Mishra


Stages of algorithm development
Describing the problem
Identifying a suitable technique
Design of an Algorithm
Proof of Correctness of the Algorithm
Computing the time complexity of the Algorithm

Dr. Alekha Kumar Mishra


Abstract Data Types (ADT)
A model of data with generic description
independent of implentation details.
Consists of:
Components of the ADT
Set of procedures (operations)
Assume that at least one operand, or the result,
of any operation is of the ADT

10

Dr. Alekha Kumar Mishra


Example : Rational Number
Rational r:
Components : num: integer , denom : integer
denom 0
procedures
Rational add(r1,r2) : num = ( r1.num*r2.denom + r2.num*r2.denom),
denom = r1.denom*r2.denom
Rational multiply(r1,r2): num = r1.num*r2.num, , denom =
r1.denom*r2.denom
Rational divide(r1,r2): ...
Boolean equal(r1,r2):
...

11

Dr. Alekha Kumar Mishra


ANALYSIS OF ALGORITHM
It is achieved in two ways
Valuation of algorithm
Evaluation of algorithm
Valuation of algorithm
Program proving
Proof of correctness
Evaluation of algorithm
Performance measurement
Running Time and Space complexity analysis

12

Dr. Alekha Kumar Mishra


Proof of correctness
Two main conditions
1) The algorithm is complete/correct
The post condition is respected on all possible
inputs satisfying preconditions
2) The algorithm terminates
For all possible inputs, algorithm stops/halts.

13

Dr. Alekha Kumar Mishra


Loop Variants
Prove an invariant of the algorithm is true for all
interations
3-steps
1) Initialization : The invariant(s) is true prior to the
first iteration of the loop.
2) Maintenance : If the invariant is true for iteration
n, then it remains true for iteration, n+1.
3) Termination : When the loop terminates, the
invariant is true for entire input.

14

Dr. Alekha Kumar Mishra


Running Time Complexity
The amount of time taken by an algorithm to run to
completion
It is measured by number of primitive operations
required ( executed) to produce output
The time complexity is independent of
Speed of the computer
Word length
OS
Translation time

15

Dr. Alekha Kumar Mishra


Space complexity
The amount of space required by an algorithm
to run to completion.
Mostly , time and space complexity is computed
as a function of input size

16

Dr. Alekha Kumar Mishra


End of Introduction Slides

17

Dr. Alekha Kumar Mishra

Potrebbero piacerti anche