adplus-dvertising

Welcome to the Stacks and Queues MCQs Page

Dive deep into the fascinating world of Stacks and Queues with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Stacks and Queues, a crucial aspect of Data Structures and Algorithms. In this section, you will encounter a diverse range of MCQs that cover various aspects of Stacks and Queues, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Data Structures and Algorithms.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Stacks and Queues. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Data Structures and Algorithms.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Stacks and Queues. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Stacks and Queues MCQs | Page 18 of 25

Explore more Topics under Data Structures and Algorithms

Q171.
If the elements β€œA”, β€œB”, β€œC” and β€œD” are placed in a queue and are deleted one at a time, in what order will they be removed?
Discuss
Answer: (a).ABCD
Q172.
A data structure in which elements can be inserted or deleted at/from both the ends but not in the middle is?
Discuss
Answer: (c).Dequeue
Q173.
A normal queue, if implemented using an array of size MAX_SIZE, gets full when
Discuss
Answer: (a).Rear = MAX_SIZE – 1
Discuss
Answer: (a).piling up of chairs one above the other
Q175.
What does the following function check for? (all necessary headers to be included and function is called from main)
#define MAX 10
 
   typedef struct stack
   {
        int top;
 int item[MAX];
   }stack;
 
   int function(stack *s)
   {
        if(s->top == -1)
     return 1;
  else return 0;
   }
Discuss
Answer: (c).empty stack
Discuss
Answer: (c).removing items from an empty stack
Q177.
What is the output of the following program?
public class Stack
{
	protected static final int CAPACITY = 100;
	protected int size,top = -1;
	protected Object stk[];
 
	public Stack()
	{
		stk = new Object[CAPACITY];
	}
 
	public void push(Object item)
	{
		if(size_of_stack==size)
		{
			System.out.println("Stack overflow");
				return;
		}
		else
		{
			top++;
			stk[top]=item;
		}
	}
	public Object pop()
	{
		if(top<0)
		{
			return -999;
		}
		else
		{
			Object ele=stk[top];
			top--;
			size_of_stack--;
			return ele;
		}
	}
}
 
public class StackDemo
{
	public static void main(String args[])
	{
		Stack myStack = new Stack();
		myStack.push(10);
		Object element1 = myStack.pop();
		Object element2 = myStack.pop();
		System.out.println(element2);
	}
}
Discuss
Answer: (d).none of the mentioned
Q178.
What is the time complexity of pop() operation when the stack is implemented using an array?
Discuss
Answer: (a).O(1)
Q179.
Which of the following array position will be occupied by a new element being pushed for a stack of size N elements(capacity of stack > N).
Discuss
Answer: (b).S[N].
Q180.
What happens when you pop from an empty stack while implementing using the Stack ADT in Java?
Discuss
Answer: (c).EmptyStackException is thrown

Suggested Topics

Are you eager to expand your knowledge beyond Data Structures and Algorithms? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!