1. >GATE CS
  2. >Computer Science and IT Engineering
Found 2  QuestionsSET DEFAULT
Selected Filters
    GATE CS Computer Science and IT Engineering Data Structures
Exams
Years
Subjects
Topics

List of top Computer Science and IT Engineering Questions on Data Structures asked in GATE CS

Consider a stack 𝑆 and a queue 𝑄. Both of them are initially empty and have the
capacity to store ten elements each. The elements 1, 2, 3, 4, and 5 arrive one by one,
in that order. When an element arrives, it is assigned either to 𝑆 (pushed on 𝑆 ) or
to 𝑄 (enqueued to 𝑄). Once all the five elements are stored, the output is generated
in two steps. First, stack S is emptied by popping all elements. Then queue 𝑄 is
emptied by dequeueing all elements. The output obtained by following this process
is 4 3 1 2 5 .
Given the output, the objective is to predict whether an element was assigned to 𝑆
or 𝑄.
Which of the following options is/are possible valid assignment(s) of the
elements?
Note: In the options, the notation 𝑥𝑆 denotes that element 𝑥 was assigned to 𝑆 and
𝑦𝑄 denotes that element 𝑦 was assigned to 𝑄.

  • GATE CS - 2026
  • GATE CS
  • Computer Science and IT Engineering
  • Data Structures

Consider the following code snippet in C language that computes the number of
nodes in a non-empty singly linked list pointed to by the pointer variable head.
struct node{
int elt;
struct node *next;
};
int getListSize (struct node *head)
{
if( E1 ) return 1;
return E2;
}
Which one of the following options gives the correct replacements for the
expressions E1 and E2?

  • GATE CS - 2026
  • GATE CS
  • Computer Science and IT Engineering
  • Data Structures