Computer Science Paper
Computer Science Paper
Question 1.
a) Obtain the truth table to verify the following expression: X(Y+Z) = XY + XZ. Also name the law
stated above.
b) Answer the following questions related to the gate given below:
A B C X
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 0
Write
i) Canonical Sum of Product expression
ii) Canonical Product of Sum expression
[ 2 x 5 = 10]
Question 2.
a) State a difference between linear and non linear data structure. Give one example of each.
b) Convert the following infix expression to its postfix form:-
((P*Q) / (R/S +T)) + U
c) Simplify the following expression by using the Boolean laws. Show the working in steps and also
mention the laws used.:
X’Y’Z’ + X’Y’Z+ X’YZ+X’YZ’+ XY’Z+ XY’Z
© www.javaforschool.com
d) Each element of an array A[20][10] requires 2 bytes of storage. If the address of A[6][8] is 4000,
find the base address at A[0][0] when the array is stored row major wise.
e) Define inheritance. How is it useful in programming?
[ 2 x 5 = 10]
Question 3.
a) The following function trial() and perform() are a part of some class. Answer the following parts
given below. Show the dry run/working.
int trial()
{
if(n==1)
return 2;
else if(n==2)
return 3;
else
return trial(n-2) + trial(n-1);
}
void perform(int p)
{
int x;
for(int i=1;i<=p;i++)
{
x=trial(i);
System.out.print(x+” “);
}
}
i) What will the function trial() return when the value of n is 4? [2]
ii) What will be the output of the function perform() when the value of p is 5? [2]
iii) In one line state what the function trial() is doing, apart from recursion? [1]
b) Answer the following from the diagram of a binary teee given below:
© www.javaforschool.com
i) Root of the tree.
ii) External nodes of the tree.
iii) List the nodes in the tree using inorder traversal.
iv) Left subtree
v) Height of the tree
[ 1 X 5 = 5]
Part II
Section A
Answer any three questions
Question 4.
a) F(P,Q,R,S)= P’Q’RS’ + P’QRS’ + PQ’R’S+PQ’RS’+PQ’RS+PQR’S+PQRS’+PQRS
Use Karnaugh map to reduce the given function F using the SOP form. Draw a logic gate diagram for the
reduced SOP form. You may use gates with more than two inputs. Assume that the variables and their
complements are available as inputs.
b) F(A,B,C,D)= π(0,1,2,3,5,7,9,13)
Use Karnaugh map to reduce the given function F using the POS form. Draw a logic gate diagram for the
reduced POS form. You may use gates with more than two inputs. Assume that the variables and their
complements are available as inputs.
[ 5 x 2 = 10]
Question 5.
A provisional store announces a special discount on all its products as a festival offer only to those who
satisfy any one of the following conditions:
• If he/she is an employee of the store and has a service of more than ten years
OR
• If he/she is a regular customer of the store whose age is less than 65 years and is not an
employee of the store
OR
• If he/she is a senior citizen but not a regular customer of the store
The inputs are:
E : Employee of the store
R : Regular customer of the store
S : Service of the employee is more than 10 years
C : Senior citizen of 65 years or above
Output
X : Denotes eligible for discount[ 1 indicates YES and 0 indicates NO in all cases]
a) Draw the truth table for the inputs and outputs given above an write the SOP expression for
X(E,R,S,C)
b) Reduce X(E,R,S,C) using Karnaugh’s map.
Draw the logic gate diagram for the reduced SOP expression for X(E,R,S,C) using AND , OR gates
. You may use gates with more than 2 inputs. Assume that the variables and their complements
are available as inputs.
[ 5 x 2= 10]
© www.javaforschool.com
Question 6.
a) Draw a truth table representing a 2 input XNOR gate and derive its SOP expression along with its
logic gate diagram. [3]
b) Simplify the following expression and convert it to its canonical POS form:
(X.Y+Z)(Y+Z’.X) [3]
c) From the logic circuit diagram given below, name the parts (1), (2), (3) and finally derive the
Boolean expression and simplify it:
[4]
Question 7.
a) Prove that the complement of A(A+B).B(B+C’) is a universal gate. [2]
b) Minimise the following expression. At each step state clearly the law used. [3]
Y=(A+B’).(B+CD)’
c) Draw the truth table and logic circuit diagram for a decimal to binary encoder. [5]
Question 8.
a) State a difference between multiplexers and decoders. Also state a use of each. [2]
b) Verify the following Boolean expression with the help of truth table. [3]
A (B C) = A (B C)
[5]
c) Write the SOP expression, truth table and the logic circuit of full adder. [5]
© www.javaforschool.com
Section B
Answer any 4 questions.
Each program should be written in such a way that it clearly depicts the logic of the problem. This can be
achieved by using mnemonic names and comments in the program.
(Flowcharts and algorithms are not required)
The programs must be written in C++/Java
Question 9.
A magic number is a number in which the eventual sum of digits of the number is equal to 1. For
example, 172 = 1 + 7 + 2 = 10
10 = 1 + 0 = 1
Then 172 is a magic number.
Design a class Magic to check if a given number is a magic number. Some of the members of the class
are given below:
Specify the class Magic by giving details of the constructor, void getnum(int), intSum_of_digits(int) and
void ismagic(). You need not write the main function.
[ 10 ]
Question 10.
A transpose of an array is obtained by interchanging the elements of rows and columns. A class
Transarray contains a two dimensional integer array of order [ m x n]. The maximum value possible for
both ‘m’ and ‘n’ is 20. Design a class Transarray to find the transpose of a given matrix. The details of the
members of the class are given below:
Member functions
Transarray() : default constructor.
© www.javaforschool.com
Transarray(intmm,intnn) : to inititalize the size of the matrix, m=mm,n=nn.
voidfillarray() : to enter elements into the matrix.
void transpose(Transarray A) : to find the transpose of a given matrix.
voiddisaparray() : displays the array in a matrix form.
Specify the class Transarray giving details of the constructors, void fillarray(), void transpose(Transarray)
and void disparray(). You need not write the main function.
[ 10 ]
Question 11.
A library issues books on a rental basis at a 2% charge on the cost price of the book per day. As per the
rules of the library, a book can be retained for 7 days without any fine. If the book is returned after 7
days, a fine will also be charged for the excess days as per the chart given below:
Number of excess days Fine per day
1 to 5 2.00
6 to 10 3.00
Above 10 days 5.00
Design a class Library and another class Compute to perform the task. The details of the 2 classes are
given below:
Member functions
Library(…) : parameterized constructor to assign values to data
members.
void show() : display the book details
Member functions
Compute(…) : parameterized constructor to assign values to data
Members of both classes.
void fine() : calculate the fine for excess days.
void display() : displays the book details along with the number of days,
fine and total amount to be paid.
Total amount is calculated as:
© www.javaforschool.com
Specify the class Library giving details of the constructors and void show(). Using the concept of
inheritance, specify the class Compute giving details of the constructor, void fine() and the void display()
function. You need not write the main function.
[ 10 ]
Question 12.
A class PrimeFac contains an array of 50 integers. Some of the members of the class are given below:
Member functions
PrimeFac() : constructor to inititalize array elements to 0.
void enter() : to enter values into array num[]
voidfrefac() : to determine the frequency of prime factors of the
numbers stored in num[] and assign it to freq[].
voiddisp() : to display both the arrays.
Specify the classPrimeFac giving details of the constructor, void enter(), void frefac() and void disp().You
need not write the main function.
[ 10 ]
Question 13.
Class Binary contains an array of n integers (n<=100) that are already arranged in ascending order. The
subscripts of the array elements vary from 0 to n-1. The data members and member functions of class
Binary are given below:
Member functions:
Binary(intnn) : constructor to initialize the size n to nn and the
other instance variables.
voidreaddata() : to fill the elements of the array in ascending
order.
© www.javaforschool.com
intbinary_search(int v) : returns the location of the value(v) to be
searched in the list by binary search method
using the recursive technique. The function
returns -1 if the number is not present in the
given list.
a) Specify the class Binary giving details of the constructor, void readdata() and
intbinary_search(int). younedd not write the main function. [8]
b) State the base case in the recursive technique binary_search(). [1]
c) What are the drawbacks of using the recursive technique. [1]
Question 14.
A class SortWord has been defined with the following details:
Class name : SortWord
Data members
txt : stores the word.
len : stores the length of the word.
Member functions
SortWord() : default constructor
voidreadTxt() : to accept the word in lower case.
voidsortTxt() : to sort the word in alphabetical order of
characters using bubble sort technique and
display it.
voidchangeTxt() : to change the case of vowels in the word to
upper case. For example :- school becomes
school.
voiddisp() : to display the changed string.
Specify the class SortWord giving the details of the functions constructor, void readTxt(), void sortTxt(),
void changeTxt() and void disp(). You need not write the main function.
[ 10 ]
© www.javaforschool.com