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

5/11

Page

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

Consider the following operation performed on a stack of size 5.
Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
After the completion of all operation, the number of elements present in stack is?

Select an option to see the answer and solution.

The prefix form of an infix expression (p + q) - (r * t) is?

Select an option to see the answer and solution.

What is the functionality of the following code?
public void function(Node node)
{
	if(size == 0)
		head = node;
	else
	{
		Node temp,cur;
		for(cur = head; (temp = cur.getNext())!=null; cur = temp);
		cur.setNext(node);
	}
	size++;
}

Select an option to see the answer and solution.

In Linked List implementation, a node carries information regarding . . . . . . . .

Select an option to see the answer and solution.

What are the disadvantages of arrays?

Select an option to see the answer and solution.

What is the term for inserting into a full queue known as?

Select an option to see the answer and solution.

In linked list implementation of a queue, front and rear pointers are tracked. Which of these pointers will change during an insertion into a NONEMPTY queue?

Select an option to see the answer and solution.

In linked list implementation of a queue, where does a new element be inserted?

Select an option to see the answer and solution.

The following function reverse() is supposed to reverse a singly linked list. There is one line missing at the end of the function.
/* Link list node */
struct node
{
    int data;
    struct node* next;
};
 
/* head_ref is a double pointer which points to head (or start) pointer 
  of linked list */
static void reverse(struct node** head_ref)
{
    struct node* prev   = NULL;
    struct node* current = *head_ref;
    struct node* next;
    while (current != NULL)
    {
        next  = current->next;  
        current->next = prev;   
        prev = current;
        current = next;
    }
    /*ADD A STATEMENT HERE*/
}

What should be added in place of "/*ADD A STATEMENT HERE*/", so that the function correctly reverses a linked list.

Select an option to see the answer and solution.

What is the value of the postfix expression 6 3 2 4 + - *?

Select an option to see the answer and solution.

What is the functionality of the following piece of code?
public void function(Object item)
{
	Node temp=new Node(item,trail);
	if(isEmpty())
	{
		head.setNext(temp);
		temp.setNext(trail);
	}
	else
	{
		Node cur=head.getNext();
		while(cur.getNext()!=trail)
		{
			cur=cur.getNext();
		}
		cur.setNext(temp);
	}
	size++;
}

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

In general, the index of the first element in an array is . . . . . . . .

Select an option to see the answer and solution.

The postfix form of A*B+C/D is?

Select an option to see the answer and solution.

Consider the following doubly linked list: head-1-2-3-4-5-tail. What will be the list after performing the given sequence of operations?
Node temp = new Node(6,head,head.getNext());
Node temp1 = new Node(0,tail.getPrev(),tail);
head.setNext(temp);
temp.getNext().setPrev(temp);
tail.setPrev(temp1);
temp1.getPrev().setNext(temp1);

Select an option to see the answer and solution.

Which of the following is not the application of stack?

Select an option to see the answer and solution.

Which of the following is true about linked list implementation of queue?

Select an option to see the answer and solution.

What is the time complexity of pop() operation when the stack is implemented using an array?

Select an option to see the answer and solution.

What is the time complexity of deleting from the rear end of the dequeue implemented with a singly linked list?

Select an option to see the answer and solution.

The data structure required for Breadth First Traversal on a graph is?

Select an option to see the answer and solution.