Comp Prelim 1
Comp Prelim 1
TI ON SC HO OL , PO W Ai
PR EL IM IN AR Y EX AM IN
AT IO N
CO M PU TE R SC IE NC E PA
PE R 1
(T HE OR Y)
ST D: XI I -
M AX .M AR KS : 70
DA TE : 25 -11 -20 24
TI M E: 3 ho ur s
(Candidates ar e all ow ed addit
ional 15 minutes fo-r on ly read
They mu st NO T start writing ing th e paper.
during this time.)
An sw er al l questions in Pa rt I ---------------------------
(compulsory) an d six quest
choosing two questions fro m ions fro m Part-IL
Section-A, two fro m Section-B
an d two fro m
Section-C.
Al l working, including rough
work, sh ou ld be done on the sa
The intended ma rk s fo r question me sh ee t as the
s or pa rts of questions are giv
en in brackets [ J.
PA RT I - 20 M AR KS
An sw er all questions.
While an sw eri ng questions in
thi s Part, indicate briefly yo ur
working an d reasoning,
wherever required.
Qu es tio n 1
(i) 'A sse rti on : A 1 B=O C= l an
d D= l and mi nte rm is A• B' •C
Re as on : A an d C mu st be co •D [1]
mplemented.
W hic h on e of the following op
tions is correct?
(a) Bo th As se rti on an d Re aso
n are true, and Re as on is the
explanation fo r As ser tio n. correct
(b)B oth As ser tio n an d Re as on
are true, bu t Re as on is no t the
correct ex pla na tio n fo r Asser
tion.
(c) Assertion is true an d Re as
on is false.
(d)Assertion is false an d Re as
on is true.
(ii) The Ca rdi na l su m- of- pro du ct
ex pre ssi on of F(a, b, c) = a.b
+ b.c' is ' + a.c [1]
Page 1 of 13
\
XII/PRELIMS NOV 2024
HFSP/ISC/csc/
(d) L( 2, 4, 5, 6,7)
. . ximutn variables in [1]
(iii) Assertion : The group which ehnunates the ma
a Kamaugh map is octet.
Reason : Octet can group 4 minterms/maxterms.
I Page 2 of 13
HFSP/ISC/CSC/XI I/PRELI MS NOV 2024
(vii) Consider the following snippet, calculate the time complexity [1]
assuming the code compiles successfully.
for(int j=0;j<m;j++) {
for( int i=0;i<m;i++){
System.out.println("Hello ");}
}
(a) O(m)
(b) O(m+m)
(c) O(m2)
(d) 0(1)
(viii) All methods declared in the interface are abstract. Where will the [1]
body of these abstract methods be defined?
(ix) Which Exception will be thrown when the following code is [1]
executed and why?
(x) What is the difference between the two methods nextToken() and [1]
countTokens( ) of StringTokenizer class ?
Question 2
(i) Answer the questions related to the circuit given below:
(a) Give the final output of the circuit if, A=l and B=O. [1]
(b) Name the basic gate represented by the given diagram. [l]
Page 3 of 13
HFSP/ISC/CSC/XII/PRELIMS NOV 2024
A X
B
[2J
lean law s:
(ii) Sim plify the follo win g exp ress ion usin g boo
int trial(int n)
{
if(n= l)
retu rn O;
else iftn= 2)
Page 4 of 13
HFSP/ISC/CSC/XII/PRELIMS NOV 2024
return l;
else
return trial(n-2)+ trial(n-1);
}
void perform(int p)
{
int x·
'
for(int i= 1;i<=p;i++)
{
X'-lt ial(i);
System out.pri nt(x + " ");
}
}
(i)Wha t will the function trial() return when the value of n is 4? [l]
(ii)Wh at will be the output of the function perform() when the value [1]
ofp is 5?
(iii) In one line state what the function trial() is doing, apart from [1]
recursion?
SECTI ON-A
Answer any two questions.
Question3
A provisional store announces a special discount on all its products ~s a
festival offer only to those who satisfy any one of the followmg
conditions:
Page 5 of 13
HFSP/ISC/CSC/Xll/PRELIMS NOV 2024
Output
X Denotes eligible for discount [ 1 indi cate s
YES and 0
indicates NO in all cases]
a) Draw the truth table for the inputs and outp
uts give n abo ve an wri te (5)
the SOP expression for X(E,R,S,C).
b) Reduce X(E,R,S,C) using Kam aug h's map .
Dra w the logic gate diagram for the reduced [5]
SOP exp ress ion for
X(E,R,S,C) using AND , OR gates. You may use
gate s with mor e than 2
inputs. Ass ume that the variables and their com
plements are avai labl e as
inputs.
Que stio n 4
a) F(P,Q,R,S)= P'Q 'RS ' + P'Q RS' + PQ' R'S
PQR'S + PQRS' + PQRS
+ PQ' RS' + PQ' RS +
[5]
Use Kamaugh map to reduce the given function
Fus ing the SOP form.
Draw a logic gate diagram for the reduced SOP
form . You may use gate s
with more than two inputs. Ass ume that
the variables and thei r
complements are available as inputs.
Page 6 of 13
I
Questi on 5
(i} From the logic circuit diagram given below, name the parts (I), (2), (3) [ ]
and fmally derive the Boolea n expression F and simplify it: 4
(11
A
8
(ii) A_3 to 8 decode r contains 3 inputs denoted by A2, Al and AO and 8 [2]
outputs denoted by DO, D1, D2, D3, D4, D5, D6, D7. Write the minterm
representations for D4 and D6.
(iii) Following is the circuit diagram of a full adder. Redraw the circuit [4]
diagram by adding missing logic gates.
A
(i) S um
B
C_ ,n
--=-........-
(Ii)
L ( Ill) -~
(iv)
_I
Page 7 of 13
4
HFSP/ISC/CSC/XII/PREUMS NOV 202
SE CT IO N- B
Answer any two questions.
the problem.
way that it clearly depicts the logic of
Each program should be written in such a m
This can be achieved by using mnemon
ic names and comments in the pro gra
uired.)
(Flowcharts and Algorithms are not req
a.-
The programs must bC' written in Jav
[10]
Question 6
cul ate the sum of the fol low ing
A ~lass Ser ies Sum is des ign ed to cal
senes:
(n- 1)!
Su m= x2 / 1! + x / 3! + x /5! + ... x
6 0
4 /
giv en bel ow :
Som e of the me mb ers of the cla ss are
: Ser ies Sum
Class nam e
Da ta me mb ers /in sta nce var iab les:
Me mb er functions:
SeriesSum(int xx, int nn) : con stru cto r to ass ign x= xx and
n=n n
dou ble find fact(int m) : to retu rn the fac tor ial of m usi ng
the rec urs ive tec hni que .
y
double find pow er(i nt x, int Y) : to _return x rai sed to the pow er of
usm g the rec urs ive tec hni que .
voi d calculateQ : to cal cul ate the sum of the ser ies
by inv oki ng the rec urs ive
fun ctio ns res pec tive ly
voi d displayQ : to dis pla y the sum of the ser ies
Page 8 of 13
HFSP/ISC/CSC/XII/PREUMS NOV 2024
Question 7 [10]
A class Mixer has been defined to merge two sorted integer ·arrays in
ascending order. Some of the members of the class are given below:
Page 9 of 13
HFSP/ISC/CSC/XII/PRELIMS NOV 2024
[10]
Question 8 •
h ther if both the words contain
• are
T o words are called anagram of eac
w b th are arrange m
o
FoIIowing
d . different order.
the same_letters ut ey hich are anagrams of each other.
some pairs of the words w h wolf fowl .
Hear, hare
:o
heart, e~rt t two words i~ lower case and check
Design the class Anagram i:pu Th member functions and data
if they are anagram of eac. ot er. ~
members ofthe class are given below.
Class Name :Anagram
Data members/instance variables: .
str 1, str2 : stores the two words tn lower case
Member functions :
Anagram() : constructor
void inputQ
: Input two strings and assign it to
strl and str2 respectively.
void charArray()
: Creates two char arrays stl [] and st2[] for the
two strings resp.Call sort(stl) and sort(st2) to
sort the char arrays. Call check (stl,st2) to
check whether the given strings are Anagram
or not. Display appropriate messages for the
same.
,
void sort(char st[ ]) : Sort a char array in ascending order using
any suitable technique.
baolean check(char st!O, char s120): Check whether both the arrays
have same length and same set of characters.
Specify the class Anagram giving details of all the functions mentioned
above. ~reate one object in the main( )method and call the methods
appropriately.
Sample input
Enter two strings
wolf
fowl
Output
Anagram
Page 10of 13
r
SECTION C
Answer any two questions.
Each program should be written in such a way that it clearly depicts the logic of the problem
stepwise.
This can be achieved by using comments in the program and mnemonic names or pseudo
codes for algorithms. The programs must be written in Java and the algorithms must be
written in general/ standard form, wherever required / specified.
(Flowcharts are not required.)
Question 9 [5]
A super class Record contains names and marks of the students in two
different single dimensional arrays. Define' a sub class Highest to display
the names of the students obtaining the highest mark.
The details of the members of both the classes are given below:
Page 11 of 13
\ I
The super class, main function and algorithm need NOT be writte n.
Question 10
[5]
A Circular queue is a linear data structure which work s on the princ
iple of
FIFO, enables the user to enter data from the rear end and remo ve
data
from the front end with the rear end connected to the front end to form
a
circular pattern.
Define a class CirQueue with the following details:
Class name : CirQueue
Data memb er/ins tance variable:
cq[] : array to store the integers
cap : stores the maxim um capac ity of the array
front : to point the index of the front end
rear : to point the index of the rear end
Mem ber functions/methods:
CirQueue (int max) : constructor to initialize the data memb er
cap=max, front=O and rear=O
void push(int n) : to add integer in the queue from the rear
end if possible, otherwise display the
message "QUE UE IS FULL "
int pop() : removes and returns the integer from the
front end of the queue if any, else
returns -9999
void show () : displays the queue elements
Page 12 of 13
f HFSP/ISC/CSC/XII/PRELIMS NOV 2024
(a) Specify the class CirQueue giving details of the functions void
push(int) and int pop(). Assume that the other functions have been defined.
The main function and algorithm need NOT be written.
(b) How is a linear queue structure different from a circular queue
structure?
Question 11
(a) A linked list is formed from the objects of the class: [2]
class Node
{
int number,
Node nextNode;
} . .
Write an Algorithm OR a Method to add a node at the end of an ex1stmg
linked list. The method declaration is as follows:
void add node (Node start, int num)
(b) Answer the following from the diagram of the Binary Tree given
below:
[1]
(i) The root of the tree.
[1]
(ii) Left subtree
[1]
(iii) Inorder traversal of the tree
*******************
Page 13 of 13