Queue Using Array Questions and Answers
Queue Using Array Questions and Answers
2. In a circular queue, how do you increment the rear end of the queue?
a) rear++
b) (rear+1) % CAPACITY
c) (rear % CAPACITY)+1
d) rear–
View Answer
3. What is the term for inserting into a full queue known as?
a) overflow
b) underflow
c) null pointer exception
d) program won’t be compiled
View Answer
advertisement
https://www.sanfoundry.com/data-structure-questions-answers-queue-array/ 1/11
28/11/2023, 09:27 Queue using Array Questions and Answers - Sanfoundry
a) Dequeue
b) Enqueue
c) Return the front element
d) Return the last element
View Answer
advertisement
https://www.sanfoundry.com/data-structure-questions-answers-queue-array/ 2/11
28/11/2023, 09:27 Queue using Array Questions and Answers - Sanfoundry
7. Which of the following represents a dequeue operation? (count is the number of elements in the
queue)
a)
advertisement
https://www.sanfoundry.com/data-structure-questions-answers-queue-array/ 3/11
28/11/2023, 09:27 Queue using Array Questions and Answers - Sanfoundry
q[front] = null;
front = (front+1)%CAPACITY;
count--;
return ele;
}
}
b)
c)
d)
https://www.sanfoundry.com/data-structure-questions-answers-queue-array/ 4/11
28/11/2023, 09:27 Queue using Array Questions and Answers - Sanfoundry
System.out.println("Queue underflow");
return 0;
}
else
{
Object ele = q[front];
q[front] = null;
front = (front+1)%CAPACITY;
return ele;
count--;
}
}
View Answer
8. Which of the following best describes the growth of a linear queue at runtime? (Q is the original
queue, size() returns the number of elements in the queue)
a)
b)
c)
https://www.sanfoundry.com/data-structure-questions-answers-queue-array/ 5/11
28/11/2023, 09:27 Queue using Array Questions and Answers - Sanfoundry
d)
View Answer
public CircularQueue()
{
this(CAPACITY);
}
public CircularQueue (int n)
{
https://www.sanfoundry.com/data-structure-questions-answers-queue-array/ 6/11
28/11/2023, 09:27 Queue using Array Questions and Answers - Sanfoundry
size = n;
front = 0;
rear = 0;
q = new Object[size];
}
https://www.sanfoundry.com/data-structure-questions-answers-queue-array/ 7/11
28/11/2023, 09:27 Queue using Array Questions and Answers - Sanfoundry
else
{
Object low;
rear = (rear-1)%size;
low = q[rear];
rear = (rear+1)%size;
return low;
}
}
}
public class CircularQueueDemo
{
public static void main(String args[])
{
Object var;
CircularQueue myQ = new CircularQueue();
myQ.enqueue(10);
myQ.enqueue(3);
var = myQ.rearElement();
myQ.dequeue();
myQ.enqueue(6);
var = mQ.frontElement();
System.out.println(var+" "+var);
}
}
a) 3 3
b) 3 6
c) 6 6
d) 10 6
View Answer
To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice Questions and
Answers.
« Prev - Data Structure Questions and Answers » Next - Data Structure Questions and Answers –
– Stack using Linked List Queue using Linked List
Related Posts:
https://www.sanfoundry.com/data-structure-questions-answers-queue-array/ 8/11
28/11/2023, 09:27 Queue using Array Questions and Answers - Sanfoundry
advertisement
Recommended Articles:
1. Data Structure Questions and Answers – Queue using Linked List
2. Data Structure Questions and Answers – Queue Operations
3. Data Structure Questions and Answers – Stack using Array
4. Data Structure Questions and Answers – Queue using Stacks
5. C Program to Implement Queue using Array
6. Java Questions & Answers – Data Structures-Queue
7. Data Structure Questions and Answers – Double Ended Queue (Dequeue)
8. Java Program to Implement Queue
9. Data Structure Questions and Answers – Array and Array Operations
10. C++ Program to Implement Queue using Linked List
advertisement
https://www.sanfoundry.com/data-structure-questions-answers-queue-array/ 9/11
28/11/2023, 09:27 Queue using Array Questions and Answers - Sanfoundry
Additional Resources:
Data Structure MCQ Questions
Data Structures in C
Data Structures in Java
Data Structures in C++
Java Array Programs
Popular Pages:
C# Array Programs
Data Science MCQ Questions
C++ STL
Java Programs on Collections
C++ Algorithm Library
Name
Subscribe
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is
Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on
development of Linux Kernel, SAN Technologies, Advanced C, Data
Structures & Alogrithms. Stay connected with him at LinkedIn.
https://www.sanfoundry.com/data-structure-questions-answers-queue-array/ 11/11