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

7/11

Page

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

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)?

Select an option to see the answer and solution.

Consider you have a stack whose elements in it are as follows.
5 4 3 2 << top
Where the top element is 2.
You need to get the following stack
6 5 4 3 2 << top
The operations that needed to be performed are (You can perform only push and pop):

Select an option to see the answer and solution.

Which data structure is used for implementing recursion?

Select an option to see the answer and solution.

Which of the following data structures can be used for parentheses matching?

Select an option to see the answer and solution.

Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack algorithm to convert the expression from infix to postfix notation. The maximum number of symbols that will appear on the stack AT ONE TIME during the conversion of this expression?

Select an option to see the answer and solution.

A Double-ended queue supports operations such as adding and removing items from both the sides of the queue. They support four operations like addFront(adding item to top of the queue), addRear(adding item to the bottom of the queue), removeFront(removing item from the top of the queue) and removeRear(removing item from the bottom of the queue). You are given only stacks to implement this data structure. You can implement only push and pop operations. What are the total number of stacks required for this operation?(you can reuse the stack)

Select an option to see the answer and solution.

What is the functionality of the following piece of code?
public void display() 
{
	if(size == 0)
		System.out.println("underflow");
	else
	{
		Node current = first;
		while(current != null)
		{
			System.out.println(current.getEle());
			current = current.getNext();
		}
	}
}

Select an option to see the answer and solution.

What is the output of the following Java code?
public class array
{
	public static void main(String args[])
	{
		int []arr = {1,2,3,4,5};
		System.out.println(arr[5]);
	}
}

Select an option to see the answer and solution.

You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list?

Select an option to see the answer and solution.

Which of the following points is/are not true about Linked List data structure when it is compared with an array?

Select an option to see the answer and solution.

Which of the following application makes use of a circular linked list?

Select an option to see the answer and solution.

To implement a stack using queue(with only enqueue and dequeue operations), how many queues will you need?

Select an option to see the answer and solution.

Which data structure is needed to convert infix notation to postfix notation?

Select an option to see the answer and solution.

What is the functionality of the following code? Choose the most appropriate answer.
public int function()
{
	if(head == null)
		return Integer.MIN_VALUE;
	int var;
	Node temp = head;
	Node cur;
	while(temp.getNext() != head)
	{
		cur = temp;
		temp = temp.getNext();
	}
	if(temp == head)
	{
		var = head.getItem();
		head = null;
		return var;
	}
	var = temp.getItem();
	cur.setNext(head);
	return var;
}

Select an option to see the answer and solution.

What does the following function do for a given Linked List with first node as head?
void fun1(struct node* head)
{
    if(head == NULL)
    return;
    fun1(head->next);
    printf("%d  ", head->data);
}

Select an option to see the answer and solution.

A normal queue, if implemented using an array of size MAX_SIZE, gets full when?

Select an option to see the answer and solution.

Process of inserting an element in stack is called . . . . . . . .

Select an option to see the answer and solution.

Convert the following Infix expression to Postfix form using a stack.
x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression is legal.

Select an option to see the answer and solution.

After performing these set of operations, what does the final list look contain?
InsertFront(10);
InsertFront(20);
InsertRear(30);
DeleteFront();
InsertRear(40);
InsertRear(10);
DeleteRear();
InsertRear(15);
display();

Select an option to see the answer and solution.

Circular Queue is also known as . . . . . . . .

Select an option to see the answer and solution.