Prashnikaप्रश्निका

Data structures - ISC Class 12 Computer Science Questions with Answers, Page 4

87 past-paper questions on Data structures from ISC Class 12 Computer Science papers (2026-2017), newest first, in full. Questions 61-80 are on this page, 20 to a page. Tap "Show answer" under a question to see its answer.

Practise these questions with filters
2020 · 2 marks · Short answerOpen: Convert the following infix notation to prefix form:

Answer the following in short.

Convert the following infix notation to prefix form: $(X + Y) / (Z * W / V)$
Show answer

Answer

AI
$(X + Y) / (Z * W / V)$ $X + Y \to +XY$ $Z * W / V$ is evaluated left to right: $Z * W \to *ZW$, then divided by $V \to /*ZWV$ Combining with the outer division: $/ + XY / * ZWV$ Prefix form: $/ + X\ Y\ / * Z\ W\ V$
2020 · 1 mark · Binary treeOpen: State the degree of the Nodes E and H.

Answer the following questions from the binary tree.

State the degree of the Nodes E and H.
Show answer

Answer

AI
Degree of a node = number of its children. Node E is a leaf, so its degree is 0. Node H has two children (I and D), so its degree is 2.
2020 · 1 mark · Binary treeOpen: Mention the external nodes of the right subtree.

Answer the following questions from the binary tree.

Mention the external nodes of the right subtree.
Show answer

Answer

AI
The right subtree has root C (C, B, E, J). External nodes (leaf nodes with no children) of the right subtree: E and J.
2020 · 2 marks · Short answerOpen: Convert the following infix notation to postfix notation:

Answer the following in short.

Convert the following infix notation to postfix notation: $A * ( B / C ) / E + F$
Show answer

Answer

AI
$A * (B / C) / E + F$ $B / C \to BC/$ $A * (BC/) \to ABC/*$ $ABC/* \;/\; E \to ABC/*E/$ $ABC/*E/ \;+\; F \to ABC/*E/F+$ Postfix form: $A\ B\ C\ /\ *\ E\ /\ F\ +$
2020 · 2 marks · DifferentiateOpen: Differentiate between Stack data structure and Queue data structure.

Differentiate between the following.

Differentiate between Stack data structure and Queue data structure.
Show answer

Answer

AI
Stack: a linear data structure that works on the LIFO (Last In First Out) principle; insertion (push) and deletion (pop) both take place at one end only, called the top, so the element added last is removed first. Queue: a linear data structure that works on the FIFO (First In First Out) principle; insertion (enqueue) takes place at the rear end and deletion (dequeue) at the front end, so the element added first is removed first.
2019 · 2 marks · DifferentiateOpen: State the difference between internal nodes and external nodes of a binary tree…

Differentiate between the following.

State the difference between internal nodes and external nodes of a binary tree structure.
Show answer

Answer

AI
An internal node of a binary tree is any node that has at least one child, i.e. it is not a leaf - it may have one or two children and lies within the body of the tree. An external node (also called a leaf node) is a node that has no children at all (both its left and right child pointers are null) - it lies at the boundary/end of a branch of the tree.
2019 · 1 mark · Short answerOpen: Name the entity used in the above data structure arrangement.

Answer the following about the data structure described.

Name the entity used in the above data structure arrangement.
Show the case
A linear data structure enables the user to add address from rear end and remove address from front. Define a class Diary with the following details: Class name : Diary Data members / instance variables: Q[ ] : array to store the addresses size : stores the maximum capacity of the array start : to point the index of the front end end : to point the index of the rear end Member functions: Diary (int max) : constructor to initialize the data member size=max, start=0 and end=0 void pushadd(String n) : to add address in the diary from the rear end if possible, otherwise display the message “ NO SPACE” String popadd( ) : removes and returns the address from the front end of the diary if any, else returns “?????” void show( ) : displays all the addresses in the diary
Show answer

Answer

AI
The entity used is a Queue (Linear Queue), which works on the FIFO (First In First Out) principle - the address added first (from the rear) is the first one removed (from the front).
2019 · 4 marks · ProgramOpen: Specify the class Diary giving details of the functions void pushadd(String)…

Answer the following about the data structure described.

Specify the class Diary giving details of the functions void pushadd(String) and String popadd( ). Assume that the other functions have been defined. The main function and algorithm need NOT be written.
Show answer

Answer

AI
void pushadd(String n)
{
    if (end == size)
        System.out.println("NO SPACE");
    else
    {
        Q[end] = n;
        end++;
    }
}

String popadd()
{
    if (start == end)
        return "?????";
    else
    {
        String val = Q[start];
        start++;
        return val;
    }
}
Explanation: pushadd(String) checks whether end has reached size (diary full) before storing the address n at index end and incrementing end; otherwise it prints "NO SPACE". popadd() checks whether the diary is empty (start==end), returning "?????" in that case; otherwise it returns the address at index start and advances start, so addresses always leave from the front in the order they were added. Tested (run for real, capacity 3): after 3 successful pushadd calls a 4th correctly printed "NO SPACE"; popadd() correctly returned the addresses in FIFO order and finally returned "?????" once the diary was emptied.
2019 · 1 mark · Binary treeOpen: Name the siblings of the nodes E and G.

Answer the following questions from the binary tree.

Name the siblings of the nodes E and G.
Show answer

Answer

AI
Sibling of E = B (both are children of the root A). Sibling of G = C (both are children of E).
2019 · 1 mark · Binary treeOpen: State the size of the tree.

Answer the following questions from the binary tree.

State the size of the tree.
Show answer

Answer

AI
Size of the tree (total number of nodes) = 9 (nodes A, E, B, G, C, D, I, H, F).
2019 · 2 marks · Short answerOpen: Convert the following infix notation to postfix form:

Answer the following in short.

Convert the following infix notation to postfix form: $( A + B * C ) - ( E * F / H ) + J$
Show answer

Answer

AI
$(A+B*C) - (E*F/H) + J$ Using operator precedence ($*$, $/$ before $+$, $-$) and left-to-right evaluation, and converting bracket by bracket: $(A+B*C) \to A\ B\ C\ *\ +$ $(E*F/H) \to E\ F\ *\ H\ /$ Combining with $-$ and then $+J$: Postfix: $A\ B\ C\ *\ +\ E\ F\ *\ H\ /\ -\ J\ +$
2019 · 2 marks · ProgramOpen: A linked list is formed from the objects of the class Node. The class structure…

Write the program described below.

A linked list is formed from the objects of the class Node. The class structure of the Node is given below:
class Node
{
    int num;
    Node next;
}
Write an Algorithm OR a Method to find and display the sum of even integers from an existing linked list. The method declaration is as follows: void SumEvenNode( Node str )
Show answer

Answer

AI
Algorithm: Step 1: Start. Set a temporary pointer temp = str (the head of the list) and sum = 0. Step 2: Repeat step 3 while temp is not null. Step 3: If temp.num is even (temp.num % 2 == 0), add it to sum (sum = sum + temp.num). Move temp to temp.next. Step 4: When temp becomes null (end of list reached), display the value of sum. Step 5: Stop. Method:
void SumEvenNode(Node str)
{
    int sum = 0;
    Node temp = str;
    while (temp != null)
    {
        if (temp.num % 2 == 0)
            sum = sum + temp.num;
        temp = temp.next;
    }
    System.out.println("Sum of even integers = " + sum);
}
(Verified by running the code: for a list 3->4->7->10->5, the method correctly printed "Sum of even integers = 14", i.e. 4+10.)
2018 · 4 marks · ProgramOpen: Specify the class Register giving details of the functions void push(String)…

Write the program described below.

Specify the class Register giving details of the functions void push(String) and String pop( ). Assume that the other functions have been defined. The main function and algorithm need NOT be written.
Show answer

Answer

AI
void push(String n)
{
    if (top == cap - 1)
        System.out.println("OVERFLOW");
    else
    {
        top++;
        stud[top] = n;
    }
}

String pop()
{
    if (top == -1)
        return "$$";
    else
    {
        String val = stud[top];
        top--;
        return val;
    }
}
Explanation: push(String) checks whether the register is full (top has reached cap-1); if so it prints "OVERFLOW", otherwise it increments top and stores the new name at that top location. pop() checks whether the register is empty (top == -1), returning "$" in that case; otherwise it returns the name at the current top location and decrements top, so names are always added and removed from the same (topmost) end. Tested (run for real, capacity 3): after 3 successful push calls, a 4th correctly printed "OVERFLOW"; pop() correctly returned the names in LIFO order (ROHIT, SUMIT, AMIT) and finally returned "$" once emptied.
2018 · 1 mark · Short answerOpen: State the height of the tree, if the root is at level 0 (zero).

Answer the following questions from the binary tree.

State the height of the tree, if the root is at level 0 (zero).
Figure for this question
Show answer

Answer

Checked answer.
A is at level 0; E and B at level 1; G, C and D at level 2; H and F at level 3. The deepest nodes are at level 3, so the height of the tree is 3.
2018 · 2 marks · Short answerOpen: A linked list is formed from the objects of the class Node. The class structure…

Answer the following.

A linked list is formed from the objects of the class Node. The class structure of the Node is given below:
class Node
{
    int n;
    Node link;
}
Write an Algorithm OR a Method to search for a number from an existing linked list. The method declaration is as follows: void FindNode( Node str, int b )
Show answer

Answer

AI
Algorithm: Step 1: Start. Set a temporary pointer temp = str (the head of the list). Step 2: Repeat step 3 while temp is not null. Step 3: If temp.n equals b, display "b is found" and stop. Otherwise, move temp to temp.link and repeat from step 2. Step 4: If the loop ends without finding b (temp has become null), display "b is not found". Step 5: Stop. Method:
void FindNode(Node str, int b)
{
    Node temp = str;
    while (temp != null)
    {
        if (temp.n == b)
        {
            System.out.println(b + " is found");
            return;
        }
        temp = temp.link;
    }
    System.out.println(b + " is not found");
}
(Verified by running the code on a 3-node list: correctly reports a middle value as found and a value absent from the list as not found.)
2018 · 2 marks · One wordOpen: Convert the following infix notation to postfix form:

Answer the following.

Convert the following infix notation to postfix form: $A + ( B - C * ( D / E ) * F )$
Show answer

Answer

AI
$A + ( B - C * ( D / E ) * F )$ Converting using the standard operator-precedence (stack-based) algorithm (verified by running the conversion in code): $D/E \to DE/$ $C*(D/E) \to C\,DE/\,* = CDE/*$ $C*(D/E)*F \to CDE/*\,F\,* = CDE/*F*$ $B - [C*(D/E)*F] \to B\,CDE/*F*\,- = BCDE/*F*-$ $A + [B-C*(D/E)*F] \to A\,BCDE/*F*-\,+$ Postfix: $A\;B\;C\;D\;E\;/\;*\;F\;*\;-\;+$
2018 · 1 mark · Short answerOpen: Name the entity used in the above data structure arrangement.

Write the program described below.

Name the entity used in the above data structure arrangement.
Show answer

Answer

AI
The entity used is a Stack, which works on the LIFO (Last In First Out) principle - names are added and removed only from the same end (the top), so the last name pushed in is the first one popped out.

Questions on other pages on Data structures

Other Computer Science chapters