0% found this document useful (0 votes)
48 views13 pages

Comp Prelim 1

Sample isc comp

Uploaded by

printaprintable
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views13 pages

Comp Prelim 1

Sample isc comp

Uploaded by

printaprintable
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

HI RA NA ND AN I FO UN DA

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]

(a) :E( 1, 3, 5, 6,7)


(b) a.b'.c + a.b'.c' +a .b. c + a.b
.c' + a'.b.c'
(c) a.b.c + a.b'.c +a .b. c

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.

Which one of the following options is correct?


- 1S
(a) Both Assertion and Reason are true, and Reason · the correct
explanation for Assertion.
(b)Both Assertion and Reason are true, but Reason is not the
correct explanation for Assertion.
(c) Assertion is true and Reason is false.
(d)Assertion is false and Reason is true.

(iv) Assertion (A): Recursion is implemented using function calls.


Reason (R): Absence of base case leads to infinite recursion. [l]
(a)Both A and Rare true, and R is the correct explanation of A.
(b)Both A and Rare true, and R is not the correct explanation of
A.
(c)A is true, but R is false.
(d)A is false, but R is true.

(v) Assertion (A): The converse of p' => q is q => p'


Reason (R): The contrapositive of p' => q is p => q' [l]
(a) Both A and Rare true, and R is the correct explanation of A
(b) Both A and Rare true, but R is not the correct explanation ~
0
A.
(c) A is true, but R is false.
(d) A is false, but R is true.

(vi) The dual of (X' +l) : (Y' tO) = Y' is:


(a) (X. 0) + (Y. 1) = Y [1]
(b) (X' . l) + (Y' . 0) = Y'
(c) (X'. 0). (Y' .1) = Y'
.. (d) (X' ..0) +. (Y'_.1-) = Y'

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?

public class Excep


{ public static void main()
{
int arr□ = null;
System.out.println("Array length: "+arr.length);
}
}

(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

F= [(X' +Y) . (Y' +Z)] I+ (X' +Z)


e clas s whi ch com pute s and
(iii) The follo win g func tion is a part of som
pow er 'q' (pq). The re
retu rns the valu e of a num ber 'p' rais ed to the
are som e plac es in the cod e mar ked by ?1? ,
?2? , ?3? whi ch mus t
the func tion wor ks
be repl aced by an expr essi on a state men t so that
corr ectl y.

dou ble pow er ( double p, int q)


{ dou ble r = ?1? ;
int c = ( q<O ) ? -q : q ;
if( q = 0)
retu rn 1 ;
else
{ for (int i= 1; i <= C ;?2? , i++) ;
retu rn (q>O )? r: ?3? ;
}
}

(a)W hat is the expr essi on or state men t at ?1? [lJ

(b)W hat is the expr essi on or statement at ?2? [lJ


(c)W hat is the expr essi on or state men t at ?3? [lJ
() are a part of some class.
(iv) The follo win g function trialO and perform
the dry run/working.
Ans wer the following part s give n belo w. Sho w

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?

PART - n (50 Marks)


Answer six questions in this part, choosing two questions from
Section A, two from Section B and two from Section C.

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

If he/she is an emp loye e of the stor e an


d has a service of mor e tha n

ten years OR
• If he/she is a regular cust ome r of the stor e whose age is less than
65 years and is not an emp loye e of the store
OR
If he/s he . . .
is a sem or citiz en but not a regu1arcustomer of the stor e

The inputs are:


E Employee of the stor e
R Regular cust ome r of the store
s Service of the emp loye e is more than 10 yea rs
C Senior citiz en of 65 years or above

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

HFSP/ISC/CSC/XII/PRELIMS NOV 2024

b) F(A,B,C,D)= 1t{O,l,2,3,5,7,9,13) [5]


Use Karnaugh map to reduce the given function Fusing the POS form.
Draw a logic gate diagram for the reduced POS form. You may use gates
with more than two inputs. Assum e that the variables and their
complements are available as inputs.

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

C ---- ---- t--- ---1 I NOT I OR I


(J)
AND I F(A.B.q

(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:

X : to sto re an int ege r num ber

n : to sto re the num ber of ter ms


Sum : dou ble var iab le to sto re the sum
of the ser ies

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

Specify the class SeriesSum, giving details of the constructor(int, int),


double find fact(int), double find power(int, int), void calculate() and
void display(). Define the main() function to create an object and call
the functions accordingly to enable the task.

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:

Class name Mixer


Data members/instance variables:
int arr□ to store the elements of an array
int n to store the size of the array
Member functions:
Mixer( int nn) : constructor to assign n = nn

void accept() : to accept the elements of the


array in ascending order withou t
any duplicates

Mixer mix( Mixer A) • : to merge the current object array


elements with the parameterized
array elements and return the
resultant object (containing sorted
array elements in ascending
order).

void display() : to display the elements of the


array

Specify the class Mixer, giving details of the constructor(int), void


accept(), Mixer mix(Mixer) and void display(). Define the main()
function to create an object and call the function accordingly to enable
the task.

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

HFSP/ISC/CSC/XII/PRELIMS NOV 2024

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:

Class name : Record


Data member/instance variable:
n[] : array to store names
m[] : array to store marks
SIZe : to store the number of
students
Member functions/methods

Record(int cap) : parameterized constructor to


initialize the datamember size =
cap
void readarray() : to enter elements in both the
arrays
void display() : displays the array elements

Class name :Highest


Data member/instance variable:
Ind :to store the index
Member functions/methods:
Highest( .. . ) : parameterized constructor to
initialize the data members of

Page 11 of 13
\ I

HFSP/ISC/CSC/XII/PREUMS NOV 2024

both the classe s


void find( ) : finds the index of the stude nt
obtai ning the highe st mark and
assig n it to 'ind'
void display( ) : displays the array eleme nts
along with the name s and mark s
of the students who have
obtain ed the highe st mark
Assume that the super class Reco rd has been defined. Using the conce
pt of
inheritance, specify the class Highest givin g the detail s of
the
constructor( ... ) and void displa y().

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

You might also like