Adobe Scan 10 Dec 2024
Adobe Scan 10 Dec 2024
c h ool
Pr'i' U onrd F,11m in111l on 2 0 2 4- 25
C:om pu t i'r ~d,·n ,·..- I h c or) l'n p c r - Grnu p 4
C ln,s "-11
Fu ll :\ l nrl.., : 7 0
Time :3 hour- .
Purr I
(20 :\ ta r !...~)
(All q11t•stio11~ urc cm11p11/:wry)
QUE STIO N 1
11 I ·' "" r11 0 11 : \ cl.1.s , that 1mplcm,.,nh .lfl i111crfacc muM implem
,.,nl all o f 1b rnctho J, Il l
R,·:.-n nin2: It j d:i" doc, not implem ent :111 method , . it can ~till
be in~tuntimcd .
A) lloth .1"cruu 1, and reasot11ng arc 11ue.
8 ) Both a,~nio n and reason ing arc fobe.
C l 1 he as,cr11on 1> ,rue. hut the rea5on mg i, false.
Dl 1 he :i,;sc·rtion i, lulse. hut the reason ing is true.
iii) .b , l'rtion : The time complt:~it~ for in;,cni ng a node :n the begmn
iny ofu li11l-.ed h,1 is 0( 11
Rt."11,o nin i:: l hi~ i, bec.1u~e \\C onl~ need tn dmngc .1 le\\ p<llnter
.\ J ffolh J".:rti on jllJ re:ison ing jf.: tru,:.
.-. 111
13) Both a~,c11,nn anJ rcasnn mg are 1',1lsc.
Cl The j ,~,:rtion 1~ tru<:. hul lh.: rea5on ing b false
l) , l he :i,~.:rti ur 1, false. h ut the rea~on ing" true.
i, ) \,w rlion: l"nco.k r-; can on!~ \\ Ori-. "ilh hinar) inputs.
Rcuw ninl!: Thi,- l1111ilaliu11 mak~~ lhcm un~u11able lur oth,:r numl,,. Ill
,r syst.: m,
,, \ 1 B th a".:rtion JnJ r.::iso111ng Jrc true
U t 11<,th a ~-crt 1<>n and n.:a~,,n i ng .ire lals.:.
Cl ·n,c n"cnin n i, true. hut 1hc rca,oning i~ falsc
O I The .1, n ior i, fjl,,:. but the r,:a,on ing b true.
lllffl I.
for(int j - I ,j~<hj-. .p• o)
~} " tern 1>111.prinrln (p):
' :, l t . l •• IICJ' L I I
, J r r1
,.. ... ~ •;r I • :l 11 A1 (( ...
• I l
I;
2
d o u b le y = l n
d o u b le x : ., ?te ( st r 5 ub .
. s tr 1n g ( l ) ) ;
X = X ♦ ?4
'> .
3 •
• ,
• • + y;
re tu rn ( i n t l (X
) ;
p u b l i c s ta ti c
l v o id
~~ in (S tr i ng {\
ar gs )
S tr in g st ~ = "
12 35 ";
S ys ~e m .o u t. p ri
n t {? 5? ) ;
L rl t ( rJ..,-\
Part U
(SO M ar ks)
Se ct io n A
(2 0 Marks )
(A ns we r any two qu
a tio ns )
~ es ti on 3
a ) ?i = n lh c Bo
ol ea n fu nct io n: F(
1) Re du cc •he :ib ov A. B. C.D )= ~( 5.6 .7.
e ex pr es si on by us in &. 9.1 0. 11.14 ,1 5)
oc te t, qu ad s an g 4- va riahlc K map.
d pa irs ) ..,e> ,. & i. 'i,. 6 1"1 sho" ing lhe ,ar io os gr
ou s (i
c .•
P
ii) D ra w th e lo gi c ga 1-t I
te J ia gr am fo r th e re
co m pl em en ts or e av duce d expression. As
ai la bl e as input~. su m e th111 th<! variables
and their
\I \
b l G iv en th e Bo ol
ea n fu nc tio n : r (A ,
- ( A-t-B ~C + D) (A ..- B. C O l
8- C +D )( A+ B.._C"
0
ii) D ra ,, th e lo gi c g at
e di og r:i m for the l"\
!duccd expression. As
co m pl em en ts arc a, su m.: th at the variab\
ai lo bh : a,, in pu ~ .:s n™1 their
II I
3
'
~
1
i
'
\
0¥$tioa ,.
/ a) Dra" rhc losic circui1 ro dl-code the binary numbt-rs
(00 I0.0IO1 .0111. 1000, IOI0.1 100.1 11 0.1111 ). Also stare the hexadecimal
cquivaJ t>nts of
given binlU) numbers.
lhl" • ~ .,, i I I f51
b) Vmf) the follo"in g proposirion is valid using truth lahlr
[JI
A= >(B \ C)= (A=>B ) \ (B=>C ) • rJ.) . ~, µ
c) Fmn, lht' fo llo"ing diagram answt"t' the following
(3\
C
12
11 MUX z
C
IO SI S2
··· 11-
AB
b) Simpli fy the boolean express ion (A+B)(ATB')( A ·-rq
(J J
A sponso r p311llCC .mtcn ds Lo sponso
• · . r a music compan y to invite Bl)un Ada.ms
for a li\e
c) rhe follo~ ing cnten a: . . .
•concert as per
The music compan Y has orgnmz . ed 1·iv.... concerts earhrr and is H'I) c:-r eatl\c
Or .
• The music compa ny .,s very cn:ative Md is highly rated, but has not organiL
cd &n) II\~
concert s earlier Or
Section B
(20 Marks)
(Answer any two questions)
7ESTlON6 (IOI
Destgn a class Duplicate to remove all duplicate characters from the string and find the resultant
string.The details of the members of the class are given below:
C\ass name : Duplicate
Oata members/instance variables:
WYd : stores a String
OW : stores the modified string
/en : to store the length of the word
Methods/Member functions:
Duplicate() : default constructor
void acceptword( ) : to accept lhe string
String remvDup (String,String,int ) : to remove all duplicate characters from the string
and find the resultant string using recursion
void display( ) : displays the modified string along wilh
an appropriate message.
Specify the class Duplicate giving details of the constructor, void acceptword( ), String
remvDup( ) 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 Join has been, defined to concat two numbers numerically (without using any string
operations) and produce a merged number.
Example: The two numbers 65 and 723 become 65723
Input: 65 and 723
Output: 65723
, f ~ . ':t t
.. ..-- .
_,
.
,
. .. ., f "' •
,
"' . .
Cius Naml'
: Join
Data Mem ~~ lnstanc:t Varbiblcs
num
:integer lo store n numhcr
Member Functions/ Mctbod5
Join()
: constructor lo initioli,c tfatn member with
legal initial value
.,,oid rcadNumbcr()
: lo occcpl the in teger number in num
Join JoinNum(Join X. Join V)
: concat the num ber, contained in
parumcterizcd objects X and V numerically (S
Lring
OJ)Cf'lltions :m: not allowed) and produces a merg
ed
numb er and returns lht.: object cont ainin g lhc
merg ed num ber.
"o id show()
: 10 displ ny the merg ed number
and the odd
posit ione d dii;it rrom the merg ed num ber
w11h tm
appr opria te mcs:su~e .
Spec if)• rhe class J o in givin g dem its
o r th e eon~1ruc1or Join () . void rc udN umn
Join Y) and void ~h o ,.,( ). Deli ne th c<( ) . .lo,n~.lo,n X.
e ma.in ( ) func 1ion to creo le nn obje ct and
acco rdin gly 10 enab le the en\\ lhc fun.c\ion s
task.
QU EST ION 8
(10 /
A clas s Swirl cont ains a 20 M::u rix of o
rder NxM . It print s the K ·th elem ent in the
the matr ix. spira l fonn of
Inpu t: arr{}!\ =
lt\ .2. 3. 41
1s.6. 1, s1
(9. 10, 11. 12}
113, 14, 15. 16) J
k=7
Output: 16
Explanation: The clements in spirol order is
I, 2, 3, 4, 8. 12. 16. 15 ...so the 7th e\c:mcnl
is 16.
6
~ n II
An int erf ace SrafT is def
ine d with u me tho d vo id dis
\5\
ina em en tin g em ployee . Cr plo y( ) to print lhc req uir ed
dct ai\ s of the
Staff. Th e cla sse s ha ve 111 eat e the clo sse s wo rke r and wo ges wh ich im ple me
tributes wh ich rep res ent the nt the int erf ace
Woticer and wo rki ng ho urs nam e of the sta ff, b asi c sal
, rar e pe r ho ur and tou il wa ary for c\a s~
con str uct or. ge s or cln ss Wa ge s wh ich
arc SC \ by \l\c, r
h,t erf ac c Na me : Sta ff
MC1Dbc:r Mc t_b od s
Data m cm ~n
Data me mb en
8
hours : to store hours work
rate : to store rate in decimals
9
N : lo store number of columns
k : lo store lho K '1h c lement
Member Functio n/ Method~
Swirl() : construc tor to initiali1,c dota member with
lcgol iniliel vuluc
void read() : to accept the integer numbers and store in mat
void elemen1_ k() : returns the K ' th element in the spiral form of the
metrix.
void show() : to d isplay the K 'th element with an appropri ate
message .
Specify the class Swirl giving details of the construc tor, void read(), int clcment_
k() and void
show(). Define the main() function to create nn object and call the function
s accordingly to
enable the task .
Section C
(10 Marks)
(Answe r any two questio ns)
Questio n 9
/51
A linlced list is fonned from rhe objecls of the class Node. The details of
lhc class Node is as
follows:
Class Node
(
S tring str;
Node link;}
Write an algorithm O R a Method to delete the start/fi rst node containing str
of an existinK linked
list . The prototyp e oflhe method is : void deleteNode(Node first)
~estio n 10