UNIT 1. A Computer Program DSA Lec

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

U N I T 1 : I N T R O D U C T I O N TO

DATA ST R U C T U R E S A N D
A LG O R I T H M S
INTRODUCTION TO
DATA STRUCTURES
• A data structure is a
particular way of collecting
and organizing data in a
computer so that it can be
used effectively.
• It is named location that
can be used to store and
organize data
DATA

integer

3.14

“Hello World”
float

234

string
PRIMITIVE DATA STRUCTURE
Primitive data structure
- These are predefined integer

data, which supported


by the programming
language
- Built in data structure float

pointer string
NON PRIMITIVE DATA STRUCTURE
Non Primitive data structure
- These are data structure LINEAR

that are NOT defined by


programming language
- Created by programmer
- User defined data structure NON LINEAR
LINEAR
• The data items are arranged in linear sequence
NON LINEAR
• The data items are not in sequence
• A computer program is a series of
instructions to carry out a particular task
written in a language that a computer can

GOOD COMPUTER
understand.

PROGRAM
• The process of preparing and feeding the
instructions into the computer for
execution is referred as programming.
There are a number of
FEATURES features for a good
FOR A program
GOOD • Run efficiently and correctly
COMPUTER • Have a user friendly interface
PROGRAM • Be easy to read and understand
• Be easy to debug
• Be easy to modify
• Be easy to maintain
A Good Program is a combination of both algorithm
and a data structure

PROGRAMS An algorithm is a step by step recipe for solving an


CONSISTS OF instance of a problem

TWO THINGS: A data structure represents the logical relationship


ALGORITHMS that exists between individual elements of data to
carry out certain tasks
AND DATA A data structure defines a way of organizing all data
STRUCTURES items that consider not only the elements stored but
also stores the relationship between the elements
A data structure is a particular way of storing and
organizing data in a computer so that it can be used
efficiently.
ALGORITHMS

• An algorithm is a step by step recipe for solving an instance of a


problem.
• Every single procedure that a computer performs is an algorithm.
• An algorithm is a precise procedure for solving a problem in finite
number of steps.
• An algorithm states the actions to be executed and the order in
which these actions are to be executed.
• An algorithm is a well ordered collection of clear and simple
instructions of definite and effectively computable operations that
when executed produces a result and stops executing at some
point in a finite amount of time rather than just going on and on
infinitely.
ALGORITHM PROPERTIES

An algorithm – It must be – There can be no – It must be


possesses the – It must be composed of a ambiguity as to composed of a
following correct. series of concrete which step will be finite number of
properties: steps. performed next. steps.

– It must – It should use


– It should be
terminate. – It less memory – It results in one
efficient and
takes zero or space as much as or more outputs
flexible
more inputs possible
EFFICIENCY OF AN
ALGORITHM
• Writing efficient programs is what every programmer hopes to be
able to do. But what kinds of programs are efficient? The question
leads to the concept of generalization of programs.
• Algorithms are programs in a general form. An algorithm is an idea
upon which a program is built.
• An algorithm should meet three things:
1. It should be independent of the programming language in which
the idea is realized
2. Every programmer having enough knowledge and experience
should understand it
3. It should be applicable to inputs of all sizes
FRO M T HE DATA S T RUCT URE P O I NT O F
V I EW, FO L L OW ING A RE S O ME
I MP O RTA NT CAT E G O RI E S O F
A L G O RI T HMS

• Search − Algorithm to search an item in a data


structure.
• Sort − Algorithm to sort items in a certain order.
• Insert − Algorithm to insert item in a data
structure.
• Update − Algorithm to update an existing item in
a data structure.
• Delete − Algorithm to delete an existing item from
a data structure.
VARIOUS 1. Devising the Algorithm:
STEPS IN It’s a method for solving a problem. Each step of an algorithm
DEVELOPING must be precisely defined, and no vague statements should
ALGORITHMS be used. Pseudo code is used to describe the algorithm , in
less formal language than a programming language.
VARIOUS 2.Validating the Algorithm:
STEPS IN The proof of correctness of the algorithm. A human must be
DEVELOPING able to perform each step using paper and pencil by giving
ALGORITHMS the required input , use the algorithm and get the required
output in a finite amount of time.
VARIOUS
3. Expressing the algorithm:
STEPS IN
To implement the algorithm in a programming language. The
DEVELOPING algorithm used should terminate after a finite number of
ALGORITHMS steps.
DATA
DEFINITION
Data Definition defines a particular data
with the following characteristics.
• Atomic − Definition should define a
single concept.
• Traceable − Definition should be able
to be mapped to some data element.
• Accurate − Definition should be
unambiguous.
• Clear and Concise − Definition should
be understandable.
END OF UNIT 1
LECTURE

You might also like