# Data Structure Questions and Answers-Queue using Array

## Data Structure Questions and Answers-Queue using Array

 Question 1 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which of the following properties is associated with a queue?
 A First In Last Out B First In First Out C Last In First Out D None of the mentioned
Question 1 Explanation:
Queue follows First In First Out structure.

 Question 2 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
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-
Question 2 Explanation:
Ensures rear takes the values from 0 to (CAPACITY-1).

 Question 3 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the term for inserting into a full queue known as?
 A overflow B underflow C null pointer exception D all of the mentioned
Question 3 Explanation:
Just as stack, inserting into a full queue is termed overflow.

 Question 4 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the time complexity of enqueue operation?
 A O(logn) B O(nlogn) C O(n) D O(1)
Question 4 Explanation:
Enqueue operation is at the rear end, it takes O(1) time to insert a new item into the queue.

 Question 5 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What does the following piece of code do?

`public Object function() { 	if(isEmpty()) 	return -999; 	else 	{ 		Object high; 		high = q[front]; 		return high; 	} }`
 A Dequeue B Enqueue C Return the front element D None of the mentioned
Question 5 Explanation:
q[front] gives the element at the front of the queue, since we are not moving the 'front' to the next element,

it is not a dequeue operation.

There are 5 questions to complete.