Vidyalelo
Data Structure · all questions

Introduction to Data Structures
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

210

Questions

4/11

Page

Pick an option on a question to see the right answer and solution.

Which of the following is not an advantage of a priority queue?

Select an option to see the answer and solution.

You have two jars, one jar which has 10 rings and the other has none. They are placed one above the other. You want to remove the last ring in the jar. And the second jar is weak and cannot be used to store rings for a long time.

Select an option to see the answer and solution.

The essential condition which is checked before deletion in a linked queue is?

Select an option to see the answer and solution.

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?

Select an option to see the answer and solution.

You are asked to perform a queue operation using a stack. Assume the size of the stack is some value 'n' and there are 'm' number of variables in this stack. The time complexity of performing deQueue operation is (Using only stack operations like push and pop)(Tightly bound).

Select an option to see the answer and solution.

Linked list data structure offers considerable saving in . . . . . . . .

Select an option to see the answer and solution.

Consider these functions:
push() : push an element into the stack
pop() : pop the top-of-the-stack element
top() : returns the item stored in top-of-the-stack-node
What will be the output after performing these sequence of operations.
push(20);
push(4);
top();
pop();
pop();
push(5);
top();

Select an option to see the answer and solution.

What is the space complexity of a linear queue having n elements?

Select an option to see the answer and solution.

What is the functionality of the following piece of code?
public int function(int data)
{
	Node temp = head;
	int var = 0;
	while(temp != null)
	{
		if(temp.getData() == data)
		{
			return var;
		}
		var = var+1;
		temp = temp.getNext();
	}
	return Integer.MIN_VALUE;
}

Select an option to see the answer and solution.

What is the time complexity of enqueue operation?

Select an option to see the answer and solution.

What is the functionality of the following piece of Java code?
Assume: 'a' is a non empty array of integers, the Stack class creates an array of specified size and provides a top pointer indicating TOS(top of stack), push and pop have normal meaning.
public void some_function(int[] a)
{
	Stack S=new Stack(a.length);
	int[] b=new int[a.length];
	for(int i=0;i<a.length;i++)
	{
		S.push(a[i]);
	}
	for(int i=0;i<a.length;i++)
	{
		b[i]=(int)(S.pop());
	}
	System.out.println("output :");
	for(int i=0;i<b.length;i++)
	{
		System.out.println(b[i]);
	}
}

Select an option to see the answer and solution.

Select the code snippet which return true if the stack is empty, false otherwise.

Options are not available for this question.

Select an option to see the answer and solution.

What is the time complexity to insert a node based on key in a priority queue?

Select an option to see the answer and solution.

What happens when you pop from an empty stack while implementing using the Stack ADT in Java?

Select an option to see the answer and solution.

What would be the asymptotic time complexity to add a node at the end of singly linked list, if the pointer is initially pointing to the head of the list?

Select an option to see the answer and solution.

The data structure required to check whether an expression contains a balanced parenthesis is?

Select an option to see the answer and solution.

Which of these best describes an array?

Select an option to see the answer and solution.

Given only a single array of size 10 and no other memory is available. Which of the following operation is not feasible to implement (Given only push and pop operation)?

Select an option to see the answer and solution.

In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is?

Select an option to see the answer and solution.

Which of the following is false about a doubly linked list?

Select an option to see the answer and solution.