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

8/11

Page

Pick an option on a question to see the right 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;
	while(temp.getNext() != head)
		temp = temp.getNext();
	if(temp == head)
	{
		var = head.getItem();
		head = null;
		return var;
	}
	temp.setNext(head.getNext());
	var = head.getItem();
	head = head.getNext();
	return var;
}

Select an option to see the answer and solution.

What does 'stack overflow' refer to?

Select an option to see the answer and solution.

What is the functionality of the following piece of code?
public void fun(int x)
{
	q1.offer(x);
}

Select an option to see the answer and solution.

In a stack, if a user tries to remove an element from an empty stack it is called . . . . . . . .

Select an option to see the answer and solution.

A data structure in which elements can be inserted or deleted at/from both ends but not in the middle is?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What are the applications of dequeue?

Select an option to see the answer and solution.

A linear list of elements in which deletion can be done from one end (front) and insertion can take place only at the other end (rear) is known as . . . . . . . .

Select an option to see the answer and solution.

With what data structure can a priority queue be implemented?

Select an option to see the answer and solution.

When does the ArrayIndexOutOfBoundsException occur?

Select an option to see the answer and solution.

The following C function takes a simply-linked list as an input argument. It modifies the list by moving the last element to the front of the list and returns the modified list. Some part of the code is left blank. Choose the correct alternative to replace the blank line.
typedef struct node 
{
    int value;
    struct node *next;
}Node;
 
Node *move_to_front(Node *head) 
{
    Node *p, *q;
    if ((head == NULL: || (head->next == NULL)) 
    return head;
    q = NULL; p = head;
    while (p-> next !=NULL) 
    {
        q = p;
        p = p->next;
    }
   _______________________________
  return head;
}

Select an option to see the answer and solution.

Which of the following concepts make extensive use of arrays?

Select an option to see the answer and solution.

Elements in an array are accessed . . . . . . . .

Select an option to see the answer and solution.

Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head pointer only. Given the representation, which of the following operation can be implemented in O(1) time?
I. Insertion at the front of the linked list
II. Insertion at the end of the linked list
III. Deletion of the front node of the linked list
IV. Deletion of the last node of the linked list

Select an option to see the answer and solution.

Which of the following array element will return the top-of-the-stack-element for a stack of size N elements(capacity of stack > N)?

Select an option to see the answer and solution.

What is the need for a circular queue?

Select an option to see the answer and solution.

Which of these is not an application of a linked list?

Select an option to see the answer and solution.

Assuming int is of 4bytes, what is the size of int arr[15];?

Select an option to see the answer and solution.

How do you initialize an array in C?

Select an option to see the answer and solution.

Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head node is not given, can we delete the node X from given linked list?

Select an option to see the answer and solution.