0% found this document useful (0 votes)
48 views13 pages

UNIT I:Introduction To Algorithm & Program Design

The document discusses elementary data organization and defines key terms like data item, entity, attribute, field, record, and file. It also defines abstract data types and differentiates between types, data types, abstract data types, and data structures. Finally, it provides an example of the stack abstract data type, defining it as a restricted list that uses a last-in-first-out strategy and listing common operations on stacks like push, pop, size, empty and full.

Uploaded by

madhuri nimse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views13 pages

UNIT I:Introduction To Algorithm & Program Design

The document discusses elementary data organization and defines key terms like data item, entity, attribute, field, record, and file. It also defines abstract data types and differentiates between types, data types, abstract data types, and data structures. Finally, it provides an example of the stack abstract data type, defining it as a restricted list that uses a last-in-first-out strategy and listing common operations on stacks like push, pop, size, empty and full.

Uploaded by

madhuri nimse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 13

UNIT I:Introduction to Algorithm &

Program

Design

Topic 1: Basic
Terminology
By: Prof G R Patil
AIT Pune
Elementary Data Organisation
 Data are simply Values or sets of Values
 Data Item is Single unit of values
 Group Items Data items which can be divided
into subitems
 Elementary Items are the data items which can
not be divided into subitems
 Collection of data organised as fields, records
and files
 Entity is something which has certain attributes
which may be assigned values
Attribute Name Age Sex
Value Lalu Prasad 66 M
Elementary Data Organisation
 Entity Set Entities with similar attributes
 Information is data with given attributes
(Meaningful data)
 Field Elementary unit of information
representing attribute
 Record collection of Field values of a given
entity
 File Collection of records of entities in a given
entity set
 Primary Key A field which uniquely determines
a record in a file
Elementary Data Organisation
 Records Fixed length and Variable length
 Organisation of data can be more complex
 Study of data structure
 Logical or Mathematical description of the

structure
 Implementation of structure on computer

 Quantitative analysis – Time and Space


Data Structures
 Logical or Mathematical model of a particular
organisation of data
 Rich enough to mirror data in real world
 Simple for effective processing
 Classification
 Primitive Integer, Real, Char, Boolean
 Non-Primitive
 Linear Array, Linked List, Stack, Queue
 NonLinear Tree, Graph
Data Structures Operations
 Traversing
 Searching
 Inserting
 Deleting
 Sorting
 Merging
Abstract Data Types (ADTs) and data structures:
terminology and definitions
 A type is a collection of values. For example, the boolean type consists of
two values, true and false; the byte type consists of all integers between
-127 and +128.
 A data type is (i) a domain of allowed values and (ii) a set of operations
on these values.
 A data type is a type + a set of operations on data of the type. For
example, integers of type byte plus {+, -, *, /} comprise the data type
byte. An integer array is a data type which has assign and search
operations associated with it.
 An abstract data type is a data type solely defined in terms of a type and
a set of operations on that type. Each operation is defined in terms of its
input and output without specifying how the data type is implemented. A
stack is an example of an ADT, defined in terms of push and pop
operations.
 A data structure is an implementation of an ADT. The Stack ADT, for
example, an be implemented by means of an array.
BACKGROUND

Problem solving with a computer means processing


data. To process data, we need to define the data type
and the operation to be performed on the data. The
definition of the data type and the definition of the
operation to be applied to the data is part of the idea
behind an abstract data type (ADT)—to hide how the
operation is performed on the data. In other words, the
user of an ADT needs only to know that a set of
operations are available for the data type, but does not
need to know how they are applied.
Simple ADTs
Many programming languages already define some simple
ADTs as integral parts of the language. For example, the C
language defines a simple ADT as an integer. The type of
this ADT is an integer with predefined ranges. C also defines
several operations that can be applied to this data type
(addition, subtraction, multiplication, division and so on). C
explicitly defines these operations on integers and what we
expect as the results. A programmer who writes a C program
to add two integers should know about the integer ADT and
the operations that can be applied to it.
Complex ADTs
Although several simple ADTs, such as integer, real,
character, pointer and so on, have been implemented and are
available for use in most languages, many useful complex
ADTs are not. For example list ADT, a stack ADT, a queue
ADT and so on. To be efficient, these ADTs should be
created and stored in the library of the computer to be used.

i
The concept of abstraction means:
1. We know what a data type can do.
2. How it is done is hidden.
Definition
Let us now define an ADT. An abstract data type is a data
type packaged with the operations that are meaningful for the
data type. We then encapsulate the data and the operations
on the data and hide them from the user.

i
Abstract data type:
1. Definition of data.
2. Definition of operations.
3. Encapsulation of data and operation.
Model for an abstract data type
The ADT model is shown in Figure 1. Inside the ADT are
two different parts of the model: data structure and
operations (public and private).

Figure 1 The model for an ADT


The Stack ADT
Definition A stack is a restricted list in which entries are
added and removed from the same end, called the top.
This strategy is known as last-in-first-out (LIFO)
strategy.
Operations (methods) on stacks:
push (item) Inserts item on the top of the stack
pop () Removes the top item
size () Returns the number of items in the
stack
empty () Returns true if the stack is empty
full() Returns true if the stack is full
ontop() Returns the top element without
removing it from the stack

You might also like