SlideShare une entreprise Scribd logo
1  sur  32
What is the Meaning of Data ????
 Data is the unit of information like as alphabetic , numeric ,
scientific value etc.
 Data are just a collection of facts and figures.
 Data will be collected through various observation
 Structure is the organization of data in a proper channel or
in systemic order with taking from previous result.
 Structure is pre-define method to handle or manage the
data , information or any other things.
What is Structure ??
DNA
Structure
What is Data Structure
 Data Structure can be defined as the group of data elements which
provides an efficient way of storing and organising data in the computer so
that it can be used efficiently.
 Data may be arranged in many different ways, such as the logical or
mathematical model, for a particular organization of data is termed as a data
structure.
 The variety of a specific data model depends on the two factors -
1. Firstly, it must be loaded enough in structure to reflect the actual
relationships of the data with the real-world object.
2. Secondly, the formation should be simple enough so that anyone
can efficiently process the data each time it is necessary.
Data Structure
Image &
Video data
Information
Mathematical
model
Need of Data Structures
 Processor speed: To handle very large amount of data, high speed
processing is required, but as the data is growing day by day to the
billions of files per entity, processor may fail to deal with that much
amount of data.
 Data Search: Consider an inventory size of 100 items in a store, If our
application needs to search for a particular item, it needs to traverse 100
items every time, results in slowing down the search process.
 Multiple requests: If thousands of users are searching the data
simultaneously on a web server, then there are the chances that a very
large server can be failed during that process
Data Structure Classification
1. An array is defined as the collection of similar type of data items stored at
contiguous memory locations.
2. Arrays are the derived data type in C programming language which can store the
primitive type of data such as int, char, double, float, etc.
3. It also has the capability to store the collection of derived data types, such as
pointers, structure, etc.
4. The array is the simplest data structure where each data element can be randomly
accessed by using its index number.
1. Each element of an array is of same data type and carries the same size,
i.e., int = 4 bytes.
2. Elements of the array are stored at contiguous memory locations where
the first element is stored at the smallest memory location.
3. Elements of the array can be randomly accessed since we can calculate
the address of each element of the array with the given base address and
the size of the data element.
Properties of Array
Introduction
Declaration of Array {1-D} :-
Data_type array_name[array_size];
Ex.
int marks[5];
Initialization of C Array
1) One by one or using a single statement :-
double balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0};
2) Size of the array :-
double balance[] = {1000.0, 2.0, 3.4, 7.0, 50.0};
Ex.
marks[0]=80;//initialization of array
marks[1]=60;
marks[2]=70;
marks[3]=85;
marks[4]=75;
Two Dimensional Array ( 2-D ):-
1. The two-dimensional array can be defined as an array of arrays. The 2D array is
organized as matrices which can be represented as the collection of rows and
columns.
2. To declare a two-dimensional integer array of size [x][y].
Declaration of two dimensional Array :-
data_type array_name[rows][columns];
Ex.
int twodimen[4][3];
int arr[4][3]={{1,2,3},{2,3,4},{3,4,5},{4,5,6}};
DataStructure
Stack
 A stack is an Abstract Data Type (ADT), commonly used in programming
languages. It is named stack as it behaves like a real-world stack, for example –
(1) deck of cards (2) pile of plates, etc.
stack
 A Stack is a linear data structure that follows the LIFO (Last-In-First-
Out) principle. This means the last element inserted inside the stack is
removed first.
 It contains only one pointer top pointer pointing to the topmost element of
the stack. Whenever an element is added in the stack, it is added on the top of
the stack, and the element can be deleted only from the stack.
 In other words, a stack can be defined as a container in which insertion
and deletion can be done from the one end known as the top of the stack.
Stack Representation
Standard Stack Operations
1) push(): When we insert an element in a stack then the operation is known as a
push. If the stack is full then the overflow condition occurs.
2) pop(): When we delete an element from the stack, the operation is known as a
pop. If the stack is empty this state is known as an underflow state.
3) isEmpty(): It determines whether the stack is empty or not.
4) isFull(): It determines whether the stack is full or not.
5) peek(): Get the value of the top element without removing it
6) count(): It returns the total number of elements available in a stack.
7) change(): It changes the element at the given position.
8) display(): It prints all the elements available in the stack.
PUSH operation
1) Before inserting an element in a stack, we check whether the stack is full.
2) If we try to insert the element in a stack, and the stack is full, then overflow condition.
3) When we initialize , we set the value of top as -1 to check that the stack is empty.
4) When the new element is pushed, the value of the top gets incremented,
i.e., top=top+1, and the element will be placed at the new position of the top
5) The elements will be inserted until we reach the max size of the stack.
POP operation
1) Before deleting the element from the stack, we check whether the stack is empty.
2) If we try to delete the element from the empty stack, then the underflow condition.
3) If the stack is not empty, we first access the element which is pointed by the top
4) Once the pop operation is performed, the top is decremented by 1, i.e., top=top-1.
Working of Stack Data Structure
Applications of Stack in Data Structure
1. Evaluation of Arithmetic Expressions
1) Infix Notation
2) Prefix Notation
3) Postfix Notation
2. Backtracking
3. Delimiter Checking
4. Reverse a Data
5. Processing Function Calls
1. A queue can be defined as an ordered list which enables insert
operations to be performed at one end called REAR and delete
operations to be performed at another end called FRONT.
2. Queue is referred to be as First In First Out list.
3. For example, people waiting in line for a rail ticket form a queue.
4. A queue is a linear list of elements
Queue
Queue Representation
Queue is an abstract data structure, similar to Stacks.
 Queue is open at both its ends. One end is always used to insert data
(enqueue) and the other is used to remove data (dequeue).
Basic Operations
enqueue() − add (store/insert) an item to the queue.
dequeue() − remove an item from the queue.
peek() − Gets the element at the front of the queue without
removing it.
isfull() − Checks if the queue is full.
isempty() − Checks if the queue is empty.
Enqueue Operation
Queues maintain two data pointers, front and rear.
Therefore, its operations are comparatively difficult to implement
than that of stacks.
Step 1 − Check if the queue is full.
Step 2 − If the queue is full, produce overflow error and exit.
Step 3 − If the queue is not full, increment rear pointer to point the
next empty space.
Step 4 − Add data element to the queue location, where the rear
is pointing.
Step 5 − return success.
Dequeue Operation
Accessing data from the queue is a process of two tasks −
1)access the data where front is pointing
2)remove the data after access.
Step 1 − Check if the queue is empty.
Step 2 − If the queue is empty, produce underflow error and exit.
Step 3 − If the queue is not empty, access the data where front is
pointing.
Step 4 − Increment front pointer to point to the next available data
element.
Step 5 − Return success.
Types of Queue
1) Linear Queue
2) Circular Queue
1.Linear Queue
Data insert at
Rear position , if
we insert more
value then the
rear value by +1.
Data deletion from
front position , if
we delete more
value then the
front value by -1.


2.Circular Queue
Applications of Queue
1. Serving requests on a single shared resource, like a printer, CPU task
scheduling etc.
2. In real life scenario, Call Center phone systems uses Queues to hold
people calling them in an order, until a service representative is free.
3. Handling of interrupts in real-time systems. The interrupts are handled
in the same order as they arrive i.e First come first served
01-Introduction of DSA-1.pptx

Contenu connexe

Similaire à 01-Introduction of DSA-1.pptx

chapter-4-data-structure.pdf
chapter-4-data-structure.pdfchapter-4-data-structure.pdf
chapter-4-data-structure.pdfstudy material
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1blessyboban92
 
Data Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxData Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxmexiuro901
 
Data Structures by Maneesh Boddu
Data Structures by Maneesh BodduData Structures by Maneesh Boddu
Data Structures by Maneesh Boddumaneesh boddu
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyMalikireddy Bramhananda Reddy
 
Data Structure
Data Structure Data Structure
Data Structure Ibrahim MH
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queueRajkiran Nadar
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptxskilljiolms
 
Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structurechouguleamruta24
 
Data Structure Using C
Data Structure Using CData Structure Using C
Data Structure Using Ccpjcollege
 
21CS32 DS Module 1 PPT.pptx
21CS32 DS Module 1 PPT.pptx21CS32 DS Module 1 PPT.pptx
21CS32 DS Module 1 PPT.pptxreddy19841
 

Similaire à 01-Introduction of DSA-1.pptx (20)

chapter-4-data-structure.pdf
chapter-4-data-structure.pdfchapter-4-data-structure.pdf
chapter-4-data-structure.pdf
 
1.1 ADS data-structure.pdf
1.1 ADS data-structure.pdf1.1 ADS data-structure.pdf
1.1 ADS data-structure.pdf
 
Unit i(dsc++)
Unit i(dsc++)Unit i(dsc++)
Unit i(dsc++)
 
DS UNIT 1.pdf
DS UNIT 1.pdfDS UNIT 1.pdf
DS UNIT 1.pdf
 
DS UNIT 1.pdf
DS UNIT 1.pdfDS UNIT 1.pdf
DS UNIT 1.pdf
 
Data structure
Data structureData structure
Data structure
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
 
Data Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxData Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptx
 
unit 2.pptx
unit 2.pptxunit 2.pptx
unit 2.pptx
 
M v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notesM v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notes
 
Data Structures by Maneesh Boddu
Data Structures by Maneesh BodduData Structures by Maneesh Boddu
Data Structures by Maneesh Boddu
 
Data structures in c#
Data structures in c#Data structures in c#
Data structures in c#
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
 
Data Structure
Data Structure Data Structure
Data Structure
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queue
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptx
 
Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structure
 
DS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptxDS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptx
 
Data Structure Using C
Data Structure Using CData Structure Using C
Data Structure Using C
 
21CS32 DS Module 1 PPT.pptx
21CS32 DS Module 1 PPT.pptx21CS32 DS Module 1 PPT.pptx
21CS32 DS Module 1 PPT.pptx
 

Dernier

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Dernier (20)

Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

01-Introduction of DSA-1.pptx

  • 1.
  • 2. What is the Meaning of Data ????  Data is the unit of information like as alphabetic , numeric , scientific value etc.  Data are just a collection of facts and figures.  Data will be collected through various observation
  • 3.  Structure is the organization of data in a proper channel or in systemic order with taking from previous result.  Structure is pre-define method to handle or manage the data , information or any other things. What is Structure ?? DNA Structure
  • 4. What is Data Structure  Data Structure can be defined as the group of data elements which provides an efficient way of storing and organising data in the computer so that it can be used efficiently.  Data may be arranged in many different ways, such as the logical or mathematical model, for a particular organization of data is termed as a data structure.  The variety of a specific data model depends on the two factors - 1. Firstly, it must be loaded enough in structure to reflect the actual relationships of the data with the real-world object. 2. Secondly, the formation should be simple enough so that anyone can efficiently process the data each time it is necessary.
  • 5. Data Structure Image & Video data Information Mathematical model
  • 6. Need of Data Structures  Processor speed: To handle very large amount of data, high speed processing is required, but as the data is growing day by day to the billions of files per entity, processor may fail to deal with that much amount of data.  Data Search: Consider an inventory size of 100 items in a store, If our application needs to search for a particular item, it needs to traverse 100 items every time, results in slowing down the search process.  Multiple requests: If thousands of users are searching the data simultaneously on a web server, then there are the chances that a very large server can be failed during that process
  • 8.
  • 9. 1. An array is defined as the collection of similar type of data items stored at contiguous memory locations. 2. Arrays are the derived data type in C programming language which can store the primitive type of data such as int, char, double, float, etc. 3. It also has the capability to store the collection of derived data types, such as pointers, structure, etc. 4. The array is the simplest data structure where each data element can be randomly accessed by using its index number. 1. Each element of an array is of same data type and carries the same size, i.e., int = 4 bytes. 2. Elements of the array are stored at contiguous memory locations where the first element is stored at the smallest memory location. 3. Elements of the array can be randomly accessed since we can calculate the address of each element of the array with the given base address and the size of the data element. Properties of Array Introduction
  • 10. Declaration of Array {1-D} :- Data_type array_name[array_size]; Ex. int marks[5];
  • 11. Initialization of C Array 1) One by one or using a single statement :- double balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0}; 2) Size of the array :- double balance[] = {1000.0, 2.0, 3.4, 7.0, 50.0}; Ex. marks[0]=80;//initialization of array marks[1]=60; marks[2]=70; marks[3]=85; marks[4]=75;
  • 12. Two Dimensional Array ( 2-D ):- 1. The two-dimensional array can be defined as an array of arrays. The 2D array is organized as matrices which can be represented as the collection of rows and columns. 2. To declare a two-dimensional integer array of size [x][y]. Declaration of two dimensional Array :- data_type array_name[rows][columns]; Ex. int twodimen[4][3]; int arr[4][3]={{1,2,3},{2,3,4},{3,4,5},{4,5,6}};
  • 14.  A stack is an Abstract Data Type (ADT), commonly used in programming languages. It is named stack as it behaves like a real-world stack, for example – (1) deck of cards (2) pile of plates, etc. stack  A Stack is a linear data structure that follows the LIFO (Last-In-First- Out) principle. This means the last element inserted inside the stack is removed first.  It contains only one pointer top pointer pointing to the topmost element of the stack. Whenever an element is added in the stack, it is added on the top of the stack, and the element can be deleted only from the stack.  In other words, a stack can be defined as a container in which insertion and deletion can be done from the one end known as the top of the stack.
  • 16. Standard Stack Operations 1) push(): When we insert an element in a stack then the operation is known as a push. If the stack is full then the overflow condition occurs. 2) pop(): When we delete an element from the stack, the operation is known as a pop. If the stack is empty this state is known as an underflow state. 3) isEmpty(): It determines whether the stack is empty or not. 4) isFull(): It determines whether the stack is full or not. 5) peek(): Get the value of the top element without removing it 6) count(): It returns the total number of elements available in a stack. 7) change(): It changes the element at the given position. 8) display(): It prints all the elements available in the stack.
  • 17. PUSH operation 1) Before inserting an element in a stack, we check whether the stack is full. 2) If we try to insert the element in a stack, and the stack is full, then overflow condition. 3) When we initialize , we set the value of top as -1 to check that the stack is empty. 4) When the new element is pushed, the value of the top gets incremented, i.e., top=top+1, and the element will be placed at the new position of the top 5) The elements will be inserted until we reach the max size of the stack.
  • 18. POP operation 1) Before deleting the element from the stack, we check whether the stack is empty. 2) If we try to delete the element from the empty stack, then the underflow condition. 3) If the stack is not empty, we first access the element which is pointed by the top 4) Once the pop operation is performed, the top is decremented by 1, i.e., top=top-1.
  • 19. Working of Stack Data Structure
  • 20. Applications of Stack in Data Structure 1. Evaluation of Arithmetic Expressions 1) Infix Notation 2) Prefix Notation 3) Postfix Notation 2. Backtracking 3. Delimiter Checking 4. Reverse a Data 5. Processing Function Calls
  • 21.
  • 22. 1. A queue can be defined as an ordered list which enables insert operations to be performed at one end called REAR and delete operations to be performed at another end called FRONT. 2. Queue is referred to be as First In First Out list. 3. For example, people waiting in line for a rail ticket form a queue. 4. A queue is a linear list of elements Queue
  • 23. Queue Representation Queue is an abstract data structure, similar to Stacks.  Queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue).
  • 24. Basic Operations enqueue() − add (store/insert) an item to the queue. dequeue() − remove an item from the queue. peek() − Gets the element at the front of the queue without removing it. isfull() − Checks if the queue is full. isempty() − Checks if the queue is empty.
  • 25. Enqueue Operation Queues maintain two data pointers, front and rear. Therefore, its operations are comparatively difficult to implement than that of stacks. Step 1 − Check if the queue is full. Step 2 − If the queue is full, produce overflow error and exit. Step 3 − If the queue is not full, increment rear pointer to point the next empty space. Step 4 − Add data element to the queue location, where the rear is pointing. Step 5 − return success.
  • 26.
  • 27. Dequeue Operation Accessing data from the queue is a process of two tasks − 1)access the data where front is pointing 2)remove the data after access. Step 1 − Check if the queue is empty. Step 2 − If the queue is empty, produce underflow error and exit. Step 3 − If the queue is not empty, access the data where front is pointing. Step 4 − Increment front pointer to point to the next available data element. Step 5 − Return success.
  • 28.
  • 29. Types of Queue 1) Linear Queue 2) Circular Queue 1.Linear Queue Data insert at Rear position , if we insert more value then the rear value by +1. Data deletion from front position , if we delete more value then the front value by -1.  
  • 31. Applications of Queue 1. Serving requests on a single shared resource, like a printer, CPU task scheduling etc. 2. In real life scenario, Call Center phone systems uses Queues to hold people calling them in an order, until a service representative is free. 3. Handling of interrupts in real-time systems. The interrupts are handled in the same order as they arrive i.e First come first served