Prashnikaप्रश्निका
Code
About
Computer ScienceSpecimenClass 12

ISC Computer Science 2020 Specimen Paper with Answers

The ISC Computer Science 2020 Specimen Paper for Class 12: all 30 questions, 70 marks in all, in printed order and in full. It is free to download: tap "Show answer" under a question to see its answer, or use the download button to save the questions as a PDF, with or without answers; "Print this paper" below prints it as it was set.

30questions
70marks
8chapters
Q1(a)1 mark · Short answerOpen: State Associative law and prove it with the help of a truth table.

Answer the following in short.

State Associative law and prove it with the help of a truth table.
Show answer

Answer

Associative law: the way in which the variables are grouped in an OR (or AND) operation does not change the result. $A + (B + C) = (A + B) + C$ and $A \cdot (B \cdot C) = (A \cdot B) \cdot C$ Truth table proof:
ABCB+CA+(B+C)A+B(A+B)+CB.CA.(B.C)A.B(A.B).C
00000000000
00111010000
01011110000
01111111000
10001110000
10111110000
11011110010
11111111111
The columns for $A+(B+C)$ and $(A+B)+C$ are identical, and so are the columns for $A.(B.C)$ and $(A.B).C$, so the Associative law is proved.
Q1(b)1 mark · Truth tableOpen: Draw the truth table to prove the proportional logic expression: (X ⇒ Y) ∧ (Y ⇒…

Answer the following using a truth table.

Draw the truth table to prove the proportional logic expression: $(X \Rightarrow Y) \land (Y \Rightarrow X) = X \Leftrightarrow Y$
Show answer

Answer

XYX => YY => X(X => Y) * (Y => X)X <=> Y
001111
011000
100100
111111
The columns $(X \Rightarrow Y) \land (Y \Rightarrow X)$ and $X \Leftrightarrow Y$ are identical in every row, hence proved.
Q1(c)1 mark · Short answerOpen: Find the dual for the Boolean equation: AB' + BC' + 1 = 1.

Answer the following in short.

Find the dual for the Boolean equation: $AB' + BC' + 1 = 1$.
Show answer

Answer

To get the dual, interchange $+$ with $\cdot$ and $0$ with $1$; the variables and their complements stay unchanged. Given: $AB' + BC' + 1 = 1$ Dual: $(A + B') \cdot (B + C') \cdot 0 = 0$
Q1(d)1 mark · Short answerOpen: Convert the Boolean expression F(X,Y,Z) = X'Y'Z + X'YZ' + XYZ into its cardinal…

Answer the following in short.

Convert the Boolean expression $F(X,Y,Z) = X'Y'Z + X'YZ' + XYZ$ into its cardinal form.
Show answer

Answer

$F(X,Y,Z) = X'Y'Z + X'YZ' + XYZ$ Each term contains all three variables, so it is a minterm: $X'Y'Z = 001 = m_1$, $X'YZ' = 010 = m_2$, $XYZ = 111 = m_7$. Cardinal form: $F(X,Y,Z) = \Sigma(1, 2, 7)$ (verified with the boolean tool). Equivalently, in maxterm form: $F(X,Y,Z) = \pi(0, 3, 4, 5, 6)$.
Q1(e)1 mark · Short answerOpen: Minimize: F = XY + (XZ)' + XY'Z using Boolean laws.

Answer the following in short.

Minimize: $F = XY + (XZ)' + XY'Z$ using Boolean laws.
Show answer

Answer

$F = XY + (XZ)' + XY'Z$ $= XY + X' + Z' + XY'Z$ (De Morgan's law on $(XZ)'$) $= (X' + XY) + Z' + XY'Z$ (regrouping) $= X' + Y + Z' + XY'Z$ (using $A + A'B = A + B$, i.e. $X' + XY = X' + Y$) $= X' + Y + Z' + Y'Z$ (using $X' + XY'Z = X' + Y'Z$) $= X' + Y + Z' + Z$ (using $Y + Y'Z = Y + Z$) $= X' + Y + 1$ (complement law $Z + Z' = 1$) $= 1$ (null law) So $F = 1$ (verified with the boolean tool: the expression is a tautology).
Q2(a)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

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.
Q2(c)2 marks · Short answerOpen: Define Interface. How is it different from a Class?

Answer the following in short.

Define Interface. How is it different from a Class?
Show answer

Answer

Interface: an interface in Java is a reference type that contains only abstract method declarations (no method bodies) and constants (public static final data members). It specifies what a class must do; a class uses the keyword implements and must define all its methods. Difference from a class: a class contains data members and complete method definitions and objects can be created from it with new, whereas an interface has no instance variables, no method bodies and cannot be instantiated. A class can extend only one super class, but it can implement many interfaces, so interfaces give a form of multiple inheritance.
Q2(d)2 marks · NumericalOpen: Each element of an array arr[15][20] requires 'W' bytes of storage. If the…

Solve the following.

Each element of an array $arr[15][20]$ requires '$W$' bytes of storage. If the address of $arr[6][8]$ is 4440 and the Base Address at $arr[1][1]$ is 4000, find the width '$W$' of each cell in the array $arr[ ][ ]$ when the array is stored as Column Major Wise.
Show answer

Answer

Column major formula: Address of $arr[I][J] = BA + W \times [(J - L_c) \times M + (I - L_r)]$ Given: number of rows $M = 15$, $BA = 4000$ at $arr[1][1]$ so $L_r = 1$, $L_c = 1$; $I = 6$, $J = 8$; address of $arr[6][8] = 4440$. $4440 = 4000 + W \times [(8 - 1) \times 15 + (6 - 1)]$ $4440 = 4000 + W \times [105 + 5]$ $440 = 110 \times W$ $W = 440 / 110 = 4$ bytes

Final answer: 4 bytes

Q2(e)2 marks · Short answerOpen: Define Big ‘O’ notation. State the two factors which determine the complexity…

Answer the following in short.

Define Big ‘O’ notation. State the two factors which determine the complexity of an algorithm.
Show answer

Answer

Big 'O' notation is a mathematical notation that describes the limiting behaviour of an algorithm: it gives the upper bound on the growth of the running time (or memory) of the algorithm as a function of the input size $n$ (the worst case), ignoring constants and lower-order terms. The two factors that determine the complexity of an algorithm are: 1. Time complexity: the amount of time (number of basic operations) the algorithm takes, as a function of the input size. 2. Space complexity: the amount of memory the algorithm needs, as a function of the input size.
Q35 marks · OutputOpen: The following is a function of some class. What will be the output of the…

What is the output of the following code?

The following is a function of some class. What will be the output of the function test ( ) when the value of count is equal to 4 ? Show the dry run / working.
void test (int count)
{
    if (count == 0)
        System.out.println(" ");
    else
    {
        System.out.println("Bye" + count);
        test(--count);
        System.out.println(" " + count);
    }
}
Show answer

Answer

Dry run for test(4) (count is reduced by --count before the recursive call, so the line printed after the call shows the reduced value): test(4): count is not 0, prints Bye4, then count becomes 3 and test(3) is called test(3): prints Bye3, count becomes 2, calls test(2) test(2): prints Bye2, count becomes 1, calls test(1) test(1): prints Bye1, count becomes 0, calls test(0) test(0): count == 0, prints a blank line (a space) and returns Back in test(1): prints " 0" Back in test(2): prints " 1" Back in test(3): prints " 2" Back in test(4): prints " 3" Output: Bye4 Bye3 Bye2 Bye1 (blank line) 0 1 2 3 (verified by running the code)
Q4(a)(i)4 marks · K-mapOpen: Reduce the above expression by using 4-variable Karnaugh map, showing the…

Answer the following for the given Boolean function.

Reduce the above expression by using 4-variable Karnaugh map, showing the various groups (i.e. octal, quads and pairs).
Show the case
Given the Boolean function $F(A, B, C, D) = \Sigma (0, 2, 3, 6, 8, 10, 11, 14, 15)$:
Show answer

Answer

Groups: (10, 11, 14, 15) → AC; (2, 3, 10, 11) → B'C; (0, 2, 8, 10) → B'D'; (2, 6, 10, 14) → CD'

Reduced expression: F = AC + B'C + B'D' + CD'

Four quads: {10,11,14,15} = AC, {2,3,10,11} = B'C, {0,2,8,10} = B'D', {2,6,10,14} = CD'.
Q4(a)(ii)1 mark · DrawingOpen: Draw the logic gate diagram for the reduced expression. Assume that the…

Answer the following for the given Boolean function.

Draw the logic gate diagram for the reduced expression. Assume that the variables and their complements are available as inputs.

Draw: Logic gate diagram for the reduced expression

Show answer

Answer

Logic gate diagram for $F = AC + B'C + B'D' + CD'$: four 2-input AND gates with inputs (A, C), (B', C), (B', D') and (C, D') feed one 4-input OR gate whose output is F. The complemented inputs B' and D' are taken directly as inputs.
Diagram for this answer
Q4(b)(i)4 marks · K-mapOpen: Reduce the above expression by using 4-variable Karnaugh map, showing the…

Answer the following for the given Boolean function.

Reduce the above expression by using 4-variable Karnaugh map, showing the various groups (i.e. octal, quads and pairs).
Show the case
Given the Boolean function $F(P, Q, R, S) = \pi (5, 7, 8, 10, 12, 14, 15)$:
Show answer

Answer

Groups: (8, 10, 12, 14) → (P' + S); (5, 7) → (P + Q' + S'); (7, 15) → (Q' + R' + S')

Reduced expression: F = (P' + S)(P + Q' + S')(Q' + R' + S')

Quad {8,10,12,14} = (P' + S); pairs {5,7} = (P + Q' + S') and {7,15} = (Q' + R' + S').
Q4(b)(ii)1 mark · DrawingOpen: Draw the logic gate diagram for the reduced expression. Assume that the…

Answer the following for the given Boolean function.

Draw the logic gate diagram for the reduced expression. Assume that the variables and their complements are available as inputs.

Draw: Logic gate diagram for the reduced expression

Show answer

Answer

Logic gate diagram for $F = (P' + S)(P + Q' + S')(Q' + R' + S')$: one 2-input OR gate with inputs (P', S) and two 3-input OR gates with inputs (P, Q', S') and (Q', R', S') feed a 3-input AND gate whose output is F. The complemented inputs P', Q', R', S' are taken directly as inputs.
Diagram for this answer
Q5(a)5 marks · DrawingOpen: Draw the logic diagram and truth table to encode the decimal numbers (2, 3, 5…

Draw the following.

Draw the logic diagram and truth table to encode the decimal numbers (2, 3, 5, 7, 8) and briefly explain its working.

Draw: Logic diagram and truth table of an encoder for the decimal numbers 2, 3, 5, 7, 8

Show answer

Answer

Encoder for the decimal digits 2, 3, 5, 7 and 8: it has 5 input lines $D_2, D_3, D_5, D_7, D_8$ (only one is 1 at a time, when that digit is pressed) and 4 output lines $W X Y Z$ that give its BCD (8-4-2-1) code. Truth table:
DigitD2D3D5D7D8WXYZ
2100000010
3010000011
5001000101
7000100111
8000011000
From the table: $W = D_8$ (the $D_8$ line is taken directly as W), $X = D_5 + D_7$, $Y = D_2 + D_3 + D_7$, $Z = D_3 + D_5 + D_7$. So X is a 2-input OR gate and Y and Z are 3-input OR gates. Working: when a digit key is pressed, only its input line becomes 1 and it feeds those OR gates whose equation contains it. For example, pressing 7 makes $D_7 = 1$, which feeds X, Y and Z, so $WXYZ = 0111$, the BCD of 7. Pressing 8 makes $D_8 = 1$, which gives $W = 1$ and all other outputs 0, i.e. 1000.
Diagram for this answer
Q5(b)3 marks · DrawingOpen: Simplify the following Boolean expression and draw the gate for the reduced…

Simplify the expression and draw its circuit.

Simplify the following Boolean expression and draw the gate for the reduced expression: $F = A'B + AB'C + A$

Draw: Gate for the reduced expression

Show answer

Answer

$F = A'B + AB'C + A$ $= A + A'B + AB'C$ (rearranging) $= (A + B) + AB'C$ (using $A + A'B = A + B$) $= A + B$ (absorption law, since $A + AB'C = A$) Reduced expression: $F = A + B$ (verified with the boolean tool). Gate for the reduced expression: a single 2-input OR gate with inputs A and B, whose output is F.
Diagram for this answer
Q5(c)2 marks · Short answerOpen: Define Universal gates. Give one example and show how it works as an OR gate.

Answer the following in short.

Define Universal gates. Give one example and show how it works as an OR gate.
Show answer

Answer

Universal gate: a gate from which any other gate (AND, OR, NOT, etc.) and hence any logic circuit can be built. NAND and NOR are the universal gates. Example: NAND gate as an OR gate. Using De Morgan's law, $A + B = ((A + B)')' = (A' \cdot B')'$, which is the NAND of $A'$ and $B'$. Connections: a NAND gate with both inputs joined to A gives $A'$ (NOT); another with both inputs joined to B gives $B'$; the outputs $A'$ and $B'$ feed a third NAND gate whose output is $(A' \cdot B')' = A + B$. So three NAND gates work as a two input OR gate.
Q6(a)5 marks · Truth tableOpen: Draw a truth table with a 3 input combination which outputs 1 if there are odd…

Answer the following using a truth table.

Draw a truth table with a 3 input combination which outputs 1 if there are odd number of 0’s. Also derive an SOP expression for the output. Reduce the expression using Karnaugh Map.
Show answer

Answer

ABCF
0001
0010
0100
0111
1000
1011
1101
1110

SOP: A'B'C' + A'BC + AB'C + ABC'

F = Σ(0,3,5,6) = A'B'C' + A'BC + AB'C + ABC'. On the K-map no two 1s are adjacent, so there is no pair, quad or octet and the expression cannot be reduced further. Reduced SOP: F = A'B'C' + A'BC + AB'C + ABC'.
Q6(b)3 marks · Short answerOpen: Define Proposition. How does tautology differ from contradiction?

Answer the following in short.

Define Proposition. How does tautology differ from contradiction?
Show answer

Answer

A proposition is a declarative statement that is either true or false but not both, e.g. 'The Sun rises in the east'. Tautology: a compound proposition that is always true, i.e. its truth table has 1 (True) in every row of the result column, e.g. $P \lor \sim P$. Contradiction: a compound proposition that is always false, i.e. its truth table has 0 (False) in every row of the result column, e.g. $P \land \sim P$. (A proposition that is sometimes true and sometimes false is called a contingency.)
Q6(c)2 marks · DrawingOpen: Draw the logic diagram of 4:1 Multiplexer.

Draw the following.

Draw the logic diagram of 4:1 Multiplexer.

Draw: Logic diagram of a 4:1 multiplexer

Show answer

Answer

4:1 Multiplexer: it has 4 data inputs $I_0$ to $I_3$, 2 select lines $S_1 S_0$ and one output Y. The select lines choose which data input is passed to the output. $Y = S_1'S_0'I_0 + S_1'S_0I_1 + S_1S_0'I_2 + S_1S_0I_3$ Circuit: four 3-input AND gates, each taking one data input and one combination of the select lines (or their complements), feed one 4-input OR gate whose output is Y. For example, when $S_1S_0 = 10$ only the third AND gate is enabled and $Y = I_2$.
Diagram for this answer
Q710 marks · ProgramOpen: A class Composite contains a two dimensional array of order [m x n]. The…

Write the program described below.

A class Composite contains a two dimensional array of order [m x n]. The maximum value possible for both ‘m’ and ‘n’ is 20. Design a class Composite to fill the array with the first (m x n) composite numbers in column wise. The details of the members of the class are given below: Class name : Composite Data members/instance variables: arr[ ] [ ] : stores the composite numbers column wise m : integer to store the number of rows n : integer to store the number of columns Member functions/methods: Composite(int mm, int nn) : to initialize the size of the matrix m=mm and n=nn int isComposite(int p) : returns 1 if number is composite otherwise returns 0 void fill() : to fill the elements of the array with the first (m × n) composite numbers in column wise void display() : displays the array in a matrix form Specify the class Composite giving details of the constructor(int,int), int isComposite(int), void fill() and void display(). Define a main() function to create an object and call the functions accordingly to enable the task.
Show answer

Answer

import java.util.Scanner;

class Composite
{
    int arr[][];
    int m, n;

    Composite(int mm, int nn)
    {
        m = mm;
        n = nn;
        arr = new int[m][n];
    }

    int isComposite(int p)
    {
        if (p < 4)
            return 0;
        for (int i = 2; i <= p / 2; i++)
        {
            if (p % i == 0)
                return 1;
        }
        return 0;
    }

    void fill()
    {
        int num = 3;
        for (int j = 0; j < n; j++)
        {
            for (int i = 0; i < m; i++)
            {
                num++;
                while (isComposite(num) == 0)
                    num++;
                arr[i][j] = num;
            }
        }
    }

    void display()
    {
        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < n; j++)
                System.out.print(arr[i][j] + "\t");
            System.out.println();
        }
    }

    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter the number of rows (max 20): ");
        int r = sc.nextInt();
        System.out.print("Enter the number of columns (max 20): ");
        int c = sc.nextInt();
        Composite ob = new Composite(r, c);
        ob.fill();
        ob.display();
    }
}
Explanation: The constructor stores the order of the matrix and creates the array. isComposite(p) returns 1 if p (4 or more) has a divisor between 2 and p/2, i.e. it has more than two factors, else 0. fill() goes through the array column by column (outer loop over columns, inner loop over rows) and stores the next composite number each time, searching upward from 4. display() prints the array in matrix form. Tested: for 3 rows and 4 columns the output is 4 9 14 18 6 10 15 20 8 12 16 21 which holds the first 12 composite numbers filled column-wise.
Q810 marks · ProgramOpen: Design a class Sort which enables a word to be arranged in alphabetical order…

Write the program described below.

Design a class Sort which enables a word to be arranged in alphabetical order. The details of the members of the class are given below: Class name : Sort Data members/instance variables: str : stores a word len : to store the length of the word Methods/Member functions: Sort() : default constructor void readword() : to accept the word void arrange() : to arrange the word in alphabetical order using any standard sorting technique. void display() : displays the original word along with the sorted word Specify the class Sort giving details of the constructor, void readword(), void arrange() and void display(). Define the main() function to create an object and call the functions accordingly to enable the task.
Show answer

Answer

import java.util.Scanner;

class Sort
{
    String str, sw;
    int len;

    Sort()
    {
        str = "";
        sw = "";
        len = 0;
    }

    void readword()
    {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a word: ");
        str = sc.next();
        len = str.length();
    }

    void arrange()
    {
        char ch[] = str.toCharArray();
        for (int i = 0; i < len - 1; i++)
        {
            for (int j = 0; j < len - 1 - i; j++)
            {
                if (ch[j] > ch[j + 1])
                {
                    char t = ch[j];
                    ch[j] = ch[j + 1];
                    ch[j + 1] = t;
                }
            }
        }
        sw = new String(ch);
    }

    void display()
    {
        System.out.println("Original word : " + str);
        System.out.println("Sorted word   : " + sw);
    }

    public static void main(String args[])
    {
        Sort ob = new Sort();
        ob.readword();
        ob.arrange();
        ob.display();
    }
}
Explanation: The default constructor sets the words to empty strings and len to 0. readword() accepts the word and stores its length. arrange() copies the characters of the word into an array and sorts them with bubble sort, then stores the sorted characters as a String in an extra data member sw, so that the original word in str is kept and both can be displayed. display() prints the original and the sorted word. Tested: input COMPUTER gives sorted word CEMOPRTU.
Q910 marks · ProgramOpen: A Special number is a number in which the sum of the factorial of its digits is…

Write the program described below.

A Special number is a number in which the sum of the factorial of its digits is equal to the number. Example: 145 ($1! + 4! + 5! = 145$). Thus, 145 is a Special number. Design a class Special to check if the given number is a Special number or not. Some of the members of the class are given below: Class name : Special Data member/instance variable: n : integer to store number Member functions/methods: Special() : default constructor void read() : to accept the number int factorial(int x) : return the factorial of a number using recursive technique boolean isSpecial() : checks for the special number by invoking the function factorial() and returns true if Special, otherwise returns false void display() : displays the result with an appropriate message Specify the class Special, giving details of the Constructor, void read(), int factorial(int), boolean isSpecial() and void display(). Define the main() function to create an object and call the member function according to enable the task.
Show answer

Answer

import java.util.Scanner;

class Special
{
    int n;

    Special()
    {
        n = 0;
    }

    void read()
    {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number: ");
        n = sc.nextInt();
    }

    int factorial(int x)
    {
        if (x <= 1)
            return 1;
        return x * factorial(x - 1);
    }

    boolean isSpecial()
    {
        int sum = 0, t = n;
        while (t > 0)
        {
            sum = sum + factorial(t % 10);
            t = t / 10;
        }
        return sum == n;
    }

    void display()
    {
        if (isSpecial())
            System.out.println(n + " is a Special number");
        else
            System.out.println(n + " is not a Special number");
    }

    public static void main(String args[])
    {
        Special ob = new Special();
        ob.read();
        ob.display();
    }
}
Explanation: The constructor sets n to 0 and read() accepts the number. factorial(x) is recursive: it returns 1 when x <= 1 (base case), otherwise x * factorial(x - 1). isSpecial() extracts each digit of n with % 10 and / 10, adds the factorial of each digit and returns true if the sum equals n. display() prints an appropriate message. Tested: 145 gives 145 is a Special number (1! + 4! + 5! = 1 + 24 + 120 = 145).
Q105 marks · ProgramOpen: An interface Shape is defined with a method area() which returns the area of…

Write the program described below.

An interface Shape is defined with a method area() which returns the area of the implementing shape. Create the classes Circle and Rectangle which implement the interface Shape. These classes have attributes which reflect their dimensions (radius for a circle, height and width for a rectangle) which are set by their constructors. The details of the members of the interface and both the classes are given below: Interface name : Shape Member functions/methods: double area() : returns the area of the implementing shape Class name : Circle Data members/instance variables: radius : to store radius of the circle in decimal Member functions/methods: Circle(int r) : parameterized constructor to initiallize radius=r double area() : to calculate area of the circle [ area of a circle is $3.14 * radius * radius$ ] Class name : Rectangle Data members/instance variables: length : to store length of the rectangle in decimal breadth : to store breadth of the rectangle in decimal Member functions / methods: Rectangle(int l, int b) : parameterized constructor to initialize length=l, breadth=b double area() : to calculate area of the rectangle [ area of a rectangle is $length * breadth$ ] Assume that the Interface Shape has been defined. Using the concept of inheritance, specify the classes Circle and Rectangle giving details of their constructors and double area() respectively. The interface, main function and algorithm need NOT be written.
Show answer

Answer

class Circle implements Shape
{
    double radius;

    Circle(int r)
    {
        radius = r;
    }

    public double area()
    {
        return 3.14 * radius * radius;
    }
}

class Rectangle implements Shape
{
    double length, breadth;

    Rectangle(int l, int b)
    {
        length = l;
        breadth = b;
    }

    public double area()
    {
        return length * breadth;
    }
}
Explanation: Both classes implement the interface Shape (the keyword implements is used for an interface), so each must define the method area(), which must be declared public as interface methods are public. The constructor of Circle stores the radius and area() returns 3.14 x radius x radius. The constructor of Rectangle stores the length and breadth and area() returns length x breadth. Tested with an interface Shape { double area(); }: Circle(7).area() gives 153.86 and Rectangle(5, 4).area() gives 20.0.
Q115 marks · ProgramOpen: Circular Queue is a linear data structure in which the operations are performed…

Write the program described below.

Circular Queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle. Define a class Cqueue with the following details: Class name : Cqueue Data member/instance variable: ele[ ] : array to hold the integer elements cap : stores the maximum capacity of the array front : to point the index of the front rear : to point the index of the rear. Member functions/methods: Cqueue(int max) : constructor to initialize the data member cap = max, front = rear = 0 and create the integer array void insert(int v) : to add integers from the front index if possible else display the message(“full from rear”) int delete( ) : to remove and return elements from rear, if any, else returns -999 void display() : to display elements of circular queue Specify the class Cqueue giving the details of void insert(int) and int delete( ). Assume that the other functions have been defined. The main( ) function and algorithm need NOT be written.
Show answer

Answer

void insert(int v)
{
    if ((front + 1) % cap == rear)
        System.out.println("full from rear");
    else
    {
        ele[front] = v;
        front = (front + 1) % cap;
    }
}

int delete()
{
    if (front == rear)
        return -999;
    int v = ele[rear];
    rear = (rear + 1) % cap;
    return v;
}
Explanation: As given in the question, elements are added at the front index and removed from the rear end, and front and rear both start at 0, so front == rear means the queue is empty. insert() checks whether moving front one step forward (with wrap-around using % cap) would meet rear; if so the queue is full and the message full from rear is shown (one position is kept unused to tell a full queue from an empty one). Otherwise the value is stored at ele[front] and front moves circularly. delete() returns -999 if the queue is empty; otherwise it returns the element at rear and moves rear forward circularly, so the element inserted first is removed first (FIFO). Tested with cap = 4: three inserts were accepted, the fourth printed full from rear, deletes returned the values in FIFO order and a delete on the empty queue returned -999.
Q12(a)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 insert a node at the beginning of an existing linked list. The method declaration is as follows: void InsertNode( Node starPtr, int n )
Show answer

Answer

void InsertNode(Node starPtr, int n)
{
    Node t = new Node();
    t.num = n;
    t.next = starPtr;
    start = t;
}
Explanation: starPtr is the reference to the first node of the existing list and start is the class-level reference that holds the head of the list (starPtr = start when the method is called). A new node t is created and the number n is stored in it. Its next reference is made to point to the old first node (starPtr), and start is then made to point to t, so the new node becomes the first node. This also works for an empty list (starPtr is null), where the new node becomes the only node. Tested: inserting 30, 20 and 10 in turn gives the list 10 20 30.
Q12(b)(i)1 mark · Binary treeOpen: Name the Root and the leaves of the tree.

Answer the following questions from the binary tree.

Name the Root and the leaves of the tree.
Show answer

Answer

Root of the tree: A. Leaves (nodes with no children): D, E and G.
Q12(b)(ii)1 mark · Binary treeOpen: Write the post order traversal of the tree.

Answer the following questions from the binary tree.

Write the post order traversal of the tree.
Show answer

Answer

Post-order traversal (left, right, root): left subtree of A gives D B (B has only a right child D), right subtree gives E G F C (C has left child E and right child F; F has left child G), then the root A. Post-order: D B E G F C A
Q12(b)(iii)1 mark · Binary treeOpen: Separate the Internal nodes and the External nodes of the tree.

Answer the following questions from the binary tree.

Separate the Internal nodes and the External nodes of the tree.
Show answer

Answer

Internal nodes (nodes having at least one child): A, B, C and F. External nodes (leaf nodes): D, E and G.

About this specimen paper

The ISC Computer Science 2020 Specimen Paper is a specimen paper for Class 12: 30 questions in printed order, 70 marks in all, asked from 8 chapters. A specimen paper is the sample question paper CISCE publishes before the exam to show the layout and style of that year’s paper. It is a good guide to the pattern you will meet.

The layout of the current Computer Science paper (sections, marks, choices) is in the paper pattern guide.

By kind of question

KindQuestionsMarks printed*
Program642
Short answer915
Drawing512
K-map28
Truth table26
Output15
Binary tree33
Differentiate12
Numerical12

By chapter

ChapterQuestionsMarks printed*
Objects330
Boolean Algebra1226
Data structures714
Computer Hardware39
Inheritance, Interfaces and Polymorphism27
Recursion15
Arrays, Strings12
Complexity and Big O notation12

* Marks are those printed on each question; where a question offers an either-or choice, both options are counted, so the totals can come to more than the paper’s own total.

Common questions

How many questions are in the ISC Computer Science 2020 Specimen Paper?

30 questions, 70 marks in all, shown in full and in printed order on this page.

Which chapters does the ISC Computer Science 2020 Specimen Paper ask most about?

By number of questions: Boolean Algebra (12), Data structures (7), Objects (3) and Computer Hardware (3).

Does this page have the answers to the ISC Computer Science 2020 Specimen Paper?

Tap “Show answer” under a question to see its answer. The download button saves the paper as a PDF, with or without the answers.