0% found this document useful (0 votes)
21 views46 pages

Data Structures

Uploaded by

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

Data Structures

Uploaded by

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

DATA STRUCTURES

III SEM DIPLOMA IN COMPUTER ENGINEERING


GOVERNMENT POLYTECHNIC PUNE
By-Ms.K.S.Sathawane
Lecturer in Computer Engineering
Chapter 1 : Introduction to Data
Structures
⚫ Introduction:
⚫ Data is a collection of numbers alphabets and symbols
combined together to represent information.
⚫ A computer takes raw data as input and after processing it
produces refined data as output.
⚫ A data is represented in many ways in computer system
such as binary representation, ASCII code , IEEE
representation format.
PRE-REQUISITES
Atomic and Composite Data types
⚫ Atomic data types: Elements that have no component
parts. Eg. Character Value A or number 153
⚫ Composite data types: A data type that allows a collection
of values to be associated with an identifier of that type.
Eg. Date of birth (15/3/1984)
Data Types
⚫ A data type, in programming, is a classification that
specifies which type of value a variable has and what type
of mathematical, relational or logical operations can be
applied to it without causing an error. A string, for
example, is a data type that is used to classify text and an
integer is a data type used to classify whole numbers.
⚫ Ex. Int x; [x can hold, integer type of data]
Data Types in C
⚫ Each variable in C has an associated data type. Each data type
requires different amounts of memory and has some specific
operations which can be performed over it. Let us briefly describe
them one by one:
⚫ Following are the examples of some very common data types used in
C:
⚫ char: The most basic data type in C. It stores a single character and
requires a single byte of memory in almost all compilers.
int: As the name suggests, an int variable is used to store an integer.
float: It is used to store decimal numbers (numbers with floating
point value) with single precision.
double: It is used to store decimal numbers (numbers with floating
point value) with double precision.
Contents
⚫ Data
⚫ Structure
⚫ Algorithm
BASIC
TERMINOLOGY-ELEMENTARY
DATA ORGANISATION
⚫ Data are values or a set of values
⚫ Data item refers to single unit of values
⚫ Data item
⚫ Group item :
⚫ Data item that can be subdivided into sub item.
⚫ Ex Name : First Name, Middle initial and Last Name
⚫ Elementary item:
⚫ Data item that can not be sub divided into sub item
⚫ Ex : PAN card number / Bank Pass Book Number is treated as
single item
⚫ Collection of data are frequently
organized into a hierarchy of fields,
records and files
Entity :
⚫ Something that has certain attributes or properties
⚫ which may be assigned values
⚫ Values may be numeric or non-numeric
⚫ Ex: The employee of an organization
⚫ Attributes Name Age Sex Employee Code
Values John 33 M 13472
BASIC
TERMINOLOGY-ELEMENTARY
DATA ORGANISATION
⚫ Entity with similar attributes ( e.g all employees of an
organization) form an entity set

⚫ Each attribute of an entity set has a range of values [ the


set of possible values that could be assigned to the
particular attribute]
fields, records and files
⚫ Field is a single elementary unit of information
representing an attribute of an entity

⚫ Record is the collection of field values of a given entity

⚫ File is the collection of records of the entities in a given


entity set
EXAMPLE:
Record

⚫ Fixed Length
⚫ Variable Length
Study of Data Structure includes the following
three steps

⚫ Logical or Mathematical description of the structure

⚫ Implementation of the structure on a computer

⚫ Quantitative analysis of the structure, which includes


determining the amount of memory needed to store
thestructure and the time required to process the structure
DATA TYPES
⚫ A data type is a term which refers to the kind of data that
may appear in computation.

⚫ Ex: in C

⚫ int, float, char, double, long double, etc.


Data Structure

⚫ The logical or mathematical model of a particular


organization of data

⚫ Choice of a model depends on two factor


⚫ It must be rich enough in structure to mirror the actual
relationships of the data in the real world
⚫ The structure should be simple enough that one can
effectively process the data when necessary
Data Structure
⚫ A data structure is a way to logically organize data that
specifies:

⚫ A set of data elements i.e., a data object and

⚫ A set of operations which may legally be applied to


elements of this data object.
OPERATIONS
⚫ Data appearing in DS are processed by means of certain
operation

⚫ Particular DS one chooses for a given situation


depends largely on the frequency with which specific
operations are performed
Data Structure Operations
1. Traversing: Accessing each record exactly once so that certain items in the

record may be processed.

2. Searching: Finding the location of the record with a given key value.

3. Inserting: Adding a new record to the structure.

4. Deleting: Removing a record from the structure.

5. Sorting: Arranging the records in some logical order.

6. Merging: Combing the records in two different sorted files into a single

sorted file.

20
DATA STRUCTURES
⚫ In real life applications, various kind of data other than the
primitive data are involved.
⚫ Manipulation of real-life data (user data) requires the following
essential tasks:
⚫ a) Storage representation of user data: User data should be
stored in such a way that computer can understand
⚫ b) Retrieval of stored data: Data stored in a computer should be
retrieved in such a way that user can understand.
⚫ c) Transformation of user data: Various operations which
require to be performed on user data so that it can be transformed
from one form to another.
CLASSIFICATION OF DATA
STRUCTURES
Types of Data Structure
Choice of Data Structures
The choice of data structures depends on two considerations:
1. It must be rich enough in structure to mirror the actual relationships of data in the
real world.
2. The structure should be simple enough that one can effectively process data when
necessary.

10 1
20 0
30
40 2 3
50 0 0
60 7
70 4 5 6
80 0 0 0 0

Figure 2: Array with 8 items Figure 3: Tree with 8 nodes

24
ARRAYS
⚫ An array is a collection of homogeneous
type of data elements.

⚫ An array is consisting of a collection of


elements .
OPERATIONS TO BE PERFROMED
ON ARRAY
⚫ 1.Traversing
⚫ 2.Search
⚫ 3.Insertion
⚫ 4.Deletion
⚫ 5.Sorting
⚫ 6.Merging
Representation of array in memory
Array Representation
STACK
⚫ A Stack is a list of elements in which an element may be
inserted or deleted at one end which is known as TOP of
the stack.
OPERATIONS PERFORMED ON
STACK
⚫ Push: add an element in stack
⚫ Pop: remove an element in stack
Representation of Stack
STACK REPRESENTATION
QUEUE
⚫ A queue is a linear list of element in which insertion can
be done at one end which is known as front and deletion
can be done which is known as rear.
OPERATIONS PERFORMED ON
QUEUE
⚫ Insertion : add a new element in queue
⚫ Deletion: Removing an element in queue
Queue Representation
LINKED LIST
⚫ A Linked list is a linear collection of data elements .It
has two part one is info and other is link part.info part
gives information and link part is address of next node
OPERATIONS PERFORMED ON
LINKED LIST
⚫ 1.Traversing
⚫ 2.Searching
⚫ 3.Insertion
⚫ 4.Deletion
Linked LIST Representation
NON LINEAR DATA
STRUCTURES
⚫ TREE
⚫ GRAPH
TREE
⚫ In computer science, a tree is a widely-used data
structure that emulates a hierarchical tree structure
with a set of linked nodes.
OPERATION ON TREE
⚫ 1.Insertion
⚫ 2.Deletion
⚫ 3.Searching
Tree Representation
GRAPH
⚫ A graph data structure may also associate to each edge
some edge value, such as a symbolic label or a numeric
attribute (cost, capacity, length, etc.).
OPERATIONS ON GRAPH
⚫ 1.Searching
⚫ 2.Insertion
⚫ 3.Deletion
Graph Representation
THANK YOU!

You might also like