SlideShare a Scribd company logo
1 of 32
Prof. K. Adisesha
adisesha1@rediffmail.com
Objectives :
• To understand how various data structures
can be classified
• To understand the most commonly used, basic
data types and data arrays
• To understand the characteristics and
mechanisms of problem-oriented data
structures used to solve specific problems, as
well as how to use a basic data structure for
program implementation
2K. Adisesha
 Data
It is an entity piece of information that is fact.
 Information
Instruction + Data
 Data Structure
It is a way of organizing data that considers not
only the items stored but also the relationship of
each data.
3K. Adisesha
Definition
 Primitive data structures
Data structure which can be directly operated by
machine level instruction
 Non primitive data structures
Data structure which can not be directly operated by
machine level instruction
 Linear data structure
 Non-Linear data structure
4K. Adisesha
Data Structure
Problem-OrientedBasic Data Structure
List Structure
Stack
Queue
Basic Data TypeStructure Type
Abstract Data Type
Hash
Tree
Array Type
Record Type Simple Type
Pointer Type
Integer
Real Number
Character
Enumeration
Partial
Logical
5K. Adisesha
 Dynamic memory allocation and pointers
 Recursion
 Searching and Sorting
 Stack
 Queue
 Linked list
 Tree
6K. Adisesha
Basic Data Type Simple Type
Integer - represents whole number and is
represented inside a computer as binary
numbers of fixed-point numbers that have no
significant digits below the decimal point.
Real Number - represents fixed-point and
floating point numbers.
Character - represents fixed-point and floating point
numbers.
Logical - used to perform logical operations,
such as AND, OR, and NOT operations.
7K. Adisesha
Structured Type Array Type
One Dimensional Array
One of the simplest and most common type
of data structure. It is an ordered set consisting of a
variable number of elements.
The number of subscripts of an array
determines its dimensionality.
ArrayX [ j ]
Array Name
Element / Subscript / Index
8K. Adisesha
Structured Type Array Type
One Dimensional Array
Example:
Grade [ j ] Grade [ 0 ] = 95
Grade [ 5 ] Grade [ 1 ] = 85
Grade [ 3 ] = 100
Grade [ 2 ] = 75
Grade [ 4 ] = 65
9K. Adisesha
Structured Type Array Type
Two Dimensional Array
An array with two subscripts. The first
subscripts is called the “row”, and the second is
called the “column”.
int ArrayX [ j ,
k ]
Array Name
indexBase type
10K. Adisesha
Structured Type Array Type
Two Dimensional
Array
Example: Grade [ 3 ,
4 ]
Grade C0 C1 C2 C3
R0 71 85 90 95
R1 97 88 78 87
R2 76 84 92 65
Grade [0,0] = 71
Grade [0,1] = 85
Grade [0,2] = 90
Grade [0,3] = 95
Grade [1,0] = 97
Grade [1,1] = 88
Grade [1,2] = 78
Grade [1,3] = 87
Grade [2,0] = 76
Grade [2,1] = 84
Grade [2,2] = 92
Grade [2,3] = 65
Row
major
11K. Adisesha
Structured Type Array Type
Two Dimensional
Array
Example: Grade [ 3 ,
4 ]
Grade C0 C1 C2 C3
R0 71 85 90 95
R1 97 88 78 87
R2 76 84 92 65
Grade [0,0] = 71
Grade [1,0] = 97
Grade [2,0] = 76
Grade [0,1] = 85
Grade [1,1] = 88
Grade [2,1] = 84
Grade [0,2] = 90
Grade [1,2] = 78
Grade [2,2] = 92
Grade [0,3] = 95
Grade [1,3] = 87
Grade [2,3] = 65
Column major
12K. Adisesha
Exercise
An array has an index of x[3..8] and start at
the address 245. It has 4 words per memory cell.
What will the location of element x[5]?
To get the location of elements
To get the number of elements in an
array
Loc [k] = base + w (k-LB)
NE = UB – LB + 1
13K. Adisesha
Memory Map
3 245
4 249
5 253
6 257
7 261
8 265
Element
s
Address
Locate

14K. Adisesha
Exercise
An automobile company uses array AUTO to
record the number of automobile sold each year
from 1932 to 1996. Locate AUTO[1980]. Assume
801 as starting address with 5 words long. Also find
the length of the array AUTO.
ANSWER:
Loc[1980] = 1041
NE = 65
15K. Adisesha
Exercise
Given a 4x5 array with [-3..0, 2..6) index,
starting address is 81 with 2 words per memory cell.
Locate [-1,5] using row major and column major
representation.
To get the location of elements (ROW
MAJOR)Loc [j,k] = base + w [ N (j-LB1) + (k-
LB2) ]
To get the location of elements (COLUMN MAJOR
Loc [j,k] = base + w [ M (k-LB2) + (j-
LB1) ]
To get the number of elements in an
arrayM = UB1 – LB1 + 1
N = UB2 – LB2 + 1
NE = M x N
16K. Adisesha
Memory Map
COLUM
N

Locate
BAC
2 3 4 5 6
-3 81 83 85 87 89
-2 91 93 95 97 99
-1
10
1
103 105 107 109
0
11
1
113 115 117 119
R
O
W
ROW
MAJOR
17K. Adisesha
Memory Map
COLUM
N

Locate
BAC
2 3 4 5 6
-3 81 89 97 105 113
-2 83 91 99 107 115
-1 85 93 101 109 117
0 87 95 103 111 119
R
O
W
COLUMN
MAJOR
18K. Adisesha
Exercise
When storing a two-dimensional array “a” with ten rows
and ten columns in continuous memory space in the direction
of rows, what is the address where a [5,6] is stored? In this
question, the address is represented in decimal numbers.
a [1,1]
a [1,2]
Addres
s
100
101
102
103
a. 145 c. 190b. 185 e. 212d. 208
19K. Adisesha
Problem-Oriented Data Structure
List Structure
A linear collection of data elements
called nodes and where linear order is
given by means of pointers.
DATA POINTER
FIELD FIELD
NODE
 AddressData 
20K. Adisesha
Problem-Oriented Data Structure
Types of List
Structure
Uni-directional
List
RAMOS 07H
03H
AQUINO 03H
05H
MARCOS 05H
01H
HEAD
ESTRADA NULL
07H
TAIL
21K. Adisesha
Problem-Oriented Data Structure
Types of List
Structure
Bi-directional List
NULL MARCOS 05H
01H
HEAD
01H AQUINO 03H
05H
05H RAMOS 07H
03H
03H ESTRADA NULL
07H
TAIL
22K. Adisesha
Problem-Oriented Data Structure
STACK
An ordered list where all operations are
restricted at one end of the list known as TOP.
List processing is based on Last-In First-Out
(LIFO).
Bottom

 Top
23K. Adisesha
Problem-Oriented Data Structure
STACK OPERATION
PUSH - inserts a new element at the
top of the stack
POP - retrieves the element at the top
and deletes it from stack.
TOP - retrieves the element at the top
of the stack
24K. Adisesha
Exercise
What will be the content of the stack after
performing the following operation?
1.Pop (S)
2.Push (E,S)
3.Push (F,S)
4.Pop (S)
5.Pop (S)
6.Push (G)
D
C
B
A
25K. Adisesha
Problem-Oriented Data Structure
STACK APPLICATION
INFIX - an expression
where operator is
placed in between the
operands
Example : (A + B)
PREFIX - an expression
where operator is placed
before the operands
Example : (+AB)
POSTFIX - an expression
where operator is placed
after the operands
Example : (AB+)
26K. Adisesha
Problem-Oriented Data Structure
TREE Structure
It is a collection of data items called nodes.
Each node has a relationship with one or more nodes
thereby giving a hierarchical structure.
A
CB D
FE G IH J
LK M
Binary Tree
/
+*
CB DA
27K. Adisesha
Exercise
Create a Tree Structure based on the given
prefix and postfix notation.
1.) - + / *A B G M * ^ N 3 - + G H ^ I 2
2.) F M 3 ^ * S / K * M 3 ^ L * - Q P 2 ^ * +
28K. Adisesha
 1. Write a C program to search for an element in an array using Binary
search
 2. Write a C program to sort a list of N elements using Bubble sort
Technique
 3. Write a C program to demonstrate the working of stack of size N using an
array. The elements of the stack may assume to be of type integer or real,
the operations to be supported are 1. PUSH 2. POP 3. DISPLAY. The
program should print appropriate messages for STACK overflow, Under flow
and empty, use separate functions to detect these cases
 4. Write a C program to simulate the working of an ordinary Queue using an
array. Provide the operations QINSERT, QDELETE and QDISPLAY. Check
the Queue status for empty and full.
 5. Write a C program to simulate the working of an Circular Queue using an
array. Provide the operations CQINSERT, CQDELETE and CQDISPLAY.
Check the Circular Queue status for empty and full.
K. Adisesha 29
 6. Using dynamic variables and pointers Write a C program to construct a singly linked list
consisting of the following information in each node;
Roll - No (Integer), Name (Character string) The operations to be supported are ;
1. LINSERT Inserting a node in the front of the list
2. LDELETE Deleting the node based on Roll - No
3. LSEARCH Searching a node based on Roll-No
4. LDISPLAY Displaying all the nodes in the list
 7. Write a C program to sort a list of N elements using Merge sort Algorithm
 8. Using Dynamic variables and pointers construct Binary search tree of integers , Write C
functions to do the following ;
1. Given a KEY, Perform a search in Binary search tree . If it is found display Key
found else insert the key in the Binary search tree.
2. While constructing the Binary search tree do not add any duplicate
3. Display the tree using any of the traversal method
K. Adisesha 30
 9. Write a C program to sort a list of N elements of integer type using
heap sort Algorithm
 10. Write a C program to simulate the working of Towers of Hanoi
problem for N disks , print the total number of Moves taken by the
program.
 11. Write a C program to sort a list of N elements of integer type using
quick sort Algorithm
 12. Write a C program to find ncr using recursion
K. Adisesha 31
Thank you
K. Adisesha 32

More Related Content

What's hot

Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria
 

What's hot (20)

Array in c++
Array in c++Array in c++
Array in c++
 
Array ppt
Array pptArray ppt
Array ppt
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Data Structures (CS8391)
Data Structures (CS8391)Data Structures (CS8391)
Data Structures (CS8391)
 
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in python
 
Data Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptxData Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptx
 
Array data structure
Array data structureArray data structure
Array data structure
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
 

Viewers also liked

Data structure using c bcse 3102 pcs 1002
Data structure using c bcse 3102 pcs 1002Data structure using c bcse 3102 pcs 1002
Data structure using c bcse 3102 pcs 1002
SANTOSH RATH
 
Indexing and hashing
Indexing and hashingIndexing and hashing
Indexing and hashing
Jeet Poria
 
Concept of hashing
Concept of hashingConcept of hashing
Concept of hashing
Rafi Dar
 
What is the role of president of india
What is the role of president of indiaWhat is the role of president of india
What is the role of president of india
Jay Rajpurohit
 
The powers and functions of the president 2
The powers and functions of the president 2The powers and functions of the president 2
The powers and functions of the president 2
Sunit Kapoor
 
Introduction of data structure
Introduction of data structureIntroduction of data structure
Introduction of data structure
eShikshak
 

Viewers also liked (20)

DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
Data structure using c bcse 3102 pcs 1002
Data structure using c bcse 3102 pcs 1002Data structure using c bcse 3102 pcs 1002
Data structure using c bcse 3102 pcs 1002
 
Hashing 1
Hashing 1Hashing 1
Hashing 1
 
Data structures using C
Data structures using CData structures using C
Data structures using C
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
 
Hashing
HashingHashing
Hashing
 
Indian president
Indian presidentIndian president
Indian president
 
Decision making and looping
Decision making and loopingDecision making and looping
Decision making and looping
 
Hashing
HashingHashing
Hashing
 
Stack a Data Structure
Stack a Data StructureStack a Data Structure
Stack a Data Structure
 
Indexing and hashing
Indexing and hashingIndexing and hashing
Indexing and hashing
 
11. Hashing - Data Structures using C++ by Varsha Patil
11. Hashing - Data Structures using C++ by Varsha Patil11. Hashing - Data Structures using C++ by Varsha Patil
11. Hashing - Data Structures using C++ by Varsha Patil
 
Concept of hashing
Concept of hashingConcept of hashing
Concept of hashing
 
What is the role of president of india
What is the role of president of indiaWhat is the role of president of india
What is the role of president of india
 
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....
 
Hashing and Hash Tables
Hashing and Hash TablesHashing and Hash Tables
Hashing and Hash Tables
 
Hashing PPT
Hashing PPTHashing PPT
Hashing PPT
 
The powers and functions of the president 2
The powers and functions of the president 2The powers and functions of the president 2
The powers and functions of the president 2
 
Introduction of data structure
Introduction of data structureIntroduction of data structure
Introduction of data structure
 
Hashing
HashingHashing
Hashing
 

Similar to Data structures using c

PPT Lecture 2.2.1 onn c++ data structures
PPT Lecture 2.2.1 onn c++ data structuresPPT Lecture 2.2.1 onn c++ data structures
PPT Lecture 2.2.1 onn c++ data structures
midtushar
 
data structure and algorithm Array.pptx btech 2nd year
data structure and algorithm  Array.pptx btech 2nd yeardata structure and algorithm  Array.pptx btech 2nd year
data structure and algorithm Array.pptx btech 2nd year
palhimanshi999
 
data structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptxdata structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptx
coc7987515756
 
DS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and EngineeringDS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and Engineering
RAJASEKHARV8
 

Similar to Data structures using c (20)

PPT Lecture 2.2.1 onn c++ data structures
PPT Lecture 2.2.1 onn c++ data structuresPPT Lecture 2.2.1 onn c++ data structures
PPT Lecture 2.2.1 onn c++ data structures
 
data structure and algorithm Array.pptx btech 2nd year
data structure and algorithm  Array.pptx btech 2nd yeardata structure and algorithm  Array.pptx btech 2nd year
data structure and algorithm Array.pptx btech 2nd year
 
data structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptxdata structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptx
 
Data Structure.pdf
Data Structure.pdfData Structure.pdf
Data Structure.pdf
 
Ds important questions
Ds important questionsDs important questions
Ds important questions
 
Cs341
Cs341Cs341
Cs341
 
Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...
 
DS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and EngineeringDS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and Engineering
 
Data structure
 Data structure Data structure
Data structure
 
Mysql1
Mysql1Mysql1
Mysql1
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
 
2D Array
2D Array 2D Array
2D Array
 
2. Array in Data Structure
2. Array in Data Structure2. Array in Data Structure
2. Array in Data Structure
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
 
Python - Lecture 12
Python - Lecture 12Python - Lecture 12
Python - Lecture 12
 
Unit ii data structure-converted
Unit  ii data structure-convertedUnit  ii data structure-converted
Unit ii data structure-converted
 
unit1Intro_final.pptx
unit1Intro_final.pptxunit1Intro_final.pptx
unit1Intro_final.pptx
 
Arrays
ArraysArrays
Arrays
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHIBCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
 
Data structure array
Data structure  arrayData structure  array
Data structure array
 

More from Prof. Dr. K. Adisesha

More from Prof. Dr. K. Adisesha (20)

Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdf
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdf
 
Introduction to Computers.pdf
Introduction to Computers.pdfIntroduction to Computers.pdf
Introduction to Computers.pdf
 
R_Programming.pdf
R_Programming.pdfR_Programming.pdf
R_Programming.pdf
 
Scholarship.pdf
Scholarship.pdfScholarship.pdf
Scholarship.pdf
 
Operating System-2 by Adi.pdf
Operating System-2 by Adi.pdfOperating System-2 by Adi.pdf
Operating System-2 by Adi.pdf
 
Operating System-1 by Adi.pdf
Operating System-1 by Adi.pdfOperating System-1 by Adi.pdf
Operating System-1 by Adi.pdf
 
Operating System-adi.pdf
Operating System-adi.pdfOperating System-adi.pdf
Operating System-adi.pdf
 
Data_structure using C-Adi.pdf
Data_structure using C-Adi.pdfData_structure using C-Adi.pdf
Data_structure using C-Adi.pdf
 
JAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdfJAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdf
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 

Recently uploaded (20)

latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 

Data structures using c

  • 2. Objectives : • To understand how various data structures can be classified • To understand the most commonly used, basic data types and data arrays • To understand the characteristics and mechanisms of problem-oriented data structures used to solve specific problems, as well as how to use a basic data structure for program implementation 2K. Adisesha
  • 3.  Data It is an entity piece of information that is fact.  Information Instruction + Data  Data Structure It is a way of organizing data that considers not only the items stored but also the relationship of each data. 3K. Adisesha
  • 4. Definition  Primitive data structures Data structure which can be directly operated by machine level instruction  Non primitive data structures Data structure which can not be directly operated by machine level instruction  Linear data structure  Non-Linear data structure 4K. Adisesha
  • 5. Data Structure Problem-OrientedBasic Data Structure List Structure Stack Queue Basic Data TypeStructure Type Abstract Data Type Hash Tree Array Type Record Type Simple Type Pointer Type Integer Real Number Character Enumeration Partial Logical 5K. Adisesha
  • 6.  Dynamic memory allocation and pointers  Recursion  Searching and Sorting  Stack  Queue  Linked list  Tree 6K. Adisesha
  • 7. Basic Data Type Simple Type Integer - represents whole number and is represented inside a computer as binary numbers of fixed-point numbers that have no significant digits below the decimal point. Real Number - represents fixed-point and floating point numbers. Character - represents fixed-point and floating point numbers. Logical - used to perform logical operations, such as AND, OR, and NOT operations. 7K. Adisesha
  • 8. Structured Type Array Type One Dimensional Array One of the simplest and most common type of data structure. It is an ordered set consisting of a variable number of elements. The number of subscripts of an array determines its dimensionality. ArrayX [ j ] Array Name Element / Subscript / Index 8K. Adisesha
  • 9. Structured Type Array Type One Dimensional Array Example: Grade [ j ] Grade [ 0 ] = 95 Grade [ 5 ] Grade [ 1 ] = 85 Grade [ 3 ] = 100 Grade [ 2 ] = 75 Grade [ 4 ] = 65 9K. Adisesha
  • 10. Structured Type Array Type Two Dimensional Array An array with two subscripts. The first subscripts is called the “row”, and the second is called the “column”. int ArrayX [ j , k ] Array Name indexBase type 10K. Adisesha
  • 11. Structured Type Array Type Two Dimensional Array Example: Grade [ 3 , 4 ] Grade C0 C1 C2 C3 R0 71 85 90 95 R1 97 88 78 87 R2 76 84 92 65 Grade [0,0] = 71 Grade [0,1] = 85 Grade [0,2] = 90 Grade [0,3] = 95 Grade [1,0] = 97 Grade [1,1] = 88 Grade [1,2] = 78 Grade [1,3] = 87 Grade [2,0] = 76 Grade [2,1] = 84 Grade [2,2] = 92 Grade [2,3] = 65 Row major 11K. Adisesha
  • 12. Structured Type Array Type Two Dimensional Array Example: Grade [ 3 , 4 ] Grade C0 C1 C2 C3 R0 71 85 90 95 R1 97 88 78 87 R2 76 84 92 65 Grade [0,0] = 71 Grade [1,0] = 97 Grade [2,0] = 76 Grade [0,1] = 85 Grade [1,1] = 88 Grade [2,1] = 84 Grade [0,2] = 90 Grade [1,2] = 78 Grade [2,2] = 92 Grade [0,3] = 95 Grade [1,3] = 87 Grade [2,3] = 65 Column major 12K. Adisesha
  • 13. Exercise An array has an index of x[3..8] and start at the address 245. It has 4 words per memory cell. What will the location of element x[5]? To get the location of elements To get the number of elements in an array Loc [k] = base + w (k-LB) NE = UB – LB + 1 13K. Adisesha
  • 14. Memory Map 3 245 4 249 5 253 6 257 7 261 8 265 Element s Address Locate  14K. Adisesha
  • 15. Exercise An automobile company uses array AUTO to record the number of automobile sold each year from 1932 to 1996. Locate AUTO[1980]. Assume 801 as starting address with 5 words long. Also find the length of the array AUTO. ANSWER: Loc[1980] = 1041 NE = 65 15K. Adisesha
  • 16. Exercise Given a 4x5 array with [-3..0, 2..6) index, starting address is 81 with 2 words per memory cell. Locate [-1,5] using row major and column major representation. To get the location of elements (ROW MAJOR)Loc [j,k] = base + w [ N (j-LB1) + (k- LB2) ] To get the location of elements (COLUMN MAJOR Loc [j,k] = base + w [ M (k-LB2) + (j- LB1) ] To get the number of elements in an arrayM = UB1 – LB1 + 1 N = UB2 – LB2 + 1 NE = M x N 16K. Adisesha
  • 17. Memory Map COLUM N  Locate BAC 2 3 4 5 6 -3 81 83 85 87 89 -2 91 93 95 97 99 -1 10 1 103 105 107 109 0 11 1 113 115 117 119 R O W ROW MAJOR 17K. Adisesha
  • 18. Memory Map COLUM N  Locate BAC 2 3 4 5 6 -3 81 89 97 105 113 -2 83 91 99 107 115 -1 85 93 101 109 117 0 87 95 103 111 119 R O W COLUMN MAJOR 18K. Adisesha
  • 19. Exercise When storing a two-dimensional array “a” with ten rows and ten columns in continuous memory space in the direction of rows, what is the address where a [5,6] is stored? In this question, the address is represented in decimal numbers. a [1,1] a [1,2] Addres s 100 101 102 103 a. 145 c. 190b. 185 e. 212d. 208 19K. Adisesha
  • 20. Problem-Oriented Data Structure List Structure A linear collection of data elements called nodes and where linear order is given by means of pointers. DATA POINTER FIELD FIELD NODE  AddressData  20K. Adisesha
  • 21. Problem-Oriented Data Structure Types of List Structure Uni-directional List RAMOS 07H 03H AQUINO 03H 05H MARCOS 05H 01H HEAD ESTRADA NULL 07H TAIL 21K. Adisesha
  • 22. Problem-Oriented Data Structure Types of List Structure Bi-directional List NULL MARCOS 05H 01H HEAD 01H AQUINO 03H 05H 05H RAMOS 07H 03H 03H ESTRADA NULL 07H TAIL 22K. Adisesha
  • 23. Problem-Oriented Data Structure STACK An ordered list where all operations are restricted at one end of the list known as TOP. List processing is based on Last-In First-Out (LIFO). Bottom   Top 23K. Adisesha
  • 24. Problem-Oriented Data Structure STACK OPERATION PUSH - inserts a new element at the top of the stack POP - retrieves the element at the top and deletes it from stack. TOP - retrieves the element at the top of the stack 24K. Adisesha
  • 25. Exercise What will be the content of the stack after performing the following operation? 1.Pop (S) 2.Push (E,S) 3.Push (F,S) 4.Pop (S) 5.Pop (S) 6.Push (G) D C B A 25K. Adisesha
  • 26. Problem-Oriented Data Structure STACK APPLICATION INFIX - an expression where operator is placed in between the operands Example : (A + B) PREFIX - an expression where operator is placed before the operands Example : (+AB) POSTFIX - an expression where operator is placed after the operands Example : (AB+) 26K. Adisesha
  • 27. Problem-Oriented Data Structure TREE Structure It is a collection of data items called nodes. Each node has a relationship with one or more nodes thereby giving a hierarchical structure. A CB D FE G IH J LK M Binary Tree / +* CB DA 27K. Adisesha
  • 28. Exercise Create a Tree Structure based on the given prefix and postfix notation. 1.) - + / *A B G M * ^ N 3 - + G H ^ I 2 2.) F M 3 ^ * S / K * M 3 ^ L * - Q P 2 ^ * + 28K. Adisesha
  • 29.  1. Write a C program to search for an element in an array using Binary search  2. Write a C program to sort a list of N elements using Bubble sort Technique  3. Write a C program to demonstrate the working of stack of size N using an array. The elements of the stack may assume to be of type integer or real, the operations to be supported are 1. PUSH 2. POP 3. DISPLAY. The program should print appropriate messages for STACK overflow, Under flow and empty, use separate functions to detect these cases  4. Write a C program to simulate the working of an ordinary Queue using an array. Provide the operations QINSERT, QDELETE and QDISPLAY. Check the Queue status for empty and full.  5. Write a C program to simulate the working of an Circular Queue using an array. Provide the operations CQINSERT, CQDELETE and CQDISPLAY. Check the Circular Queue status for empty and full. K. Adisesha 29
  • 30.  6. Using dynamic variables and pointers Write a C program to construct a singly linked list consisting of the following information in each node; Roll - No (Integer), Name (Character string) The operations to be supported are ; 1. LINSERT Inserting a node in the front of the list 2. LDELETE Deleting the node based on Roll - No 3. LSEARCH Searching a node based on Roll-No 4. LDISPLAY Displaying all the nodes in the list  7. Write a C program to sort a list of N elements using Merge sort Algorithm  8. Using Dynamic variables and pointers construct Binary search tree of integers , Write C functions to do the following ; 1. Given a KEY, Perform a search in Binary search tree . If it is found display Key found else insert the key in the Binary search tree. 2. While constructing the Binary search tree do not add any duplicate 3. Display the tree using any of the traversal method K. Adisesha 30
  • 31.  9. Write a C program to sort a list of N elements of integer type using heap sort Algorithm  10. Write a C program to simulate the working of Towers of Hanoi problem for N disks , print the total number of Moves taken by the program.  11. Write a C program to sort a list of N elements of integer type using quick sort Algorithm  12. Write a C program to find ncr using recursion K. Adisesha 31