Category: Data Structure
-
Define Circular Queue.
Another representation of a queue, which prevents an excessive use of memory by arranging elements/ nodes Q1,Q2,…Qn in a circular fashion. That is, it is the queue, which wraps around upon reaching the end of the queue
-
Define Dequeue.
Deque stands for Double ended queue. It is a linear list in which insertions and deletion are made from either end of the queue structure.
-
Write down the function to insert an element into a queue, in which the queue isimplemented as an array.
Q – Queue X – element to added to the queue Q IsFull(Q)– Checks and true if Queue Q is full Q->Size – Number of elements in the queue Q Q->Rear – Points to last element of the queue Q Q->Array – array used to store queue elements voidenqueue (int X, Queue Q) {if(IsFull(Q)) Error…
-
How do you test for an empty Queue?
The condition for testing an empty queue is rear=front-1. In linked list implementation of queue the condition for an empty queue is the header node link field is NULL.
-
What are the various operations performed on the Queue?
The various operations performed on the queue are CREATE(Q) – Creates Q as an empty Queue. Enqueue(Q,X) – Adds the element X to the Queue. Dequeue(Q) – Deletes a element from the Queue. ISEMTPTY(Q) – returns true if Queue is empty else false. ISFULL(Q) – returns true if Queue is full else false.
-
Define Queue.
A Queue is an ordered list in which all insertions take place at one end called the rear, while all deletions take place at the other end called the front. Rear is initialized to -1 and front is initialized to 0. Queue is also referred as First In First Out (FIFO) list.
-
Explain the usage of stack in recursive algorithm implementation?
In recursive algorithms, stack data structures is used to store the return address when a recursive call is encountered and also to store the values of all the parameters essential to the current state of the function.
-
What are the postfix and prefix forms of the expression?
A+B*(C-D)/(P-R) Postfix form: ABCD-*PR-/+ Prefix form: +A/*B-CD-PR
