adplus-dvertising

Welcome to the Data Structures and Algorithms MCQs Page

Dive deep into the fascinating world of Data Structures and Algorithms with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Data Structures and Algorithms, a crucial aspect of GATE CSE Exam. In this section, you will encounter a diverse range of MCQs that cover various aspects of Data Structures and Algorithms, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within GATE CSE Exam.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Data Structures and Algorithms. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of GATE CSE Exam.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Data Structures and Algorithms. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Data Structures and Algorithms MCQs | Page 5 of 30

Discuss
Answer: (c).Both of the above
Q42.
Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operation are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are
Discuss
Answer: (a).Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT
Q43.
A Priority-Queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is given below: 10, 8, 5, 3, 2 Two new elements ”1‘ and ”7‘ are inserted in the heap in that order. The level-order traversal of the heap after the insertion of the elements is:
Discuss
Answer: (d).10, 8, 7, 3, 2, 1, 5
Q44.
An implementation of a queue Q, using two stacks S1 and S2, is given below:

void insert(Q, x) {
   push (S1, x);
}
  
void delete(Q){
   if(stack-empty(S2)) then
      if(stack-empty(S1)) then {
          print(“Q is empty”);
          return;
      }
      else while (!(stack-empty(S1))){
          x=pop(S1);
          push(S2,x);
      }
   x=pop(S2);
}

Let n insert and m (<=n) delete operations be performed in an arbitrary order on an empty queue Q. Let x and y be the number of push and pop operations performed respectively in the process. Which one of the following is true for all m and n?
Discuss
Answer: (a).n+m <= x < 2n and 2m <= y <= n+m
Q45.
Consider the following pseudo code. Assume that IntQueue is an integer queue. What does the function fun do?

void fun(int n)
{
IntQueue q = new IntQueue();
q.enqueue(0);
q.enqueue(1);
for (int i = 0; i < n; i++)
{
int a = q.dequeue();
int b = q.dequeue();
q.enqueue(b);
q.enqueue(a + b);
ptint(a);
}
}
Discuss
Answer: (c).Prints first n Fibonacci numbers
Discuss
Answer: (c).A queue can be implemented where ENQUEUE takes a sequence of three instructions and DEQUEUE takes a single instruction
Q47.
A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efficiently. Which one of the following statements is CORRECT (n refers to the number of items in the queue)?
Discuss
Answer: (a).Both operations can be performed in O(1) time
Q48.
Suppose you are given an implementation of a queue of integers. The operations that can be performed on the queue are:

i. isEmpty (Q) — returns true if the queue is empty, false otherwise.
ii. delete (Q) — deletes the element at the front of the queue and returns its value.
iii. insert (Q, i) — inserts the integer i at the rear of the queue.
Consider the following function:

void f (queue Q) {
int i ;
if (!isEmpty(Q)) {
i = delete(Q);
f(Q);
insert(Q, i);
}
}

What operation is performed by the above function f ?
Discuss
Answer: (b).Reverses the order of the elements in the queue Q
Discuss
Answer: (a).An array, each element of which is a pointer to a structure of type node
Q50.
The most appropriate matching for the following pairs

X: m=malloc(5); m= NULL; 1: using dangling pointers
Y: free(n); n->value=5; 2: using uninitialized pointers
Z: char *p; *p = ’a’; 3. lost memory

is:
Discuss
Answer: (d).X—3 ,Y—1, Z---2
Page 5 of 30

Suggested Topics

Are you eager to expand your knowledge beyond Data Structures and Algorithms? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!