Queue - Introduction
•Follows FIFO (First In First Out).
• Insert at rear (Enqueue), remove from front (Dequeue).
Explanation: Think of a line at a ticket counter; first person to enter is first to leave.
Queue Representation
3.
Queue - Representation
•Array representation.
• Linked list implementation.
Explanation: Arrays are simple but have fixed size; Linked lists are dynamic.
4.
Queue - Operations
•Enqueue, Dequeue, Peek, isEmpty, isFull.
Explanation: Operations help manage elements efficiently.
5.
Types of Queue
•Simple Queue
• Circular Queue
• Priority Queue
• Deque
Explanation: Different types provide flexibility for various use cases.
6.
Applications of Queue
•CPU scheduling
• Disk scheduling
• Data buffering
• Request handling
Explanation: Queues are used wherever order of processing matters.
7.
Stack - Introduction
•Follows LIFO (Last In First Out).
• Insert and remove from the same end (Top).
Explanation: Think of a stack of plates; last placed is first removed.
Element 3
Element 2
Element 1
8.
Stack - Representation
•Array representation.
• Linked list implementation.
Explanation: Similar to queues, arrays are fixed while linked lists are flexible.
Applications of Stack
•Function calls
• Expression evaluation
• Parsing
• Undo/Redo
• Backtracking
Explanation: Stacks are vital in programming and problem solving.