COMPUTER SCIENCE
Paper-l
(THEORY)
Three hours
(Candidates are allv\1'ed addilional ) 5 minutes f or only reading the paper.
They must NOT start writing during this time.)
Answer all questions in Part J (compulsory) and seven questions from Part II. choosing three
questions from Sect ion-A, two questions fro m Section-B and two questions from Section-C
All working, including rough work, should be done on the same sheet as the rest of the answer.
The imended marks for questions or p arts of questions are given in brackets [ ].
PART I
Answer all questions.
While answering questions in this Part, indicate briefly your working and reasoning,
wherever required.
Question 1
(a) State the two Absorption laws. Verify anyone of them using truth table. [2]
(b) Reduce the following expression: [2]
F(A.B.C) = L (0,1,2,3,4,5,6,7)
Also find the complement of the reduced expression.
(c) Name the logic gate for the following circuit diagram and write its truth table. [2]
A B
(d) Using truth table, verify whether the following is true or false: [2]
(p => q) = (q => p)
(e) IfA= l, B=O, C=l and 0=1 find its: [2]
(i) Maxterm
( i i) Minterm
Question 2
(a) How can we override a method in inheritance? [2]
(b) A square matrix A[m x m] is stored in the memory with each element requiring [2]
2 bytes of storage. If the base address A[ 1][ 1] is 1098 and the address at A [4][5] is
1144, determine the order of the matrix A[m x m] when the matrix is stored
Column Major wise.
(c) What is Big 0 notation? [2)
(d) What is an exception? [2]
(e) Convert the following infix expression to its postfix form: [2)
a+b*c-d/e
Question 3
(a) The following is a part of some class. What will be the output of the function [5]
mymethod( ) when the value of counter is equal to 3? Show the dry run / working.
void mymethod(int counter)
{
if ( counter = = 0 )
System.out.println(" ");
else
{
System .out. println(" He! 10 "+counter);
mymethod(- -counter) ;
System.out.println(" "+counter);
}
}
(b) The following function is a part of some class which computes and returns the greatest
common divisor of any two numbers. There are some places in the code marked by
?1?, n?, ?3?, ?4? and ?5? which must be replaced by statement/expression so that
the"function works correctly.
int gcd(int a, int b)
{
int r;
while(?l ?)
{
r=n? ;
b=?3?;
a=?4? ;
}
if(a==O)
return ?5?;
else
return -1;
}
l.com
(i) What is the expression or statement at ?1? III
(i i) What is the expression or statement at ?2? 111
(i ii) What is the expression or statement at ?3? III
(iv) What is the expression or statement at ?4? III
(v) What is the expression or statement at ?5? 111
PART - II
Answer seven questions in this part, choosing three questions from
Section A, two from Section B and two from Section C
SECTION - A
Answer any three questions.
Question 4
(a) State the principle of Duality. Give the dual of the following: 131
(A'.B)+(C.l )=(A'+C).(B+C)
(b) Reduce the Boolean expressions to their simplest forms: [4J
(i) {(C.D)'+ A} + A + C.D + A.B
(ii) A.{B+C(A.B+A.C)'}
(c) Verify using a truth table if: 13]
(A 0 B 0 C)' = A 61 B EB C
Question 5
(a) Given F( P, Q, R,' S) = n( 2, 3, 6,7,?, 11, q, 13, 14, 15) 15]
Reduce the above expression by using/our variable Karnaugh ' s Map. Draw the logic
gate diagram of the reduced expression using NOR gate only.
(b) Gi ven F(A,B,C,D)=ABCD+ABCD+ABCD+ABCD+ABCD+ABCD. 151
Reduce the above expression by using/our variable Karnaugh ' s Map. Draw the logic
gate diagram of the reduced expression using NAND gate only.
Question 6
(a) Show with the help of a logic diagram how a NAND gate is equivalent to an OR gate . [3J
(b) Veri fy if the following is valid: 13]
(a => b) /\ (a => c) = a => (b /\ c)
(c) What is a Decoder? Draw the truth table and logic circuit diagram for a 2 to 4 Decoder. [41
3
© www.javaforschool.com
Question 7
(a) What is a Full Adder? Draw the truth table for a Full adder. Also derive SOP expression 141
for the Fu ll Adder and draw its logic circuit.
(b) State how a Decoder is different fro m a Multiplexer. A lso state one li se of each. r3]
(c) Convert the following cardinal ex pression into its canonical form and reduce it using 131
Boolean laws:
F(L,M,O ,P) = 7[ (0,2 ,8, 10)
SECTION - B
Answer any two questions.
Each program should be written in such a way that it clearly depicts the logic a/the problem.
This can be achieved by using mnemonic names and comments in the program.
(Flowcharts and Algorithm s are not required.)
The programs must be written in Java.
Question 8
Input a sentence from the user and count the number of times, the words "an" and "and " are [101
present in the sentence. Design a class Frequency using the description given below:
Class name Frequency
Data Members / variables:
text stores the sentence
countand to store the frequenc y of the word
"and"
countan to store the frequ ency of the word "a n"
len stores the length of the string
Member functions/method s:
Frequ ency( ) constructor to initialize the insta nce
variables
void accept(String n) to assign n to text , where the value of
the parameter n sho uld be in lo we r
case.
void checkandfreq( ) to count th e frequency of "and"
void checkanfreq( to co un! the frequency of "an"
void display( ) to display the number of "and" and
"an" with appropriate messages.
Specify the class Frequency giVIng details of the constructor( ), void accept(String),
void checkandfreq( ), void checkanfreq( ) and void display( ). A lso detine the maine )
fun ction to create an object and call methods accordingly to enable the task.
4
vaforschool.com
Question 9
A class DeciOct has been defined to convert a decimal number into its equivalent octal
number. Some of the members of the class are given below:
Class name DeciOct
Data Members / instance variables:
n stores the decimal number
oct stores the octal equivalent number
Member functions:
DeciOct( ) constructor to initialize the data
members n=O, oct = O.
void getnum(int nn ) assign nn to n
void deci oct() calculates the octal equivalent of ' n'
and stores it in oct using the
recursive technique
void show() displays the decimal number ' n',
calls the function deci _ oct( ) and
displays its octal equivalent.
(a) Specify the class DeciOct, giving details of the constructor( ), void getnum(int), [8]
void deci_oct() and void show(). Also define a maine ) function to create an object
and call the functigns accordingly to enable the task.
(b) State any two disadvantages of using recursion. 12]
ool.com
Question 10
You are given a sequence of N integers, which are called as pseudo arithmetic sequences [10J
(sequences that are in arithmetic progression).
Sequence ofN integers: 2, 5,6,8,9, 12
We observe that 2 + 12 = 5 + 9 = 6 + 8 = 14.
The sum of the above sequence can be calculated as 14 x 3 = 42.
For sequence containing an odd number of elements the rule is to double the middle element,
for example 2, 5, 7, 9, 12
= 2 + 12 = 5 + 9 = 7 + 7 = 14.
14 x 3 = 42 [middle element = 7]
A class Pseudoarithmetic determines whether a given sequence is a pseudo-arithmetic
sequence.
The details of the class are given below:
Class name Pseudoarithmetic
Data Members / instance variables:
n to store the size of the sequence
a[] integer array to store the sequence of
numbers
ans, flag store the status
sum store the sum of sequence of numbers
r store the sum of the two numbers
Member functions:
Pseudoarithmetic( ) default constructor
void accept( int nn ) to assign nn to n and to create an integer
array. Fill in the elements of the array.
boolean check( ) return true if the sequence is a
pseudo-arithmetic sequence otherwise
returns false
Specify the class Pseudoarithmetic, gIvmg the details of the constructor( ),
void accept(int) and boolean check(). Also define a maine ) function to create an object
and call the member functions accordingly to enable the task.
SECTION -C
Answer any two questions.
Each Program / Algorilhm should be written in such a way that if clearly depicts the logic 0/
the problem step wise. This can also be achie ved by using pseudo codes.
(Flowcharts are not required) .
The programs must be written in Java.
The Algorithm must be written in general/standard form .
Question 11
A super class Record has been defined to store the names and ranks of 50 students. Define a 1101
sub-class Rank to find the highest rank along with the name. The details of both classes are
given be low:
Class name Record
Data Members / instance variables:
name[ ] to store the names of students
rnk[ ] to store the ranks of students
Member functions:
Record( ) co nstructor to initialize data membe rs
void readvalues( ) to store the names and ranks
voi d display( ) d isplays the names and the corresponding
ranks
Class name Rank
Data members /instance variables:
index integer to store the index of the topmost
rank
Member functions:
Rank() constructor to invoke the base class
constructor and to initialize index = 0
voi d highest( ) finds the index/location of the topmost
rank and stores it in index without
sorting the array.
void display( ) displays the names and railks along with
the name hav ing the topmos t rank.
Specify the class Record glvmg details of the constructor( ), void readvalues( ) and
void display( ). Using the concept of inheritance, specify the class Rank gi ving details of
constructor( ), void highest( ) and void display( ).
THE MArN() FUNCTION AND ALGORITHM NEED NOT BE WRITTEN.
© www.javaforschool.com
Question 12
Stack is a kind of data structure which can store elements with the restriction that an
element can be added or removed from the top only .
The details of the class Stack is given below:
Class name Stacl\.
Data Members / instance
variables:
st[ ] the array to hold the names
size the maximum capacity of the string array
top the index of the topmost element of the
stack
ctr to count the number of elements of the
stack
Member functions:
Stack( ) default constructor
Stack(int cap) constructor to initialize size = cap and
top = -1
void pushname(String n) to push a name into the stack. If the
stack is full, display the message
"0 VERFLO W"
String popname( ) removes a name from the top of the stack
and returns it. If the stack is empty,
display the message "l JNDERFLOW"
void display( ) Display the elements of the stack.
(a) Specify class Stack giving details of the constructors( ), void pushname (String n), [8)
String popname( ) and void display( ).
THE MAIN( ) FUNCTION AND ALGORITHM NEED NOT BE WRITTEN .
(b) Under what Principle does the above entity work? [2]
Question 13
(a) A linked list is formed from the objects of the class, [4)
class Node
{
int info;
Node link ;
}
Write an algorithm OR a Method for deleting a node from a linked list.
The method declaration is given below:
void deletenode (Node start)
8
© www.javaforschool.com
(b) Distingui sh between worst-case and best case complexity of an algo rithm. 12]
(c) Answer the following from the diagram of a Binary Tree given below:
(i) Write the Postorder tree traversal [lJ
(ii) Name the Leaves of the tree [lJ
(iii) Height of the tree [lJ
(iv) Root of the tree IlJ
9
vaforsc