The document discusses queues and their implementation. It defines a queue as a FIFO data structure where new items are added to the rear and removed from the front. Key queue operations are described like add, remove, isEmpty and isFull. The document then provides examples of implementing a queue using arrays and pointers in C++. It includes functions for initialization, insertion, removal, checking if empty, and printing all elements.
The document discusses queues, which are first-in first-out (FIFO) data structures with a front and rear end where insertion occurs at the rear and deletion occurs at the front. It describes queue operations like creation, insertion, deletion, checking for emptiness/fullness. Queues can be implemented using arrays or linked lists. Applications of queues include accessing files from disk systems, CPU scheduling in operating systems, and ticket reservation systems.
The document discusses stacks and queues. It defines stacks as LIFO data structures and queues as FIFO data structures. It describes basic stack operations like push and pop and basic queue operations like enqueue and dequeue. It then discusses implementing stacks and queues using arrays and linked lists, outlining the key operations and memory requirements for each implementation.
The document discusses stacks and their implementation and applications. Stacks are LIFO data structures that can be implemented using arrays. Key operations on stacks include push, pop, peek, isEmpty and isFull. Stacks have various applications including expression evaluation, recursion, function calls and memory management. Stacks can grow either upwards or downwards in the array.
Data Structure Introduction
Data Structure Definition
Data Structure Types
Data Structure Characteristics
Need for Data Structure
Stack Definition
Stack Representation
Stack Operations
Stack Algorithm
Program for Stack in C++
Linked List Definition
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
Linked List Defination
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
This document discusses queues as a data structure. Some key points:
- Queues follow the FIFO (first in, first out) principle and have two main operations - enqueue to insert at the rear, and dequeue to remove from the front.
- Queues can be implemented using arrays or linked lists. Array implementation uses front and rear pointers to track the first and last elements while linked list uses pointers between nodes.
- Common applications of queues include task scheduling, disk I/O handling, media playback lists, call centers, and simulation of waiting lines where the first entry is the first to be served.
The document discusses queues and their implementation. It defines a queue as a FIFO data structure where new items are added to the rear and removed from the front. Key queue operations are described like add, remove, isEmpty and isFull. The document then provides examples of implementing a queue using arrays and pointers in C++. It includes functions for initialization, insertion, removal, checking if empty, and printing all elements.
The document discusses queues, which are first-in first-out (FIFO) data structures with a front and rear end where insertion occurs at the rear and deletion occurs at the front. It describes queue operations like creation, insertion, deletion, checking for emptiness/fullness. Queues can be implemented using arrays or linked lists. Applications of queues include accessing files from disk systems, CPU scheduling in operating systems, and ticket reservation systems.
The document discusses stacks and queues. It defines stacks as LIFO data structures and queues as FIFO data structures. It describes basic stack operations like push and pop and basic queue operations like enqueue and dequeue. It then discusses implementing stacks and queues using arrays and linked lists, outlining the key operations and memory requirements for each implementation.
The document discusses stacks and their implementation and applications. Stacks are LIFO data structures that can be implemented using arrays. Key operations on stacks include push, pop, peek, isEmpty and isFull. Stacks have various applications including expression evaluation, recursion, function calls and memory management. Stacks can grow either upwards or downwards in the array.
Data Structure Introduction
Data Structure Definition
Data Structure Types
Data Structure Characteristics
Need for Data Structure
Stack Definition
Stack Representation
Stack Operations
Stack Algorithm
Program for Stack in C++
Linked List Definition
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
Linked List Defination
Linked List Representation
Linked List Operations
Linked List Algorithm
Program for Linked List in C++
This document discusses queues as a data structure. Some key points:
- Queues follow the FIFO (first in, first out) principle and have two main operations - enqueue to insert at the rear, and dequeue to remove from the front.
- Queues can be implemented using arrays or linked lists. Array implementation uses front and rear pointers to track the first and last elements while linked list uses pointers between nodes.
- Common applications of queues include task scheduling, disk I/O handling, media playback lists, call centers, and simulation of waiting lines where the first entry is the first to be served.
Queue is a linear data structure where elements are inserted at the rear end and deleted from the front end, following FIFO (First In First Out) principle. A queue can be implemented using arrays or linked lists. The document discusses implementation of queues using static arrays and dynamic memory allocation. It also covers insertion and deletion algorithms and provides examples of queue operations using both array-based and linked list-based implementations. Circular queues are introduced as an enhancement over standard queues to avoid overflow in static array implementation.
The document discusses stacks, which are linear data structures that follow the LIFO (last in, first out) principle. Stacks can be implemented using arrays or linked lists. Elements are inserted and removed only from one end, called the top of the stack. Insertion is called pushing and removal is called popping. Stacks are used extensively in computer systems, for example in operating system function calls and interrupt handling. The Java programming language contains a Stack class that can be used by programmers.
The document discusses different implementations of stacks and queues using linked lists and arrays. It describes how stacks can be implemented using a linked list, with push and pop operations adding and removing nodes from the head of the list. Queues can also be implemented with linked lists or arrays, but arrays require additional logic to maintain first-in, first-out order efficiently. Common applications of stacks and queues include evaluating expressions, checking for balanced brackets, and managing tasks in operating systems and server requests.
The document discusses different types of queues including linear queue, circular queue, deque (double ended queue), and priority queue. It defines a queue as a list where items are inserted at the rear and deleted at the front (FIFO). Circular queues overcome limitations of linear queues by making the array circular. A deque supports insertion/deletion from both front and rear. Priority queues process elements based on priority, with higher priority elements processed before lower priority ones. Heaps provide an efficient implementation for priority queues.
This document discusses queues as a data structure. It defines queues as lists that only allow insertions at one end and deletions at the other end, following a First-In First-Out (FIFO) ordering. Common queue operations like add, remove, and peek are introduced. Examples of queues in computer science and real world are provided, like print job queues and lines. Implementations of queues using arrays and linked lists are briefly described.
Using NetBeansImplement a queue named QueueLL using a Linked List .pdfsiennatimbok52331
Using NetBeans
Implement a queue named QueueLL using a Linked List (same as we did for the stack). This
implementation must be used in all the following problems.
Implement a queue QueueST using a stack (use StackLL).
Test your implementations in the main with examples.
Solution
Answer:-
import java.util.*;
/* Class Node */
class Node
{
protected int data;
protected Node link;
/* Constructor */
public Node()
{
link = null;
data = 0;
}
/* Constructor */
public Node(int d,Node n)
{
data = d;
link = n;
}
/* Function to set link to next Node */
public void setLink(Node n)
{
link = n;
}
/* Function to set data to current Node */
public void setData(int d)
{
data = d;
}
/* Function to get link to next node */
public Node getLink()
{
return link;
}
/* Function to get data from current Node */
public int getData()
{
return data;
}
}
/* Class linkedQueue */
class linkedQueue
{
protected Node front, rear;
public int size;
/* Constructor */
public linkedQueue()
{
front = null;
rear = null;
size = 0;
}
/* Function to check if queue is empty */
public boolean isEmpty()
{
return front == null;
}
/* Function to get the size of the queue */
public int getSize()
{
return size;
}
/* Function to insert an element to the queue */
public void insert(int data)
{
Node nptr = new Node(data, null);
if (rear == null)
{
front = nptr;
rear = nptr;
}
else
{
rear.setLink(nptr);
rear = rear.getLink();
}
size++ ;
}
/* Function to remove front element from the queue */
public int remove()
{
if (isEmpty() )
throw new NoSuchElementException(\"Underflow Exception\");
Node ptr = front;
front = ptr.getLink();
if (front == null)
rear = null;
size-- ;
return ptr.getData();
}
/* Function to check the front element of the queue */
public int peek()
{
if (isEmpty() )
throw new NoSuchElementException(\"Underflow Exception\");
return front.getData();
}
/* Function to display the status of the queue */
public void display()
{
System.out.print(\"\ Queue = \");
if (size == 0)
{
System.out.print(\"Empty\ \");
return ;
}
Node ptr = front;
while (ptr != rear.getLink() )
{
System.out.print(ptr.getData()+\" \");
ptr = ptr.getLink();
}
System.out.println();
}
}
/* Class LinkedQueueImplement */
public class LinkedQueueImplement
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
/* Creating object of class linkedQueue */
linkedQueue lq = new linkedQueue();
/* Perform Queue Operations */
System.out.println(\"Linked Queue Test\ \");
char ch;
do
{
System.out.println(\"\ Queue Operations\");
System.out.println(\"1. insert\");
System.out.println(\"2. remove\");
System.out.println(\"3. peek\");
System.out.println(\"4. check empty\");
System.out.println(\"5. size\");
int choice = scan.nextInt();
switch (choice)
{
case 1 :
System.out.println(\"Enter integer element to insert\");
lq.insert( scan.nextInt() );
break;
case 2 :
try
{
System.out.println(\"Removed Element = \"+ lq.remove());
}
catch (Exception e)
{
System.out.println(\"Error : \" + e.getMessage());
}
break;
case 3 .
The document discusses queues as a data structure and their implementation using circular arrays. Queues follow a first-in, first-out (FIFO) ordering, with insertion at the rear of the queue and deletion at the front. A circular array implementation is presented, which uses indices to track the front and rear of the queue, wrapping around to the beginning of the array when the indices reach the end. Sample code demonstrates creating and manipulating queues through functions like enqueue, dequeue, isEmpty and isFull. Common applications of queues include printer jobs, access to shared resources, and call center phone lines.
This document discusses different implementations of stacks and queues using linked lists and arrays. It describes how to implement a stack using a linked list, with push and pop operations adding and removing nodes from the front of the list. Queues are described as first-in first-out data structures, with enqueue adding to the back and dequeue removing from the front. Examples are given of using stacks and queues for applications like balancing parentheses in expressions and evaluating postfix notation.
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueBalwant Gorad
Explain Stack and its Concepts, Its Operations, Queue, Circular Queue, Priority Queue. Explain Queue and It's Operations
Data Structures, Abstract Data Types
A stack is a linear data structure that follows the LIFO (Last In First Out) principle. Elements are added and removed from the top of the stack. Common operations on a stack include push to add an element and pop to remove an element. A stack can be implemented using arrays or pointers in static or dynamic ways respectively. Stacks have applications in reversing words, undo operations, and backtracking in algorithms.
Queue data structures allow for first-in, first-out access to elements. They have two ends - a head for removing elements and a tail for adding elements. Common implementations include arrays, linked lists, and stacks. Priority queues order elements by priority when removing them. Double-ended queues allow adding/removing from either end.
This document discusses binary search trees and provides source code to implement binary search tree traversal operations. It explains that a binary search tree is a binary tree where the left child of a node is less than the parent and the right child is greater. It provides code for preorder, inorder, and postorder traversals of the binary search tree and outputs the traversal order for a sample tree.
This document discusses linear data structures, specifically stacks and queues. It defines a stack as a linear data structure that follows the LIFO principle and can be implemented using arrays or linked lists. Queue is defined as another linear data structure that follows the FIFO principle and supports enqueue and dequeue operations. Various queue implementations like array-based queues, linked list queues, circular queues, and priority queues are described along with their operations. Common applications of stacks and queues in areas like function calls, CPU scheduling, and page replacement algorithms are also mentioned.
Stacks are commonly used data structures that follow the LIFO (last in, first out) principle. They can be implemented using arrays or linked lists. Operations like push add an element to the top of the stack and pop removes an element from the top. Stacks have many applications in computing including implementing function calls, parsing expressions, and undo operations.
A queue is a first-in, first-out (FIFO) data structure where insertion is done at the rear end and deletion is done at the front end. It can be implemented using either an array or linked list. Basic operations on a queue include enqueue, which inserts an item at the rear, and dequeue, which removes an item from the front. A circular queue addresses the issue of empty spaces in a linear queue by connecting the rear end to the front so the queue can migrate in a circular fashion.
Stack and queue are non-primitive data structures that differ in their accessing and adding methods. A stack uses LIFO (last in first out), accessing the last added element first, while a queue uses FIFO (first in first out), accessing the first added element first. A key difference is that a stack has one open end for pushing and popping, while a queue has two open ends for enqueuing and dequeuing. Both data structures are based on real-world equivalents like stacks of CDs and queues for movie tickets.
The document discusses data structures like stacks and queues. It provides examples of implementing a queue using both a linked list and an array. It describes how a queue is a FIFO structure where elements are inserted at the rear and removed from the front. It also discusses some uses of queues, providing a bank simulation as an example where a queue models customers waiting to be served by tellers.
Stack and Queue data structures are described. A Stack follows LIFO (last-in, first-out) where elements can only be inserted and removed from one end. Common stack operations are push, pop, and peek. A Queue follows FIFO (first-in, first-out) where elements can only be inserted at the rear and removed from the front. Common queue operations are enqueue and dequeue. Both can be implemented using arrays or linked lists. A circular array implementation improves the efficiency of dequeuing from a queue.
1. A queue is a first-in, first-out (FIFO) data structure where items are inserted at the rear of the queue and deleted from the front.
2. Queues can be implemented using arrays or linked lists, with operations including enqueue to add an item to the rear, and dequeue to remove an item from the front.
3. Queues have many applications where processing or accessing data in a first-come, first-served order is important, such as in operating systems, communication software, and printing.
The document discusses different types of queues and their implementations. It begins by defining a queue as a first-in first-out (FIFO) data structure where elements are inserted at the rear and deleted from the front. It then covers linear and circular queue implementations using arrays, including operations like insertion, deletion, checking for empty/full, and traversal. Priority queues are also introduced, which process elements based on assigned priorities. The key types and operations of queues as an abstract data type (ADT) are summarized.
Queue is a linear data structure where elements are inserted at the rear end and deleted from the front end, following FIFO (First In First Out) principle. A queue can be implemented using arrays or linked lists. The document discusses implementation of queues using static arrays and dynamic memory allocation. It also covers insertion and deletion algorithms and provides examples of queue operations using both array-based and linked list-based implementations. Circular queues are introduced as an enhancement over standard queues to avoid overflow in static array implementation.
The document discusses stacks, which are linear data structures that follow the LIFO (last in, first out) principle. Stacks can be implemented using arrays or linked lists. Elements are inserted and removed only from one end, called the top of the stack. Insertion is called pushing and removal is called popping. Stacks are used extensively in computer systems, for example in operating system function calls and interrupt handling. The Java programming language contains a Stack class that can be used by programmers.
The document discusses different implementations of stacks and queues using linked lists and arrays. It describes how stacks can be implemented using a linked list, with push and pop operations adding and removing nodes from the head of the list. Queues can also be implemented with linked lists or arrays, but arrays require additional logic to maintain first-in, first-out order efficiently. Common applications of stacks and queues include evaluating expressions, checking for balanced brackets, and managing tasks in operating systems and server requests.
The document discusses different types of queues including linear queue, circular queue, deque (double ended queue), and priority queue. It defines a queue as a list where items are inserted at the rear and deleted at the front (FIFO). Circular queues overcome limitations of linear queues by making the array circular. A deque supports insertion/deletion from both front and rear. Priority queues process elements based on priority, with higher priority elements processed before lower priority ones. Heaps provide an efficient implementation for priority queues.
This document discusses queues as a data structure. It defines queues as lists that only allow insertions at one end and deletions at the other end, following a First-In First-Out (FIFO) ordering. Common queue operations like add, remove, and peek are introduced. Examples of queues in computer science and real world are provided, like print job queues and lines. Implementations of queues using arrays and linked lists are briefly described.
Using NetBeansImplement a queue named QueueLL using a Linked List .pdfsiennatimbok52331
Using NetBeans
Implement a queue named QueueLL using a Linked List (same as we did for the stack). This
implementation must be used in all the following problems.
Implement a queue QueueST using a stack (use StackLL).
Test your implementations in the main with examples.
Solution
Answer:-
import java.util.*;
/* Class Node */
class Node
{
protected int data;
protected Node link;
/* Constructor */
public Node()
{
link = null;
data = 0;
}
/* Constructor */
public Node(int d,Node n)
{
data = d;
link = n;
}
/* Function to set link to next Node */
public void setLink(Node n)
{
link = n;
}
/* Function to set data to current Node */
public void setData(int d)
{
data = d;
}
/* Function to get link to next node */
public Node getLink()
{
return link;
}
/* Function to get data from current Node */
public int getData()
{
return data;
}
}
/* Class linkedQueue */
class linkedQueue
{
protected Node front, rear;
public int size;
/* Constructor */
public linkedQueue()
{
front = null;
rear = null;
size = 0;
}
/* Function to check if queue is empty */
public boolean isEmpty()
{
return front == null;
}
/* Function to get the size of the queue */
public int getSize()
{
return size;
}
/* Function to insert an element to the queue */
public void insert(int data)
{
Node nptr = new Node(data, null);
if (rear == null)
{
front = nptr;
rear = nptr;
}
else
{
rear.setLink(nptr);
rear = rear.getLink();
}
size++ ;
}
/* Function to remove front element from the queue */
public int remove()
{
if (isEmpty() )
throw new NoSuchElementException(\"Underflow Exception\");
Node ptr = front;
front = ptr.getLink();
if (front == null)
rear = null;
size-- ;
return ptr.getData();
}
/* Function to check the front element of the queue */
public int peek()
{
if (isEmpty() )
throw new NoSuchElementException(\"Underflow Exception\");
return front.getData();
}
/* Function to display the status of the queue */
public void display()
{
System.out.print(\"\ Queue = \");
if (size == 0)
{
System.out.print(\"Empty\ \");
return ;
}
Node ptr = front;
while (ptr != rear.getLink() )
{
System.out.print(ptr.getData()+\" \");
ptr = ptr.getLink();
}
System.out.println();
}
}
/* Class LinkedQueueImplement */
public class LinkedQueueImplement
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
/* Creating object of class linkedQueue */
linkedQueue lq = new linkedQueue();
/* Perform Queue Operations */
System.out.println(\"Linked Queue Test\ \");
char ch;
do
{
System.out.println(\"\ Queue Operations\");
System.out.println(\"1. insert\");
System.out.println(\"2. remove\");
System.out.println(\"3. peek\");
System.out.println(\"4. check empty\");
System.out.println(\"5. size\");
int choice = scan.nextInt();
switch (choice)
{
case 1 :
System.out.println(\"Enter integer element to insert\");
lq.insert( scan.nextInt() );
break;
case 2 :
try
{
System.out.println(\"Removed Element = \"+ lq.remove());
}
catch (Exception e)
{
System.out.println(\"Error : \" + e.getMessage());
}
break;
case 3 .
The document discusses queues as a data structure and their implementation using circular arrays. Queues follow a first-in, first-out (FIFO) ordering, with insertion at the rear of the queue and deletion at the front. A circular array implementation is presented, which uses indices to track the front and rear of the queue, wrapping around to the beginning of the array when the indices reach the end. Sample code demonstrates creating and manipulating queues through functions like enqueue, dequeue, isEmpty and isFull. Common applications of queues include printer jobs, access to shared resources, and call center phone lines.
This document discusses different implementations of stacks and queues using linked lists and arrays. It describes how to implement a stack using a linked list, with push and pop operations adding and removing nodes from the front of the list. Queues are described as first-in first-out data structures, with enqueue adding to the back and dequeue removing from the front. Examples are given of using stacks and queues for applications like balancing parentheses in expressions and evaluating postfix notation.
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueBalwant Gorad
Explain Stack and its Concepts, Its Operations, Queue, Circular Queue, Priority Queue. Explain Queue and It's Operations
Data Structures, Abstract Data Types
A stack is a linear data structure that follows the LIFO (Last In First Out) principle. Elements are added and removed from the top of the stack. Common operations on a stack include push to add an element and pop to remove an element. A stack can be implemented using arrays or pointers in static or dynamic ways respectively. Stacks have applications in reversing words, undo operations, and backtracking in algorithms.
Queue data structures allow for first-in, first-out access to elements. They have two ends - a head for removing elements and a tail for adding elements. Common implementations include arrays, linked lists, and stacks. Priority queues order elements by priority when removing them. Double-ended queues allow adding/removing from either end.
This document discusses binary search trees and provides source code to implement binary search tree traversal operations. It explains that a binary search tree is a binary tree where the left child of a node is less than the parent and the right child is greater. It provides code for preorder, inorder, and postorder traversals of the binary search tree and outputs the traversal order for a sample tree.
This document discusses linear data structures, specifically stacks and queues. It defines a stack as a linear data structure that follows the LIFO principle and can be implemented using arrays or linked lists. Queue is defined as another linear data structure that follows the FIFO principle and supports enqueue and dequeue operations. Various queue implementations like array-based queues, linked list queues, circular queues, and priority queues are described along with their operations. Common applications of stacks and queues in areas like function calls, CPU scheduling, and page replacement algorithms are also mentioned.
Stacks are commonly used data structures that follow the LIFO (last in, first out) principle. They can be implemented using arrays or linked lists. Operations like push add an element to the top of the stack and pop removes an element from the top. Stacks have many applications in computing including implementing function calls, parsing expressions, and undo operations.
A queue is a first-in, first-out (FIFO) data structure where insertion is done at the rear end and deletion is done at the front end. It can be implemented using either an array or linked list. Basic operations on a queue include enqueue, which inserts an item at the rear, and dequeue, which removes an item from the front. A circular queue addresses the issue of empty spaces in a linear queue by connecting the rear end to the front so the queue can migrate in a circular fashion.
Stack and queue are non-primitive data structures that differ in their accessing and adding methods. A stack uses LIFO (last in first out), accessing the last added element first, while a queue uses FIFO (first in first out), accessing the first added element first. A key difference is that a stack has one open end for pushing and popping, while a queue has two open ends for enqueuing and dequeuing. Both data structures are based on real-world equivalents like stacks of CDs and queues for movie tickets.
The document discusses data structures like stacks and queues. It provides examples of implementing a queue using both a linked list and an array. It describes how a queue is a FIFO structure where elements are inserted at the rear and removed from the front. It also discusses some uses of queues, providing a bank simulation as an example where a queue models customers waiting to be served by tellers.
Stack and Queue data structures are described. A Stack follows LIFO (last-in, first-out) where elements can only be inserted and removed from one end. Common stack operations are push, pop, and peek. A Queue follows FIFO (first-in, first-out) where elements can only be inserted at the rear and removed from the front. Common queue operations are enqueue and dequeue. Both can be implemented using arrays or linked lists. A circular array implementation improves the efficiency of dequeuing from a queue.
1. A queue is a first-in, first-out (FIFO) data structure where items are inserted at the rear of the queue and deleted from the front.
2. Queues can be implemented using arrays or linked lists, with operations including enqueue to add an item to the rear, and dequeue to remove an item from the front.
3. Queues have many applications where processing or accessing data in a first-come, first-served order is important, such as in operating systems, communication software, and printing.
The document discusses different types of queues and their implementations. It begins by defining a queue as a first-in first-out (FIFO) data structure where elements are inserted at the rear and deleted from the front. It then covers linear and circular queue implementations using arrays, including operations like insertion, deletion, checking for empty/full, and traversal. Priority queues are also introduced, which process elements based on assigned priorities. The key types and operations of queues as an abstract data type (ADT) are summarized.
Similar to Data Structures and Agorithm: DS 09 Queue.pptx (20)
it describes the bony anatomy including the femoral head , acetabulum, labrum . also discusses the capsule , ligaments . muscle that act on the hip joint and the range of motion are outlined. factors affecting hip joint stability and weight transmission through the joint are summarized.
हिंदी वर्णमाला पीपीटी, hindi alphabet PPT presentation, hindi varnamala PPT, Hindi Varnamala pdf, हिंदी स्वर, हिंदी व्यंजन, sikhiye hindi varnmala, dr. mulla adam ali, hindi language and literature, hindi alphabet with drawing, hindi alphabet pdf, hindi varnamala for childrens, hindi language, hindi varnamala practice for kids, https://www.drmullaadamali.com
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxEduSkills OECD
Iván Bornacelly, Policy Analyst at the OECD Centre for Skills, OECD, presents at the webinar 'Tackling job market gaps with a skills-first approach' on 12 June 2024
Communicating effectively and consistently with students can help them feel at ease during their learning experience and provide the instructor with a communication trail to track the course's progress. This workshop will take you through constructing an engaging course container to facilitate effective communication.
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPRAHUL
This Dissertation explores the particular circumstances of Mirzapur, a region located in the
core of India. Mirzapur, with its varied terrains and abundant biodiversity, offers an optimal
environment for investigating the changes in vegetation cover dynamics. Our study utilizes
advanced technologies such as GIS (Geographic Information Systems) and Remote sensing to
analyze the transformations that have taken place over the course of a decade.
The complex relationship between human activities and the environment has been the focus
of extensive research and worry. As the global community grapples with swift urbanization,
population expansion, and economic progress, the effects on natural ecosystems are becoming
more evident. A crucial element of this impact is the alteration of vegetation cover, which plays a
significant role in maintaining the ecological equilibrium of our planet.Land serves as the foundation for all human activities and provides the necessary materials for
these activities. As the most crucial natural resource, its utilization by humans results in different
'Land uses,' which are determined by both human activities and the physical characteristics of the
land.
The utilization of land is impacted by human needs and environmental factors. In countries
like India, rapid population growth and the emphasis on extensive resource exploitation can lead
to significant land degradation, adversely affecting the region's land cover.
Therefore, human intervention has significantly influenced land use patterns over many
centuries, evolving its structure over time and space. In the present era, these changes have
accelerated due to factors such as agriculture and urbanization. Information regarding land use and
cover is essential for various planning and management tasks related to the Earth's surface,
providing crucial environmental data for scientific, resource management, policy purposes, and
diverse human activities.
Accurate understanding of land use and cover is imperative for the development planning
of any area. Consequently, a wide range of professionals, including earth system scientists, land
and water managers, and urban planners, are interested in obtaining data on land use and cover
changes, conversion trends, and other related patterns. The spatial dimensions of land use and
cover support policymakers and scientists in making well-informed decisions, as alterations in
these patterns indicate shifts in economic and social conditions. Monitoring such changes with the
help of Advanced technologies like Remote Sensing and Geographic Information Systems is
crucial for coordinated efforts across different administrative levels. Advanced technologies like
Remote Sensing and Geographic Information Systems
9
Changes in vegetation cover refer to variations in the distribution, composition, and overall
structure of plant communities across different temporal and spatial scales. These changes can
occur natural.
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Data Structures and Agorithm: DS 09 Queue.pptx
1. Data Structure
Lecture No. 9
Queue
Engr. Rashid Farid Chishti
http://youtube.com/rfchishti
http://sites.google.com/site/chishti
International Islamic University H-10, Islamabad, Pakistan
Video Lecture
2. A stack is LIFO (Last-In First Out) structure.
In contrast, a queue is a FIFO (First-In First-Out ) structure.
A queue is a linear structure for which items can be only inserted at one end
and removed at another end.
Queue Operations
Put(X) place X at the rear of the queue.
Get() remove the front element and return it.
Front() return front element without removing it.
Is_Empty() return TRUE if queue is empty, FALSE otherwise
Is_Full() return TRUE if queue is full, FALSE otherwise
Queues
3. Implementing Queue using Array
Index No. 0 1 2 3 Head Tail Count
A Queue -1 -1 0 An empty queue
Put(‘A’) A -1 0 1 Puts ‘A’ in Queue
Put(‘B’) A B -1 1 2 Puts ‘B’ in Queue
Put(‘C’) A B C -1 2 3 Puts ‘C’ in Queue
Put(‘D’) A B C D -1 (3) → -1 4 Puts ‘D’ in Queue
Put(‘E’) A B C D -1 -1 4 Error: Queue is full
Get() B C D 0 -1 3 Gets ‘A’ from Queue
Put(‘F’) F B C D 0 0 4 Puts ‘F’ in Queue
Get() F C D 1 0 3 Gets ‘B’ from Queue
Get() F D 2 0 2 Gets ‘C’ from Queue
Get() F (3) → -1 0 1 Gets ‘D’ from Queue
Get() 0 0 0 Gets ‘F’ from Queue
Get() 0 0 0 Error: Queue is empty
4. #include <iostream>
using namespace std;
typedef char Type;
#define MAX 4
class Queue{
private:
Type qu[MAX];//array of any type
int head; //index of start of queue
int tail; // index of end of queue
int count; // number of items
public:
Queue::Queue();
bool Is_Full();
bool Is_Empty();
void Put(Type var);
Type Get();
Type Front();
void Show();
};
4
Example 1: Implementing Queue using Array
Queue::Queue(){ //constructor
head = -1; tail = -1;
count = 0;
}
bool Queue::Is_Full(){
return count >= MAX-1;
}
bool Queue::Is_Empty(){
return count <= 0;
}
1 2
5. void Queue::Put(Type var){
// insert at tail of Queue
if(count >= MAX)
cout <<"Error: Queue is full n";
else{
qu[++tail] = var;
count++;
}
if(tail >=MAX-1)
// wrap around if past array end
tail = -1;
}
5
Example 1: Implementing Queue using Array
Type Queue::Get(){
// remove item from queue head
if(count <= 0){ // if queue empty
cout <<"Error: Queue is Emptyn";
return -1;
}
Type temp = qu[++head]; //store item
count--;
if(head >= MAX-1){
// wrap around if past array end
head = -1;
}
return temp; //return item
}
3 4
7. Using linked List: Recall
Insert works in constant time for either end of a linked list.
Remove works in constant time only.
Seems best that head of the linked list be the front of the queue so that all
removes will be from the front.
Inserts will be at the end of the list.
Implementing Queue using Linked List
front
2
5
7
1 1 7 5 2
front
rear rear
front
2
5
7 1 7 5 2
front
rear rear
get()
front
2
5
7
9
7 5 2
front
rear
rear
put(9)
9
8. #include <iostream>
using namespace std;
typedef int Type;
struct Node{
Type data ;
Node *next ;
};
class Queue{
private :
Node *front, *rear ;
public :
Queue( ) ;
void Put ( Type Data ) ;
Type Get( ) ;
~Queue( ) ;
};
8
Example 2: Implementing Queue using Linked List
Queue :: Queue( ){
front = rear = NULL ;
}
void Queue :: Put ( Type Data ){
Node *newNode ;
newNode = new Node ;
if ( newNode == NULL )
cout << "nQueue is full" ;
newNode -> data = Data ;
newNode -> next = NULL ;
if ( front == NULL ){
rear = front = newNode ;
return ;
}
rear -> next = newNode ;
rear = rear -> next ;
}
1 2
9. Type Queue :: Get( ){
if ( front == NULL ){
cout << "Queue is empty" ;
return -1;
}
Node *current ;
Type Data ;
Data = front -> data ;
current = front ;
front = front -> next ;
delete current ;
if (front == NULL) rear = NULL;
return Data ;
}
Queue :: ~Queue( ){
if ( front == NULL )
return ;
Node *current ;
while ( front != NULL ){
9
Example 2: Implementing Queue using Linked List
current = front ;
front = front -> next ;
delete current ;
}
}
int main( ){
Queue a ;
a.Put ( 11 ) ;
a.Put ( -8 ) ;
a.Put ( 23 ) ;
a.Put ( 19 ) ;
cout << a.Get( ) << endl;
cout << a.Get( ) << endl;
cout << a.Get( ) << endl;
cout << a.Get( ) << endl;
cout << a.Get( ) << endl;
system("PAUSE");
return 0;
}
3 4
10. The queue data structure is used in various CPU and disk scheduling. Here we
have multiple tasks requiring CPU or disk at the same time. The CPU or disk
time is scheduled for each task using a queue.
The queue can also be used for print spooling wherein the number of print
jobs is placed in a queue.
Handling of interrupts in real-time systems. The interrupts are handled in the
same order as they arrive i.e First come first served.
Breadth-first Search in which the neighboring nodes of a tree are traversed
before moving on to next level uses a queue for implementation.
In real life scenario, Call Center phone systems uses Queues to hold people
calling them in an order, until a service representative is free.
Applications of Queue
11. Double ended queue is a more generalized form of queue data structure
which allows insertion and removal of elements from both the ends, i.e , front
and back.
Double Ended Queue
0 1 2 3 4 5 6
Front Rear
Pop Back
Push Back
Push Front
Pop Front
12. Circular Queue is a linear data structure in which the
operations are performed based on FIFO (First In First Out)
principle and the last position is connected back to the first
position to make a circle. It is also called ‘Ring Buffer’.
Circular Queue
13. In priority queue, data when inserted, is stored based on its priority.
When we remove a data from a priority queue, the data with least priority, will
get removed.
Priority Queue
9 0
Index
Number
7 1
7 2
6 3
5 4
3 5
1 6
Data with the highest priority
Data with the least priority