Enviar búsqueda
Cargar
Ds 3
•
3 recomendaciones
•
691 vistas
Niit Care
Seguir
Tecnología
Educación
Denunciar
Compartir
Denunciar
Compartir
1 de 34
Recomendados
Ds 5
Ds 5
Niit Care
Ds 7
Ds 7
Niit Care
Introduction to Data Structures and Linked List
Introduction to Data Structures and Linked List
Selvaraj Seerangan
C Programming: Structure and Union
C Programming: Structure and Union
Selvaraj Seerangan
Data structure
Data structure
Gaurav Handge
Algo>Abstract data type
Algo>Abstract data type
Ain-ul-Moiz Khawaja
Lesson 1 overview
Lesson 1 overview
MLG College of Learning, Inc
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
Nimmi Weeraddana
Recomendados
Ds 5
Ds 5
Niit Care
Ds 7
Ds 7
Niit Care
Introduction to Data Structures and Linked List
Introduction to Data Structures and Linked List
Selvaraj Seerangan
C Programming: Structure and Union
C Programming: Structure and Union
Selvaraj Seerangan
Data structure
Data structure
Gaurav Handge
Algo>Abstract data type
Algo>Abstract data type
Ain-ul-Moiz Khawaja
Lesson 1 overview
Lesson 1 overview
MLG College of Learning, Inc
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
Nimmi Weeraddana
Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)
St Mary's College,Thrissur,Kerala
Data structure using c++
Data structure using c++
Prof. Dr. K. Adisesha
Abstract Data Types
Abstract Data Types
karthikeyanC40
Tree
Tree
guest917885e
Ds 1
Ds 1
Niit Care
Ds 2
Ds 2
Niit Care
Abstract data types
Abstract data types
Hoang Nguyen
Programming & Data Structure Lecture Notes
Programming & Data Structure Lecture Notes
FellowBuddy.com
Abstract data types
Abstract data types
Poojith Chowdhary
Lesson 2.1 array
Lesson 2.1 array
MLG College of Learning, Inc
Data and File Structure Lecture Notes
Data and File Structure Lecture Notes
FellowBuddy.com
C programming session 07
C programming session 07
Dushmanta Nath
Data structures using C
Data structures using C
Pdr Patnaik
Computing 9691 Test Paper Paper 3 for May / June 2007 Cambridge
Computing 9691 Test Paper Paper 3 for May / June 2007 Cambridge
Alpro
Lecture4a dynamic data_structure
Lecture4a dynamic data_structure
mbadhi barnabas
Lecture1 data structure(introduction)
Lecture1 data structure(introduction)
Taibah University, College of Computer Science & Engineering
i-Eclat: performance enhancement of Eclat via incremental approach in frequen...
i-Eclat: performance enhancement of Eclat via incremental approach in frequen...
TELKOMNIKA JOURNAL
Data Structure
Data Structure
Ibrahim MH
Lecture 2c stacks
Lecture 2c stacks
Victor Palmar
Data Structure - Stacks
Data Structure - Stacks
Brainware University
Advanced data structures slide 2 2+
Advanced data structures slide 2 2+
jomerson remorosa
Datastructure
Datastructure
Griffinder VinHai
Más contenido relacionado
La actualidad más candente
Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)
St Mary's College,Thrissur,Kerala
Data structure using c++
Data structure using c++
Prof. Dr. K. Adisesha
Abstract Data Types
Abstract Data Types
karthikeyanC40
Tree
Tree
guest917885e
Ds 1
Ds 1
Niit Care
Ds 2
Ds 2
Niit Care
Abstract data types
Abstract data types
Hoang Nguyen
Programming & Data Structure Lecture Notes
Programming & Data Structure Lecture Notes
FellowBuddy.com
Abstract data types
Abstract data types
Poojith Chowdhary
Lesson 2.1 array
Lesson 2.1 array
MLG College of Learning, Inc
Data and File Structure Lecture Notes
Data and File Structure Lecture Notes
FellowBuddy.com
C programming session 07
C programming session 07
Dushmanta Nath
Data structures using C
Data structures using C
Pdr Patnaik
Computing 9691 Test Paper Paper 3 for May / June 2007 Cambridge
Computing 9691 Test Paper Paper 3 for May / June 2007 Cambridge
Alpro
Lecture4a dynamic data_structure
Lecture4a dynamic data_structure
mbadhi barnabas
Lecture1 data structure(introduction)
Lecture1 data structure(introduction)
Taibah University, College of Computer Science & Engineering
i-Eclat: performance enhancement of Eclat via incremental approach in frequen...
i-Eclat: performance enhancement of Eclat via incremental approach in frequen...
TELKOMNIKA JOURNAL
Data Structure
Data Structure
Ibrahim MH
La actualidad más candente
(18)
Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)
Data structure using c++
Data structure using c++
Abstract Data Types
Abstract Data Types
Tree
Tree
Ds 1
Ds 1
Ds 2
Ds 2
Abstract data types
Abstract data types
Programming & Data Structure Lecture Notes
Programming & Data Structure Lecture Notes
Abstract data types
Abstract data types
Lesson 2.1 array
Lesson 2.1 array
Data and File Structure Lecture Notes
Data and File Structure Lecture Notes
C programming session 07
C programming session 07
Data structures using C
Data structures using C
Computing 9691 Test Paper Paper 3 for May / June 2007 Cambridge
Computing 9691 Test Paper Paper 3 for May / June 2007 Cambridge
Lecture4a dynamic data_structure
Lecture4a dynamic data_structure
Lecture1 data structure(introduction)
Lecture1 data structure(introduction)
i-Eclat: performance enhancement of Eclat via incremental approach in frequen...
i-Eclat: performance enhancement of Eclat via incremental approach in frequen...
Data Structure
Data Structure
Similar a Ds 3
Lecture 2c stacks
Lecture 2c stacks
Victor Palmar
Data Structure - Stacks
Data Structure - Stacks
Brainware University
Advanced data structures slide 2 2+
Advanced data structures slide 2 2+
jomerson remorosa
Datastructure
Datastructure
Griffinder VinHai
stack 1.pdf
stack 1.pdf
hafsa40
Chapter 6 ds
Chapter 6 ds
Hanif Durad
STACK AND QUEUE CIRCULAR QUEUE PPTS.pptx
STACK AND QUEUE CIRCULAR QUEUE PPTS.pptx
sunitha1792
Data Structures in C
Data Structures in C
Jabs6
CH4.pptx
CH4.pptx
AliJama14
Unit II - LINEAR DATA STRUCTURES
Unit II - LINEAR DATA STRUCTURES
Usha Mahalingam
Ch-8.pdf
Ch-8.pdf
R.K.College of engg & Tech
stack & queue
stack & queue
manju rani
Data Structures and Algorithm - Week 3 - Stacks and Queues
Data Structures and Algorithm - Week 3 - Stacks and Queues
Ferdin Joe John Joseph PhD
Data Structures by Maneesh Boddu
Data Structures by Maneesh Boddu
maneesh boddu
DSA Lab Manual C Scheme.pdf
DSA Lab Manual C Scheme.pdf
Bharati Vidyapeeth COE, Navi Mumbai
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
chandankumar364348
Unit 3 Stacks and Queues.pptx
Unit 3 Stacks and Queues.pptx
Yogesh Pawar
Stack in Sata Structure
Stack in Sata Structure
Muhazzab Chouhadry
Topic 2_revised.pptx
Topic 2_revised.pptx
JAYAPRIYAR7
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
karymadelaneyrenne19
Similar a Ds 3
(20)
Lecture 2c stacks
Lecture 2c stacks
Data Structure - Stacks
Data Structure - Stacks
Advanced data structures slide 2 2+
Advanced data structures slide 2 2+
Datastructure
Datastructure
stack 1.pdf
stack 1.pdf
Chapter 6 ds
Chapter 6 ds
STACK AND QUEUE CIRCULAR QUEUE PPTS.pptx
STACK AND QUEUE CIRCULAR QUEUE PPTS.pptx
Data Structures in C
Data Structures in C
CH4.pptx
CH4.pptx
Unit II - LINEAR DATA STRUCTURES
Unit II - LINEAR DATA STRUCTURES
Ch-8.pdf
Ch-8.pdf
stack & queue
stack & queue
Data Structures and Algorithm - Week 3 - Stacks and Queues
Data Structures and Algorithm - Week 3 - Stacks and Queues
Data Structures by Maneesh Boddu
Data Structures by Maneesh Boddu
DSA Lab Manual C Scheme.pdf
DSA Lab Manual C Scheme.pdf
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
Unit 3 Stacks and Queues.pptx
Unit 3 Stacks and Queues.pptx
Stack in Sata Structure
Stack in Sata Structure
Topic 2_revised.pptx
Topic 2_revised.pptx
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Más de Niit Care
Ajs 1 b
Ajs 1 b
Niit Care
Ajs 4 b
Ajs 4 b
Niit Care
Ajs 4 a
Ajs 4 a
Niit Care
Ajs 4 c
Ajs 4 c
Niit Care
Ajs 3 b
Ajs 3 b
Niit Care
Ajs 3 a
Ajs 3 a
Niit Care
Ajs 3 c
Ajs 3 c
Niit Care
Ajs 2 b
Ajs 2 b
Niit Care
Ajs 2 a
Ajs 2 a
Niit Care
Ajs 2 c
Ajs 2 c
Niit Care
Ajs 1 a
Ajs 1 a
Niit Care
Ajs 1 c
Ajs 1 c
Niit Care
Dacj 4 2-c
Dacj 4 2-c
Niit Care
Dacj 4 2-b
Dacj 4 2-b
Niit Care
Dacj 4 2-a
Dacj 4 2-a
Niit Care
Dacj 4 1-c
Dacj 4 1-c
Niit Care
Dacj 4 1-b
Dacj 4 1-b
Niit Care
Dacj 4 1-a
Dacj 4 1-a
Niit Care
Dacj 1-2 b
Dacj 1-2 b
Niit Care
Dacj 1-3 c
Dacj 1-3 c
Niit Care
Más de Niit Care
(20)
Ajs 1 b
Ajs 1 b
Ajs 4 b
Ajs 4 b
Ajs 4 a
Ajs 4 a
Ajs 4 c
Ajs 4 c
Ajs 3 b
Ajs 3 b
Ajs 3 a
Ajs 3 a
Ajs 3 c
Ajs 3 c
Ajs 2 b
Ajs 2 b
Ajs 2 a
Ajs 2 a
Ajs 2 c
Ajs 2 c
Ajs 1 a
Ajs 1 a
Ajs 1 c
Ajs 1 c
Dacj 4 2-c
Dacj 4 2-c
Dacj 4 2-b
Dacj 4 2-b
Dacj 4 2-a
Dacj 4 2-a
Dacj 4 1-c
Dacj 4 1-c
Dacj 4 1-b
Dacj 4 1-b
Dacj 4 1-a
Dacj 4 1-a
Dacj 1-2 b
Dacj 1-2 b
Dacj 1-3 c
Dacj 1-3 c
Último
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
wesley chun
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Miguel Araújo
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
Khem
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
apidays
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
Zilliz
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
apidays
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Deepika Singh
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Martijn de Jong
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Drew Madelung
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
Zilliz
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
Nanddeep Nachan
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
The Digital Insurer
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
Khushali Kathiriya
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
Rustici Software
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
The Digital Insurer
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
MIND CTI
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
apidays
Último
(20)
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Ds 3
1.
Implementing Stacks and
Queues Using Linked List Objectives In this lesson, you will learn to: Define stacks Identify applications of stacks Implement stacks using linked lists Define queues Identify the two types of queues: Deques Priority queue Implement queues using linked lists Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 1 of 34
2.
Implementing Stacks and
Queues Using Linked List Stacks Are a form of single linked lists in which addition and deletion are performed in the beginning of the list Are also called push-down lists Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 2 of 34
3.
Implementing Stacks and
Queues Using Linked List Stacks (Contd..) Enable the item which is added last to be removed first (Last In First Out i.e. LIFO) TOP PUSH POP DataC DataB DataA Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 3 of 34
4.
Implementing Stacks and
Queues Using Linked List Stacks (Contd..) Example: Function calls stored in a stack PUSH the calling POP out the calling function values function values once addresses when the s u b s tring() the called function function is invoked execution is over m ain() Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 4 of 34
5.
Implementing Stacks and
Queues Using Linked List Stack Operations Operations that can be carried out on stacks are: Addition (PUSH) Removal (POP) Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 5 of 34
6.
Implementing Stacks and
Queues Using Linked List Stack Operations (Contd..) Some Common applications of stacks are: Parameter tracking and passing values with function calls Validating arithmetic expressions Evaluating prefix and postfix notations Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 6 of 34
7.
Implementing Stacks and
Queues Using Linked List Application of Stacks Towers of Hanoi PIN 1 PIN 2 PIN 3 Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 7 of 34
8.
Implementing Stacks and
Queues Using Linked List Application of Stacks The rules applicable to the Towers of Hanoi are as follows: Only one disc at a time should be moved, specifically the topmost disc from any pin A larger disc should never be placed on a smaller disc Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 8 of 34
9.
Implementing Stacks and
Queues Using Linked List Infix Notation The arithmetic expressions that are written with the operator placed between the operands are said to be in Infix Notation Is evaluated using general mathematics rules for operator precedence like: Parenthesis (highest precedence) Exponentiation (second highest precedence) Multiplication and division (third highest precedence) Addition and subtraction (lowest precedence) Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 9 of 34
10.
Implementing Stacks and
Queues Using Linked List Postfix Notation Precedence values or parenthesis are not required to determine the order of operation. 1+2 would be denoted as 12+ The evaluation of an arithmetic expression written in infix is done in two steps: Conversion of an infix expression to a postfix expression Evaluation of the postfix expression Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 10 of 34
11.
Implementing Stacks and
Queues Using Linked List Conversion of an Infix Expression to a Postfix Expression Is done by following the listed steps: 1. Scan the expression from left to right and execute steps 2 to 5 until the stack is empty 2. If the scanned item is an operand, add it to the postfix string, which is the string that will contain the final converted postfix expression 3. If the scanned item is a parenthesis, PUSH it to the stack 4. If the scanned item is an operator, add the current operator to the stack Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 11 of 34
12.
Implementing Stacks and
Queues Using Linked List Conversion of an Infix Expression to a Postfix Expression (Contd..) 5. If a right parenthesis is encountered then, 5.1 POP each operator from the top of the stack until the left parenthesis is encountered 5.2 Remove the left parenthesis from the stack 6. Exit Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 12 of 34
13.
Implementing Stacks and
Queues Using Linked List Evaluation of a Postfix Expression Is done by following the listed steps: 1. Add a ')' to the end of the postfix expression 2. Scan the expression from left to right 3. Repeat steps 4 and 5 4. If an operand is encountered, PUSH every operand encountered to the stack 5. If an operator is encountered, 5.1 POP the top two elements 5.2 Evaluate the expression of the two elements 5.3 PUSH the result to the stack Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 13 of 34
14.
Implementing Stacks and
Queues Using Linked List Evaluation of a Postfix Expression (Contd..) 6. Set RESULT = top of the stack 7. Exit on encountering the ')' value Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 14 of 34
15.
Implementing Stacks and
Queues Using Linked List Implementing Stacks Using linked lists Is preferred because of dynamic allocation of memory Using arrays Is disadvantageous because it requires the size of the array to be pre-defined Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 15 of 34
16.
Implementing Stacks and
Queues Using Linked List Implementing Stacks (Contd..) Example: class Stack { private: //Member data Node *top; public: Stack(); void PUSH(node *); Node *POP(); ~Stack(); }; Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 16 of 34
17.
Implementing Stacks and
Queues Using Linked List Problem Statement 3.D.1 Create an application that implements stack by using single linked list and prints the accepted input in reverse order. Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 17 of 34
18.
Implementing Stacks and
Queues Using Linked List Problem Statement 3.P.1 Create an application that accepts an expression with round brackets and validates it. The application should ensure that the number of opening brackets should be equivalent to the number of closing brackets. Hint: An expression (2+3)*5 can be used to evaluate the given program. Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 18 of 34
19.
Implementing Stacks and
Queues Using Linked List Queues Are sequential lists in which items are inserted into the tail end of the queue and taken from the head Example: Printer queue Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 19 of 34
20.
Implementing Stacks and
Queues Using Linked List Queues (Contd..) Are also called First In First Out (FIFO) lists REAR B C X D G FRONT Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 20 of 34
21.
Implementing Stacks and
Queues Using Linked List Types of Queues Deques Priority queues Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 21 of 34
22.
Implementing Stacks and
Queues Using Linked List Deques Stands for double-ended queues Are queues in which elements can be added or removed from both the ends of the queue Example: FRONT REAR Ann Bob Tim Joe Ken Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 22 of 34
23.
Implementing Stacks and
Queues Using Linked List Deques (Contd..) Are of two types: Input restricted deques Output restricted deques Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 23 of 34
24.
Implementing Stacks and
Queues Using Linked List Priority Queues Are queues which have priority associated with the items added to the queue that determines the order in which the elements are processed and deleted Are used by a time-sharing system Are used by operating system schedulers for scheduling activities to be processed by the microprocessor Are used by simulation applications Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 24 of 34
25.
Implementing Stacks and
Queues Using Linked List Priority Queues (Contd..) In priority queues: An element with a higher priority is processed first If two elements share the same priority, then the element that came in first is processed first Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 25 of 34
26.
Implementing Stacks and
Queues Using Linked List Operations on Queues Primitive operations are: Insertion of nodes Deletion of nodes Additional operations are: Checking if a queue is empty Emptying a queue Counting the number of elements in a queue Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 26 of 34
27.
Implementing Stacks and
Queues Using Linked List Implementing Queues Implementing queues by using arrays is not flexible as an array is of a fixed size Implementing queues by using linked list is flexible as when a new item is added, it is simply linked to the end of the queue. A queue when implemented using linked lists is called a linked queue. Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 27 of 34
28.
Implementing Stacks and
Queues Using Linked List Problem Statement 3.D.2 Create an application that will accept the applicant names as and when they appear for interview. The list of applicants should be updated every hour. Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 28 of 34
29.
Implementing Stacks and
Queues Using Linked List Problem Statement 3.P.2 Create an application that will print the details of the first five early bird prize winners. Hint: The details to be accepted are the name and e-mail id. Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 29 of 34
30.
Implementing Stacks and
Queues Using Linked List Summary In this lesson, you learned that: A stack is a data structure in which operations like adding and removing data are performed from only one end called as TOP Stacks can be used to: Validate arithmetic expressions Evaluate infix and postfix notation Store function arguments and address whenever a function calls another function Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 30 of 34
31.
Implementing Stacks and
Queues Using Linked List Summary (Contd..) The operations that can be carried out on stacks are: Push Pop In computers where rules for precedence do not exist, the evaluation of an arithmetic expression written in infix is done in two steps: Conversion of an infix expression to a postfix expression Evaluation of the postfix expression Stacks can be implemented by using arrays or linked lists Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 31 of 34
32.
Implementing Stacks and
Queues Using Linked List Summary (Contd..) Defining stacks by using linked list is preferred because of dynamic memory allocation A queue is a sequential list where items are inserted into the tail end of the queue and taken from the head The tail is referred to as the REAR element and the head is the FRONT element of a queue, where each element is deleted from the end called FRONT and added at the other end called REAR Queues are called First In First Out (FIFO) lists Queues can be categorized into two types: Deques (pronounced either deck or deQueue) Priority queue Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 32 of 34
33.
Implementing Stacks and
Queues Using Linked List Summary (Contd..) A deques is also called a double-ended queue. In this, elements are added or removed from both ends of the queue The two types of deques are: Output-restricted Input-restricted Often, the items added to a queue have a priority associated with them that determines the order in which the processing and deletion of the each element in the queue happens. Such a kind of queue is called a priority queue Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 33 of 34
34.
Implementing Stacks and
Queues Using Linked List Summary (Contd..) The different applications of queues are: Time-sharing systems Operating system schedulers for scheduling activities to be processed by the microprocessor Simulation applications A queue can be implemented using arrays or linked list A queue when implemented using linked lists is called a linked queue Implementing Stacks and Queues Using Linked ©NIIT List/Lesson 3/Slide 34 of 34