ISC Class 12 Computer Science previous year paper (2018)
- Categories Sample Papers
Part I (20 marks)
Answer all questions.
While answering questions in this Part, indicate briefly your working and reasoning, wherever required.
Question 1 [1 mark each]
(a) State the Commutative law and prove it with the help of a truth table.
(b) Convert the following expression into its canonical POS form:
F (X, Y, Z) = (X+Y’). (Y’+Z)
(c) Find the dual of:
(A’+ B). (1 +B’) = A’ + B
(d) Verify the following proposition with the help of a truth table
(P ∧ Q) ∨ (P ∧ ∼ Q) = P
(e) If F (A, B, C) = A’ (BC’ + B’C), then find F’
Ans.
(a) Law: Commutative Law (i) A + B = B + A (ii) A . B = B. A
Truth Table:
A | B | A+B | B+A |
---|---|---|---|
0 | 0 | 0 | 0 |
0 | 1 | 1 | 1 |
1 | 0 | 1 | 1 |
1 | 1 | 1 | 1 |
(b) F (X, Y, Z) = (X+Y’) . (Y’+Z)
= (X+Y’+0). (Y’+Z+0)
= (X+Y’+ (Z.Z’)). (Y’+Z+ (X.X’))
= (X+Y’+Z). (X+Y’+Z’). (X+Y’+Z). (X’+Y’+Z)
= (X+Y’+Z). (X+Y’+Z’). (X’+Y’+Z)
(c) Equation: (A’+ B). (1 +B’) = A’ + B
Dual = A’. B + 0.B’ = A’. B
(d) Verify: (P∧Q)∨(P∧∼Q) = P
P | Q | P∧Q | P∧∼Q | (P∧Q)∨(P∧∼Q) |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 1 | 0 | 0 | 0 |
1 | 0 | 0 | 1 | 1 |
1 | 1 | 1 | 0 | 1 |
(e) F (A, B,C) = A’(BC’+B’C)
F’ = A’’ + (BC’ + B’C)’
= A+ (BC’)’. (B’C)’
= A + (B’ + C). (B + C’)
Question 2 [2 marks each ]
(a) What are Wrapper Classes? Give any two examples.
(b) A matrix A[m][m] is stored in the memory with each element requiring 4 bytes of storage. If the base address at A [1][1] is 1500 and address of A [4][5] is 1608,
determine the order of matrix when it is stored in Column Major Wise.
(c) Convert the following infix notation to postfix form:
A + (B – C * (D / E) * F)
(d) Define Big ‘O’ notation. State the two factors which determine the complexity of an algorithm.
(e) What is exceptional handling? Also, state the purpose of finally block in a try catch statement.
Ans.
(a) Wrapper Class: A class which defines a primitive data type. A Wrapper class is a class whose object wraps or contains a primitive data types. Wrapper class in java provides the mechanism to convert primitive into object and object into primitive.
Example: Integer, Character, Double etc.
(b) Column Major Wise: P[i][j] = BA + W [ (j – lc )* rows + (i – lr]
Putting the values: 1608 = 1500 + 4[ (4*m + 3)]
1608 = 1500 + 16m + 12
16m = 1608-1512
m = 6
(c) Infix to Postfix: A + (B – C * (D / E) * F)
= A + (B – C * DE/ * F)
= A + (B- CDE/* * F)
=A + (BCDE/*F*-)
Ans: ABCDE/*F*-+
(d) Big ‘O’ Notation: The unit of measurement of efficiency of an algorithm. A theoretical measure of the execution of an algorithm, usually the time or memory needed, given the problem size n, which is usually the number of items.
Two factors are Time and Space(memory)
(e) Exceptional Handling: The way to handle anomalous situations during run time. Finally, is a block of code which is executed with or without exceptions.
Question 3 [5 marks ]
The following is a function of some class which checks if a positive integer is a Palindrome number by returning true or false. (A number is said to be Palindrome if the reverse of the number is equal to the original number.) The function does not use modulus (%) operator to extract digit. There are some places in the code marked by?1?, ?2?, ?3?, ?4?, ?5? which may be replaced by a statement / expression so that the function works properly.
boolean PalindromeNum( int N )
{
int rev= ?1?;
int num=N;
while(num>0)
{
int f= num/ 10;
int s = ?2?;
int digit = num - ?3?;
rev= ?4? + digit;
num /= ?5?;
}
if ( rev= =N )
return true;
else
return false;
}
(i) What isthe statement or expression at ?1?
(ii) What isthe statement or expression at ?2?
(iii) What isthe statement or expression at ?3?
(iv) What isthe statement or expression at ?4?
(v) What isthe statement or expression at ?5?
Ans.
(i) 0
(ii) f*10
(iii) s OR f*10
(iv) rev*10
(v) 10
PART – II (50 Marks)
Answer six questions in this part, choosing two questions from
Section A, two from Section B and two from Section C.
SECTION – A
Answer any two questions.
Question 4
(a) Given the Boolean function F (A, B, C, D) = Ʃ (0,2,4,8,9,10,12,13).
- Reduce the above expression by using 4-variable Karnaugh map, showing the various groups (i.e. octal, quads and pairs).
- Draw the logic gate diagram for the reduced expression. Assume that the variables and their complements are available as inputs.
(b) Given the Boolean function F (A, B, C, D) = π(3,4,5,6,7,10,11,14,15).
- Reduce the above expression by using 4-variable Karnaugh map, showing the various groups (i.e. octal, quads and pairs).
- Draw the logic gate diagram for the reduced expression. Assume that the
variables and their complements are available as inputs.
Ans.
(a) F(A, B,C,D) = ∑ ( 0, 2 , 4, 8, 9, 10, 12, 13 )
There are two quads and one pair:
Quad 1 (m0+ m4+ m12+ m8 ) = C’D‘ Quad2 ( m0+ m2+ m8+ m10 ) = B’D‘
Quad 3 (m8+ m9 + m12 + m13) = AC’
Hence F (A, B, C, D) = C’D’ + B’D’ + AC’
4(b) F(A,B,C,D) = π ( 3 , 4 , 5 , 6 , 7 , 10 , 11 , 14 , 15 )
There are three quads :
Quad 1: (M4 M5 M6 M7) = A + B’ Quad 2: ( M3 M7 M11 M15) = C’ + D’
Quad 3: (M10 M11 M14 M15) = A’ + C’
Hence F (A, B,C,D) = ( A + B’ ) . (C’ + D’). (A’ + C’)
Question 5
(a)A training institute intends to give scholarships to its students as per the criteria given below:
• The student has excellent academic record but is financially weak.
OR
• The student does not have an excellent academic record and belongs to a backward class.
OR
• The student does not have an excellent academic record and is physically impaired.
The inputs are:
INPUTS
A Has excellent academic record
F Financially sound
C Belongs to a backward class
I Is physically impaired
(In all the above cases 1 indicates yes and 0 indicates no).
Output : X [1 indicates yes, 0 indicates no for all cases]
Draw the truth table for the inputs and outputs given above and write the POS expression for X (A, F, C, I). [5]
(b) Using the truth table, state whether the following proposition is a tautology, contingency or a contradiction: [3]
~(A ˄ B) V ( ~A => B)
(c) Simplify the following expression, using Boolean laws: [2]
A • (Aʹ + B) • C • (A + B)
Ans.
(a)
A | F | C | I | X (OUTPUT) |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 1 | 1 |
0 | 0 | 1 | 0 | 1 |
0 | 0 | 1 | 1 | 1 |
0 | 1 | 0 | 0 | 0 |
0 | 1 | 0 | 1 | 1 |
0 | 1 | 1 | 0 | 1 |
0 | 1 | 1 | 1 | 1 |
1 | 0 | 0 | 0 | 1 |
1 | 0 | 0 | 1 | 1 |
1 | 0 | 1 | 0 | 1 |
1 | 0 | 1 | 1 | 1 |
1 | 1 | 0 | 0 | 0 |
1 | 1 | 0 | 1 | 0 |
1 | 1 | 1 | 0 | 0 |
1 | 1 | 1 | 1 | 0 |
SOP Expression: X (A ,F, C, I) = Σ (1, 2, 3, 5, 6, 7, 8, 9, 10, 11)
OR X = A’F’C’I + A’F’CI’ + A’F’CI + A’FC’I + A’FCI’ + A’FCI + AF’C’I’ + AF’C’I + AF’CI’ + AF’CI
(b) ∼(A∧B) ∨ (∼A=>B) is a Tautology, Contradiction or Contingency
A | B | ∼A | ∼B | ∼(A∧B) | ∼A=>B | ∼(A∧B) ∨ (∼A=>B) |
---|---|---|---|---|---|---|
0 | 0 | 1 | 1 | 1 | 0 | 1 |
0 | 1 | 1 | 0 | 1 | 1 | 1 |
1 | 0 | 0 | 1 | 1 | 1 | 1 |
1 | 1 | 0 | 0 | 0 | 1 | 1 |
Hence, it is a Tautology
(c) Simplify : A.(A’+B).C.(A+B)
= (AA’ + AB).(AC + BC)
= (0 + AB).(AC + BC)
= ABC + ABC
= ABC
Question 6
(a) What is an Encoder? Draw the Encoder circuit to convert A-F hexadecimal numbers to binary. State an application of a Multiplexer. [5]
(b) Differentiate between Half Adder and Full Adder. Draw the logic circuit diagram for a Full Adder. [3]
(c) Using only NAND gates, draw the logic circuit diagram for Aʹ + B. [2]
Ans.
(a) An Encoder is a combinational circuit which inputs 2n or fewer lines and outputs n lines.
Circuit diagram of a A – F Encoder:
Application of a Multiplexer: 1. Used for Routing of signals
2. Data Transmission
3. Telephone Exchanges / TV etc
(b) Half Adders : It is a combinational circuit which adds two input binary bits and outputs two binary bits.
Full Adders : It is a combinational circuit which adds three input binary bits and outputs two binary bits.
Circuit of a Full Adder : SUM=A⊕B⊕C
CARRY = AB + BC + AC
(c) Using NAND – circuit of Aʹ + B
SECTION – B
Answer any two questions.
Question 7 [marks 10]
Design a class Perfect to check if a given number is a perfect number or not. [ A number is said to be perfect if sum of the factors of the number excluding itself is equal to the original number]
Example : 6 = 1 + 2 + 3 (where 1, 2 and 3 are factors of 6, excluding itself)
Some of the members of the class are given below:
Class name | Perfect |
---|---|
Data members/instance variables: | |
num | to store the number |
Methods/Member functions: | |
Perfect (int nn) | parameterized constructor to initialize the data member num=nn |
int sum_of_factors(int i) | returns the sum of the factors of the number(num), excluding itself, using recursive technique |
void check() | checks whether the given number is perfect by invoking the function sum_of_factors() and displays the result with an appropriate message |
Specify the class Perfect giving details of the constructor (), int sum_of_factors(int) and void check (). Define a main () function to create an object and call the functions accordingly to enable the task.
import java.util.*;
class Perfect
{
int num;
Perfect(int nn)
{
num=nn;
}
int sum_of_factors(int i)
{
if (i == num)
return 0;
else if (num%i==0)
return i + sum_of_factors(i+1);
else
return sum_of_factors(i+1);
}
void check()
{
int s=sum_of_factors(1);
if (s==num)
System.out.println(num+"is a perfect number");
else
System.out.println(num+"is not a perfect number");
}
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number");
int no=sc.nextInt();
Perfect ob=new Perfect(no); // OR Perfect ob=new Perfect(6);
ob.check(); // ob.check();
}
}
Question 8 [marks 10]
Two matrices are said to be equal if they have the same dimension and their corresponding elements are equal.
For example, the two matrices A and B given below are equal:
Design a class EqMat to check if two matrices are equal or not. Assume that the two
matrices have the same dimension.
Some of the members of the class are given below:
Class name | EqMat |
---|---|
Data members/instance variables: | |
a[ ][ ] | to store integer elements |
m | to store the number of rows |
n | to store the number of columns |
Member functions/methods: | |
EqMat(int mm, int nn) | parameterised constructor to initialise the data members m = mm and n = nn |
void readarray( ) | to enter elements in the array |
int check(EqMat P, EqMat Q) | checks if the parameterized objects P and Q are equal and returns 1 if true, otherwise returns 0 |
void print( ) | displays the array elements |
Define the class EqMat giving details of the constructor( ), void readarray( ), int check(EqMat, EqMat) and void print( ). Define the main( ) function to create objects and call the functions accordingly to enable the task.
import java.util.*;
class EqMat
{
int a[][];
int m;
int n;
static Scanner sc=new Scanner(System.in);
EqMat(int mm,int nn)
{
m=mm;
n=nn;
a=new int[m][n];
}
void readarray()
{
System.out.println("enter" + (m*n) + "elements" );
for (int i=0;i<m;i++)
for (int j=0;j<n;j++)
a[i][j]=sc.nextInt();
}
int check(EqMat P,EqMat Q)
{
for (int i=0;i<P.m;i++)
for (int j=0;j<P.n;j++)
{
if (P.a[i][j]!=Q.a[i][j])
return 0;
}
return 1;
}
void print()
{
for (int i=0;i<m;i++)
{
System.out.println();
for (int j=0;j<n;j++)
System.out.print(a[i][j]+"\t");
}
}
public static void main()
{
EqMat ob1=new EqMat(3,3);
EqMat ob2=new EqMat(3,3);
System.out.println("enter nos for the Ist Matrix");
ob1.readarray();
System.out.println("enter nos for the 2nd Matrix");
ob2.readarray();
if (ob1.check(ob1,ob2)==1)
{
System.out.println("Equal Matrix");
ob1.print();
ob2.print();
}
else
System.out.println("not equal");
}
}
Question 9 [marks 10]
A class Capital has been defined to check whether a sentence has words beginning with a capital letter or not.
Some of the members of the class are given below:
Class name | Capital |
---|---|
Data member/instance variable: | |
sent | to store a sentence |
freq | stores the frequency of words beginning with a capital letter |
Member functions/methods: | |
Capital( ) | default constructor |
void input() | to accept the sentence |
boolean isCap(String w) | checks and returns true if word begins with a capital letter, otherwise returns false |
void display () | displays the sentence along with the frequency of the words beginning with a capital letter |
Specify the class Capital, giving the details of the constructor( ), void input( ), boolean isCap(String) and void display( ). Define the main( ) function to create an object and call the functions accordingly to enable the task.
import java.util.*;
class Capital
{
String sent;
int freq;
Capital()
{
sent="";
freq=0;
}
void input()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the sentence");
sent=sc.nextLine();
}
boolean isCap(String w)
{
char c=w.charAt(0);
if (Character.isUpperCase(c) )
return true;
else
return false;
}
void display()
{
System.out.println("sentence="+sent);
String b=" "+sent;
char c;
for(int i=0;i<b.length();i++)
{
c=b.charAt(i);
if (c==' ')
{
if(Character.isUpperCase(b.charAt(i+1)) )
freq++;
}
}
System.out.println("Freqency of title word="+freq);
}
public static void main()
{
Capital ob=new Capital();
ob.input();
ob.display();
}
}
SECTION – C
Answer any two questions.
Question 10 [marks 5]
A super class Number is defined to calculate the factorial of a number. Define a sub class Series to find the sum of the series S = 1! + 2! + 3! + 4!+……………+n!
The details of the members of both the classes are given below:
Class name | Number |
Data member/instance variable: | |
n | to store an integer number |
Member functions/methods: | |
Number(int nn) | parameterized constructor to initialize the data member n=nn |
int factorial (int a) | returns the factorial of a number (factorial of n = 1×2×3×………×n) |
void display() | displays the data members |
Class name: | Series |
Data member/instance variable: | |
sum | to store the sum of the series |
Member functions/methods: | |
Series(…) | parameterized constructor to initialize the data members of both the classes |
void calsum( ) | calculates the sum of the given series |
void display( ) | displays the data members of both the classes |
Assume that the super class Number has been defined. Using the concept of inheritance, specify the class Series giving the details of the constructor(…),void calsum( ) and void display( ).
The super class, main function and algorithm need NOT be written.
class Series extends Number
{
long sum;
Series(int nn)
{
super(nn);
sum=0;
}
void calsum()
{
for (int i=1;i<=n;i++)
sum=sum+factorial(i);
}
void display()
{
super.display();
System.out.println("sum of the series="+sum);
}
}
Question 11 [marks 5]
Register is an entity which can hold a maximum of 100 names. The register enables the user to add and remove names from the top most end only.
Define a class Register with the following details:
Class name | Queue |
---|---|
Data Members / instance variables: | |
Que[ ] | array to hold the integer elements |
size | stores the size of the array |
front | to point the index of the front |
rear | to point the index of the rear |
Member functions: | |
Queue (int mm) | constructor to initialize the data size = mm, front = 0, rear = 0 |
void addele(int v ) | to add integer from the rear if possible else display the message “Overflow” |
int delele( ) | returns elements from front if present, otherwise displays the message “Underflow” and return -9999 |
void display ( ) | displays the array elements |
(a) 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. [4]
(b) Name the entity used in the above data structure arrangement. [1]
Ans.
(a)
class Register
{
void push(String n)
{
if (top<cap-1)
stud[++top]=n;
else
System.out.println("OVERFLOW");
}
String pop()
{
if (top>=0)
return stud[top--];
else
return " $";
}
}
(b) The entity used in the above data structure is Stack.
Question 12
(a) A linked list is formed from the objects of the class Node. The class structure of the Node is given below: [2]
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 )
(b) Answer the following questions from the diagram of a Binary Tree given below:
(i) Write the inorder traversal of the above tree structure. [1]
(ii) State the height of the tree, if the root is at level 0 (zero). [1]
(iii) List the leaf nodes of the tree. [1]
Ans.
(a) ALGORITHM:
Step 1. Start
Step 2. Set temporary pointer to the first node
Step 3. Repeat steps 4 and 5 until the pointer reaches null. Display number not found
Step 4. check for number , if found display, exit
Step 5. Move pointer to the next node
Step 6. End algorithm
METHOD:
void FindNode(Node str, int b)
{
Node temp=str;
while(temp!=null)
{
if (temp.n == b)
{
System.out.prinln(b+” is found “);
break;
}
temp=temp.link;
}
}
(b) (i) G,E,H,C,A,B,F,D
(ii) 3
(iii) G,H,F