Write the program described below.
Show the case
Show answer
Answer
87 past-paper questions on Data structures from ISC Class 12 Computer Science papers (2026-2017), newest first, in full. Questions 1-20 are on this page, 20 to a page. Tap "Show answer" under a question to see its answer. The syllabus covers Stack, Queue, Circular queue, Dequeue, Conversion of Infix to Prefix and Postfix, Single linked list, Binary trees and Tree traversals.
Nothing matches. Try fewer letters.
Write the program described below.
Answer
Answer the following questions from the binary tree.

Answer (a)
Answer (b)
Answer (c)
Answer the following questions from the binary tree.
Answer
Write the program described below.
Answer
void visit(String url)
{
if (top == max - 1)
{
System.out.println("Browser history full");
}
else
{
top++;
pages[top] = url;
}
}
String back()
{
if (top == -1)
{
return "No previous browser history";
}
else
{
String url = pages[top];
top--;
return url;
}
}Write the program described below.
class Word
{
String value;
Word next;
}Write an Algorithm OR a Method to count and display the number of nodes whose value starts with a consonant.
The method declaration is as follows:
void countConsonant(Word first)Answer
void countConsonant(Word first)
{
int count = 0;
Word current = first;
while (current != null)
{
if (current.value != null && current.value.length() > 0)
{
char ch = Character.toUpperCase(current.value.charAt(0));
if (Character.isLetter(ch) && ch != 'A' && ch != 'E' && ch != 'I' && ch != 'O' && ch != 'U')
{
count++;
}
}
current = current.next;
}
System.out.println("Number of nodes starting with a consonant: " + count);
}Explanation: The method traverses the linked list starting from the first node. For each node, it checks if the first character of value is an alphabetic character and not a vowel (A, E, I, O, U). If so, count is incremented. After traversing the list, the count is displayed.Answer the following questions from the binary tree.
Answer
Answer the questions on the class described below.
| Class name | : | CustomerService |
|---|---|---|
| Data members/instance variables: | ||
| services[ ] | : | array to store customer service request |
| size | : | to store the maximum capacity of the array |
| first | : | to store the index of the first customer service request |
| last | : | to store the index of the last customer service request |
| Methods/Member functions: | ||
| CustomerService(int s) | : | constructor to assign size = s, first = 0 and last = 0 |
| void add(int reqst) | : | to insert a request at index last, if space is available, otherwise display “Request cannot be accepted at the moment” |
| int del( ) | : | to remove and return the request at index first, if any, else return -9999 |
Answer (i)
void add(int reqst)
{
if (last == size)
System.out.println("Request cannot be accepted at the moment");
else
{
services[last] = reqst;
last++;
}
}
int del()
{
if (first == last)
return -9999;
else
{
int val = services[first];
first++;
return val;
}
}(Tested (run for real) inside a complete class with size=3: adding a 4th request correctly printed "Request cannot be accepted at the moment", and the four del() calls correctly returned 101, 102, 103, then -9999.)Answer (ii)
Answer the following.
Answer
Write the program described below.
class Node
{
char ch;
Node next;
}
Write an Algorithm OR a Method to count and display the number of upper-case and lower-case characters.
The method declaration is as follows:
void countCase(Node startptr)Answer
void countCase(Node startptr)
{
int upper = 0, lower = 0;
Node p = startptr;
while (p != null)
{
if (Character.isUpperCase(p.ch))
upper++;
else if (Character.isLowerCase(p.ch))
lower++;
p = p.next;
}
System.out.println("Upper-case count: " + upper);
System.out.println("Lower-case count: " + lower);
}Explanation: A pointer p starts at startptr and traverses the linked list node by node until it reaches null (end of list). At each node, Character.isUpperCase()/isLowerCase() checks the character ch and increments the appropriate counter; the counts are displayed once the traversal is complete. Tested (run for real) on the list H-e-L-l-O: output was 'Upper-case count: 3' and 'Lower-case count: 2', which is correct (H, L, O are upper-case; e, l are lower-case).Answer the following questions from the binary tree.
Answer
Convert the following infix expression to prefix form.
Answer
Answer the following questions from the binary tree.
Answer (a)
Official answer keyAnswer (b)
Official answer keyAnswer (c)
Official answer keyChoose the correct option.
Answer
Correct option: c
Write the program described below.
class Cell
{
char m;
Cell right;
}Write an Algorithm OR a Method to print the sum of the ASCII values of the lower case alphabets present in the linked list.
The method declaration is as follows:void lowercase(Cell str)Answer
void lowercase(Cell str)
{
int sum = 0;
Cell temp = str;
while (temp != null)
{
if (temp.m >= 'a' && temp.m <= 'z')
sum = sum + (int) temp.m;
temp = temp.right;
}
System.out.println("Sum of ASCII values of lowercase letters = " + sum);
}The method traverses the linked list from the given node str to the end (right==null), adds the ASCII value of every lower-case character found (checked with the range 'a' to 'z') to sum, and finally prints the total.Answer the following questions from the binary tree.
Answer (a)
Answer (b)
Answer (c)
Choose the correct option.
Answer
Correct option: b
Answer the following on the class described.
Answer (i)
void push(int v)
{
if ((rear + 1) % cap == front)
System.out.println("QUEUE IS FULL");
else
{
Q[rear] = v;
rear = (rear + 1) % cap;
}
}
int remove()
{
if (front == rear)
return -999;
int val = Q[front];
front = (front + 1) % cap;
return val;
}Explanation: push() adds v at the rear index and advances rear circularly (using %cap), but first checks whether the next rear position would collide with front (queue full). remove() checks for an empty queue (front==rear) and returns -999 in that case; otherwise it returns the element at front and advances front circularly. Tested and working correctly for wraparound and full/empty conditions.Answer (ii)
Answer the following on the class described.
Answer (i)
void add(int val)
{
if ((rear + 1) % cap == front)
System.out.println("QUEUE IS FULL");
else
{
q[rear] = val;
rear = (rear + 1) % cap;
}
}
int remove()
{
if (front == rear)
return -999;
int val = q[front];
front = (front + 1) % cap;
return val;
}Explanation: add() checks whether inserting at rear would collide with front (queue full) using modulo arithmetic to wrap around the array; if not full it stores val at q[rear] and advances rear circularly. remove() checks for an empty queue (front==rear) returning -999 in that case; otherwise it returns the element at front and advances front circularly. Tested with cap=4: after add(10),add(20),add(30), remove() correctly returns 10; then add(40) succeeds but a further add(50) correctly prints 'QUEUE IS FULL', and the queue then displays as 20 30 40.Answer (ii)
Answer the following questions from the binary tree.
Answer (a)
Answer (b)
Answer (c)
Answer the following questions.


Answer (a)
Answer (b)
Answer (c)
Data structures is a unit of the ISC Class 12 Computer Science syllabus.
The syllabus lists these topics: Stack, Queue, Circular queue, Dequeue, Conversion of Infix to Prefix and Postfix, Single linked list, Binary trees and Tree traversals.
Prashnika has 87 past-paper questions on Data structures, from papers of 2017-2026, asked in 9 different years. By kind: Binary tree (19), Program (19), Case based (15) and Short answer (13). They carry between 1 and 5 marks, and most are worth 2 marks.
To practise, use the Infix to postfix converter, the Binary tree and BST tool and the paper generator, which can build a practice paper from this chapter.
The syllabus lists Stack, Queue, Circular queue, Dequeue, Conversion of Infix to Prefix and Postfix, Single linked list, Binary trees and Tree traversals.
Prashnika has 87 questions on Data structures, from papers of 2017-2026 (board, specimen, improvement and practice papers together).
By kind: Binary tree (19), Program (19), Case based (15) and Short answer (13).