GATE CS 2026 (Forenoon) — Question 39

Data StructuresLinked Lists & Binary TreesMCQ2 marks · −2/3 if wrongEasy

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.
c
1struct node{
2    int elt;
3    struct node *next;
4};
5int getListSize (struct node *head)
6{
7    if( E1 ) return 1;
8    return E2;
9}
10
Which one of the following options gives the correct replacements for the expressions E1 and E2?
  1. A
    E1: head == NULL E2: 1 + getListSize(head)
  2. B
    E1: head -> next == NULL E2: 1 + getListSize(head -> next)
  3. C
    E1: head == NULL E2: 1 + getListSize(head -> next)
  4. D
    E1: head -> next == NULL E2: 1 + getListSize(head)
Practise the full 2026-FN paper
Challenge a friend: WhatsApp Telegram
Recommended book · affiliate linkIntroduction to Algorithms (CLRS)The standard reference behind most GATE algorithm questions.
Practise more on Linked Lists & Binary TreesTimed, in the real exam interface · free to start

A GATE question every morning

One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.

Join
Stuck? Ask in the student group