Questions;
What a priority queue is.
How to implement the DEQUEUE, ENQUEUE, IS-EMPTY, and IS-FULL operations for priority queues using max-heaps.
How these algorithms work andtheir run times.
BUILD-MAX-HEAP
HEAP-EXTRACT-MAX
HEAP-INCREASE-KEY
HEAP-MAXIMUM
HEAPSORT
INSERTION-SORT
LEFT
MAX-HEAP-INSERT
MAX-HEAPIFY
PARENT
RIGHT
1. Priority Queue: In this kind of queue each element is assigned a priority . Now elements are processed or deleted according to the priority assigned to them. There are a couple of rules that needs to be followed while working with priority queues -
Rule 1: Element of the higher priority are processed before the elements of lower priority.
Rule 2: Two elements of same priority are processed in the order which they were added to the queue.
There are two types of priority queues : 1. Ascending , 2. Descending
3

2. iii. is empty : here is how it works
This function is used when the stack is empty.
if (size == 0)
stack is empty.
2. iv. is full :
This function checks whether the stack is full or not. It is known that the stack is full or not by checking that the stack top is full or not.
if(stack-top == MAX-1)
stack is full .
3. Well there are a lot of questions in this part so i can answer only as much as time permits . Sorry for any inconvenience caused. I have attached images where I have written down the answers :
Questions; What a priority queue is. How to implement the DEQUEUE, ENQUEUE, IS-EMPTY, and IS-FULL operations...
3. Some circular queue implementations use the mod operator % in enqueue and dequeue operations. Explain why this is inefficient. 4. If a queue is implemented using a singly linked list with a head and tail pointer, you should always insert at the tail and remove from the head. Explain why this is so. 5. What is a Priority Queue, and how does it differ from a standard queue? 6. Priority Queues are almost always implemented with an ordered data...
The tree diagram below depicts a heap being used to implement a
priority queue. Enqueue the value 6 onto the priority queue, then
execute a dequeue. After those two operations have been completed,
what does the underlying array look like? List the elements in the
resulting heap in the order in which they appear in the array, from
left to right.
In class, we discussed the priority queue (PQ) ADT implemented using min-heap. In a min-heap, the element of the heap with the smallest key is the root of the binary tree. On the other hand, a max-heap has as root the element with the biggest key, and the relationship between the keys of a node and its parent is reversed of that of a min-heap. We also discussed an array-based implementation of heaps. In this assignment, your task is to...
Consider the min-priority queue implemented by a binary heap. (The max-priority queue is treated in §6.5 Priority queues in the textbook.) Show the binary tree implemented by the array A = 〈5, 8, 9, 11, 10, 12, 10, 12, 15, 11, 14, 13, 16, 15〉. Show the binary tree resulting from Heap-Insert(A, 6) where A is the array in (a). Show the binary tree resulting from Extract-Min(A) where A is the array in (a). Show the binary tree resulting from...
Suppose we want to implement a circular queue using an array that has an initial capacity (maximum number of elements) MAX. A circular queue is like a regular queue except that elements can be enqueued or dequeued by wrapping around it. Assume we enqueue on the tail and dequeue from the head. An example circular queue with sample operations is shown below: head head tail head tail tail head Enqueue(9) a) Write a program in C that implements this circular...
solving using C. Use a singly linked list to implement a priority queue with two operations: enqueue and dequeue. Each node contains an integer value, a priority, and a pointer to the next node. The priority is a value between 1- 10 (where 10 is the highest priority). When a value is added to the queue, it is added with a value and priority. When a value is removed from the priority queue, the first element with the highest priority...
in C++ please
1- Write the priority queue code – include insertion and remove operations. Given the following values – test your program. Use max-heap. 8, 17, 4, 99, 3, 6, 88, 34, 65 2- Sort the numbers: 8, 17, 4, 99, 3, 6, 88, 34, 65 using heap-sort and show the steps - you may write it on a paper and take a picture and include it here. Show all steps. 3- Write the heap-sort code and test the...
In C++ Implement a queue data structure using two stacks. Remember a queue has enqueue and dequeue functions. You could use either the array or linked list implementation for stacks and queues. Source for stack array: --------------------------------------------------- #include<iostream> #define SIZE 100 #define NO_ELEMENT -999999 using namespace std; class Stack { int arr[SIZE]; // array to store Stack elements int top; public: Stack() { top = -1; } void push(int); // push an element into Stack int pop(); // pop the...
PRIORITY QUEUE USING AVL TREE [ c++ ] Implement a PriorityQueue where we will store the underlying data as an AVL Tree. For each of the fundamental operations of a PriorityQueue, explain briefly how you would implement it with an AVL Tree. If something is a standard AVL tree operation, such as a re-balance, you need only refer to it. The operations are: 1. insertion 2. extractMin() 3.min() 4.extractMax() 5.Max()
(C++) (VISUAL STUDIO) 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. In a normal Queue, we can insert elements until queue becomes full. But once queue becomes full, we cannot insert the next element even if there is a space in front of queue. Efficiently implement a queue class using a circular...