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

9/11

Page

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

The prefix form of A-B/ (C * D ^ E) is?

Select an option to see the answer and solution.

In case of insertion into a linked queue, a node borrowed from the . . . . . . . . list is inserted in the queue.

Select an option to see the answer and solution.

Linked lists are not suitable for the implementation of . . . . . . . .

Select an option to see the answer and solution.

What is the best case time complexity of deleting a node in a Singly Linked list?

Select an option to see the answer and solution.

How do you calculate the pointer difference in a memory efficient double linked list?

Select an option to see the answer and solution.

What are the advantages of arrays?

Select an option to see the answer and solution.

Given an array of size n, let's assume an element is 'touched' if and only if some operation is performed on it(for example, for performing a pop operation the top element is 'touched'). Now you need to perform Dequeue operation. Each element in the array is touched atleast?

Select an option to see the answer and solution.

Which of the following is not an inherent application of stack?

Select an option to see the answer and solution.

Which of the following real world scenarios would you associate with a stack data structure?

Select an option to see the answer and solution.

In linked list implementation of a queue, the important condition for a queue to be empty is?

Select an option to see the answer and solution.

The following C function takes a single-linked list of integers as a parameter and rearranges the elements of the list. The function is called with the list containing the integers 1, 2, 3, 4, 5, 6, 7 in the given order. What will be the contents of the list after the function completes execution?
struct node 
{
    int value;
    struct node *next;
};
void rearrange(struct node *list)
{
    struct node *p, * q;
    int temp;
    if ((!list) || !list->next) 
      return;
    p = list;
    q = list->next;
    while(q) 
    {
         temp = p->value;
         p->value = q->value;
         q->value = temp;
         p = q->next;
         q = p?p->next:0;
    }
}

Select an option to see the answer and solution.

Consider the following definition in c programming language.
struct node
{
    int data;
    struct node * next;
}
typedef struct node NODE;
NODE *ptr;

Which of the following c code is used to create new node?

Select an option to see the answer and solution.

What does the following function do?
public Object some_func()throws emptyStackException
{
	if(isEmpty())
		throw new emptyStackException("underflow");
	return first.getEle();
}

Select an option to see the answer and solution.

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);
	}
}

Select an option to see the answer and solution.

The postfix form of the expression (A+ B)*(C*D- E)*F / G is?

Select an option to see the answer and solution.

What is the functionality of the following piece of code?
public int function()
{
	Node temp = tail.getPrev();
	tail.setPrev(temp.getPrev());
	temp.getPrev().setNext(tail);
	size--;
	return temp.getItem();
}

Select an option to see the answer and solution.

How do you insert a node at the beginning of the list?

Options are not available for this question.

Select an option to see the answer and solution.

What is the time complexity to count the number of elements in the linked list?

Select an option to see the answer and solution.

Given below is the Node class to perform basic list operations and a Stack class with a no arg constructor.
Select from the options the appropriate pop() operation that can be included in the Stack class. Also 'first' is the top-of-the-stack.
class Node
{
	protected Node next;
	protected Object ele;
	Node()
	{
		this(null,null);
	}
	Node(Object e,Node n)
	{
		ele=e;
		next=n;
	}
	public void setNext(Node n)
	{
		next=n;
	}
	public void setEle(Object e)
	{
		ele=e;
	}
	public Node getNext()
	{
		return next;
	}
	public Object getEle()
	{
		return ele;
	}
}
 
class Stack
{
	Node first;
	int size=0;
	Stack()
	{
		first=null;
	}
}

Options are not available for this question.

Select an option to see the answer and solution.

Process of removing an element from stack is called . . . . . . . .

Select an option to see the answer and solution.