Computation Thinking PYQ Book 2024
Computation Thinking PYQ Book 2024
4F(A or (8 and ¢ and 0)){ count = count + 2 1? AFCA oF not(B or ¢ or 0)){ Count = count + 1 , Procedure miniSum accepts three numbers as parameters and returns the sum of two smallest numbers. Choose the correct code fragment to complete the procedure. 1 Procedure winisum(a, ®, ¢) ‘sun = 0 {f(a > € and a> ot Sum Bsc1 elset 1 else{ 2 if(e > ¢ and 8 > ad{ 2 Sum = Ass 3 sum ade 3|} . ’ 4 if(C > Band B > Ad{ 5 elsef 5 sum = A+ 6 sum A+ 8 <3 7 , s\} 7 v * 1 1f(8 > Cc and B > A){ ipiaieat : Sem Ass 2 Sum = A+B 3} sles 4 else 4 if(c > Band 8 > a){ 5 Sum = A+B 5 Sum = B+ 6|} s|> ‘The following pseudocode is executed using the “Words” dataset. What will A represent at the end ‘of the execution? 2 sum = 0, count = ° 2 while(table a has wore rows) { 5 ead the first row x fn Table 1 © Count = count + 2 5S Suet = Sum + x.Lettercount nove x to Table? ) © = sent / count 1D Sums = 0, Counts = 0, A= 0, #0 LL whifTe(table 2 has more rows)( head the First row x in Table 2 1 counts = counts + 3 Le Sus» Sunt 4 x.Lettercount 2S koword ands th a full st09){ is C= Sums / counts wv ite < ot * Anked 8 ? » Suns = 0, counts = 0 , wove x to Table 1® Number of sentences with average letter count more than the average letter count of dataset ~ Number of sentences with average letter count less than the average letter count of dataset ® Number of words with average letter count more than the average letter count per word of dataset ® Number of words with average letter count less than the average letter count per word of dataset ‘The following pseudocode is executed using the “Olympics” dataset, Procedure doSomething accepts a table of rows which contains rows of the same player. Assume that the player has won at least two medals and only one medal in any year. What will (B - A) represent at the end of the execution? | Procedure dosonething(Table T1) A= 2030, 8 = 2030 2 whfTe(Table 1 has more roms) ( 4 Read the first row z from Table TL 5 Af(z.vear < a){ Bea Aw Z.vear ) ° Af (2.vear > A and 2.vear< 8){ B= Z.vear u , 2 wove the row z to Table 12 a } a return((B - aD) 5 end dosomething ¥ Year gap between first and second medal won by a player * Year gap between first and latest medal won by a player ® Year gap between latest and second latest medal won by a player ® Year gap between first and second latest medal won by a playerThe given pseudocode is executed using the “Olympics” table. What will count represent at the end of the execution? Assume all players have distinct names. L count + 0 Paén(Te(Table 1 Pas more rows) ead the fest row x (Table wove x to Table? vhile(Table 1 has more rows){ ‘ ead the first row ¥ dn Table nove Y t0 Table} ' 1 0.name = ys) ’ {FO national ty — Y.watforalty snd x.madal — v.madal)( 10 count = count #1 x , x , ul] 9 MM wove aT? rows frow Table 3 to Table a '* The number of pairs of players having the same nationality or the same medal. ‘¥ The number of pairs of players having the same nationality and same medal. The number of players having the same nationality and same medal '§ The number of players having the different name but of same nationality. The given pseudocode is executed using the “Shopping Bilis” dataset. frac stores the ratio of the number of customers who purchased both “Bread” and “Milk” to the number of customers who purchased “Milk”. Choose the correct code fragment(s) of procedure hasltem to complete the pseudocode. (Assume there is at least one customer who has purchased “Milk’). simot = 0, tome = ¢ siete # as ware cart end the top cart fm rile §(fOaszemce, i) ‘ tusttenn, “tree")( owt = teat ©c= alse whi la(eard ¥ has more (tems) ( Read an ttem z from itemist of card ¥ $4Cz. Tem = a © = True ? elset Co False ) Remove 2 from rtemcist of ) return¢c) c= False while(card ¥ has wore tress) ( Read an item 2 from Ttemist of card ¥ A¢Cz.2t0m = AL c= True ) nenove 2 from temist of ¥ y return(c) = True white(card ¥ has more ftems){ Read an item z from Item ist of card ¥ Af(@.tem = 00 c= True » Remove 2 from ItemList of ¥ » return(e) c= True whiTe(card ¥ has more Stems) ( ead an iter 2 from trem ist of card ¥ [email protected] = at © = False » Remove 2 from ItemList of ¥ ) return moxie)The given information represents a "Words" dataset and it may have some mistakes with respect to the sanity of data. Identify all rows with such mistakes. Rowne. Field Value Row Card number oye Row2 Word 1 Row3 Part of Speech "Noun" Rows Letter Count 5 ‘¥ Row 1: Incorrect data type of card number ¥ Row 2: Incorrect data type of Word * Row 3: Incorrect data type of Part of Speech * Row 3: Invalid value of Part of Speech * Row 4: Incorrect data type of Letter Count Row 4: Invalid value of Letter Count The following pseudocode is executed using the “Scores” dataset. At the end of the execution, ‘count captures the number of pairs of students having either same gender or from the same city ‘but not both. But the pseudocode may have mistakes. Identify all such mistakes (if any). Assume that all statements not listed in the options below are free of errors. 12 Procedure findPair(x, ¥) fee, B A= False, B = True 2 whilecrable 1 has more rows) ( ié|| Aeoccsmkcrows v came 3 Read the first row X in Table 2 . ame 4 Move X to Table 2 a } 5 whiTle(rable 1 has more rows){ ae | | itceictaypiee oe esctey omit 6 ead the first row Yin Tablet pealtee Move ¥ to Table 3 alla s ON Cie CORE TR ES CAS 20 4f((A and not B) and (not @ and 8)){ o } 21 return(1) 10 Move all rows from Table 3 to Table 1 } u|} 23 return(o)¥ Line 13: Incorrect initialisation of B ® Line 18: Incorrect update of B © Line 20: Incorrect condition ® Line 21: It should return(0) The following pseudocode is executed using a dataset similar to the "Words" dataset, based on the following paragraph. "Surrounded by nature, Susan often takes a stroll, savoring the soothing sounds of chirping birds.Such moments underline the significance of embracing simple joys in life. Rustlings in the trees suggest squirrels beginning their day, searching for sustenance. Surely, the beauty of a sunrise holds unparalleled magic.” count = 0, flag = True whi le(rable 1 has more rows)( Read the first row x in Table 1 4 Move x to Table 2 s 1#¢Flag)4 ‘ Af(ast letter of x.word — "5" ? if (2nd Verter of X.Word == "u'){ 8 count ~ count + 1 9 ) 10 } un) } 2 flag < False 13 if(x.word ends with full stop){ 1“ flag = True 1 } 16} What would be the value of count at the end of the execution of the above pseudocode? Assume that upper case and lower case are ignored during comparison of letters. 3Qualifier May Term 2024 The gen information represents "Scores" dataset and it may have some mistakes with respect to the sanity of data. Identify all rows with such mistakes. It isa Multiple Select Question (MSQ). Row no. Field Value Row! Card number 1 Row2 Name Harish Row 3 Gender M Row4 Date of Birth 30 November Row 5 Mathematics 62 Row6 Physics 145 Row7 Chemistry 1 Row8 Total 398 * Row 1: Incorrect data type of card number Marks: 3 Row 4: Invalid Date of Birth ¥ Row 6: Physics score is out of range ¥ Row 8: Total score is out of range The given pseudocode is executed using “Scores” dataset. Let B be a positive integer. What does the procedure DoSomething compute? Procedure Dosonething (8) ©=0,0= 101 whileCrable 1 has more rows){ » ead the first row x fn Table 1 if xPhystes > © c= physics ) $f 0x.chentstry < 0)( 0 = x.chenistry ) wove x to Table 2 Af(€ - D>» Wf return (False) » return(trve) End Dosomething Marks: 4* Returns “True” if and only if the difference between the maximum Physics marks and the minimum Chemistry marks is at least B Returns “True” if and only if the difference between the maximum Chemist marks and the minimum Physics marks is at most B 'Y Returns “True” if and only if the difference between the maximum Physics marks and the minimum Chemistry marks is less than B * Returns “True” if and only if the difference between the maximum Chemist marks and the minimum Physics marks is less than B The following pseudocode is executed using the “Scores" dataset. What will A represent at the end of the execution? ° eee Marks: 4 2 whilerfte 1 has wore cards)( 2 Read the top card x from pile 1 4 he ke Stese90 wove x to pile 2 6|t 7 Procedure ‘srnseq(x) © $F GxPhystes < xamathematies){ ° if satnematics < x.cheststry)( 0 retuen(a) 2 , 2} + return) Und fete ¥ Number of students with highest marks in Chemistry and lowest marks in Physics. ® Number of students with highest marks in Mathematics and lowest marks in. Physics. * Number of students with highest marks in Physics among the three subjects. * Number of students with lowest marks in Physics and highest marks in The following pseudocode is executed using the “Library” dataset. 1 k= 0, count = 0 2 whfle(rable 1 has wore Fema) { ‘ead the first row x from Table 1 6 Afevear > OE 3 As xvear “| 9 ove x to Table 2 1 venflecrable 2 has more rows){ ‘ead the first row ¥ from Table 2 Sfeycvear t= ADC count = count + 1 ) move y to Table 1 5|} What will count represent atthe end of execution of the above pseudocode?* Number of books which were published after the least recent year. ® Number of books which were published in the least recent year. -¥ Number of books which were published after the most recent year. Number of books which were published in the most recent year. The following pseudocode is executed using the "Words" dataset. At the end of the execution, A ‘captures the number of nouns with letter count at least four and at most eight. Choose the correct code fragment{s) to complete the pseudocode. It is a Multiple Select Question (MSQ). ane swiecrable 4 has wore card) ead the Fest row x fron Table 1 sflOhechsomethingtx, 4, 9)( acaet ) nove x to Table 2 ay 9 Procedure chechsomething(v, C1, €2,) 10 (r.Partotspeech m- “Noun")f ul) baat “ retura(False) voy Ls tnd chechsonet hing 2) SCL oe v.Lertercoune and y.Lertercount a G2), retuen(trve) 1 et eturn(False) ) $F(CL ce Y.Lettercount and v.tettercount <= @)¢ return(reve) 1 eset return(False) 1 2) S#(GL o Y.tertercount and y.tettercount <= €2){ 2 ‘return(alse) 1} oy ee leet s return(true) soa S€(c1 > y.aeweerceunt or v.aettercoumt > @){ reterecralse) ) at return) )The following pseudocode is executed using the "Words" table. At the end of the execution, count stores the numberof pais of verbs such that both verbs have either the same letter count or both end with a full stop, but not both. Choose the correct code fragment to complete the pseudocode. 1 count 2 whleCrable 1 has more rows)( 5 ead the First row x in Table 1 © neve x te Table 2 5 4f0x.Partofspeech a= “verb">{ 6 hlTeCrable 1 has more rows)( . ° ead the first row ¥ in Table 1 wove y to Table} 2 ocumearcant = yeeren ) cant comes t a) set oir nd sod et 0h 4 AN OD (| emas came 4 , ‘) ox cartercnmt — v.ceeareeet)| count = count +b ) tO. naed and Yond end wth a fal staph out» cent 1 ) « 2) Houvet and vmod end witha FN) aly Antrim ¥ aero ‘ cot = ent ’ 0 ol fut stInthe Shopping Bis" dataset, the procedure countBils counts the numberof bis from Big ‘Bazaar with total amount more than the average total bil amount. Assume tht the variable Avg holds the value ofthe average total il amount. Choose the correct code fragments) to complete ‘the procedure. kis Mutiple Select Question (MSQ). 1 Procedure countsiT150) 2 coume = 0 3 whfle(otte 1 has wore eards)( ‘ ead the top card x from afte x : 200 ne 7 4 os BINT the code ove card x to pile 2 ’ ie retura(count), LL end counts tts 2 Ox shopane m= “eigtaraae"Df (4. roLaletM aot > 9 , ‘Coant = count + 1 “| 9 sy 2) A roeatarTamoaae > aNg)( 116, sheppame = "Wi gazane"){ 3 cont = Coomt + “) a o) 2) HfoxToratesTTARCUNE > Ang oF x.shepmame = Mwigtazanr")f 2 count = comtt + 8 yD 1 FO-Toeate Namoone > sng and xShopaad me “Hiptansae”){ 2 count = Coane + 5 ni ‘The following pseudocode's executed using the "Words" dataset. At the end ofthe execution, A ‘represent number of sentences with average letter count less than the average letter count of dataset. identify all such mistakes (if any). Assume that all statements not listed in the options below are free of errors. tis a Multiple Select Question (MSO). 1 Seat = 0, Counet = 0, w= 8 2 wbfle(rabte 2 has wore rows) ead the First row x fn Table 2 out = countt + 1 Sart = Sut + .Lettercount nove x to Table? + © be suet / counet 2 Sons = 0, counts = 0, Aw 0, Co20 | whfle(rable 2 has sore rows)( LL head the first row x in Table z 22 counts = counts + 2 2 Sums = sums + x terrercount Atif Qc.word ends with a full stop){ ry C= Sums / count 6 if > Of v AeaeL u ) » Sums = 0, Counts = 0 |) 9 21 Move x to Table 1 nly ® Line 8: Incorrect expression for B Line 15: Incorrect expression for C Line 16; Incorrect conditional statement * No mistake ‘Two words are said to be conjugate if they fulfil following conditions: © They are different words. ‘© Number of vowels are same in both words. '* Number of consonants are different in both words. For a row X in the "Words" dataset, assume that vCount(X) return the number of vowels in X.Word. At the end of the execution, count stores the number of conjugate pairs. Choose the correct code fragment(s) to complete the pseudocode. It is a Multiple Select Question (MSQ).. 1 count = 0 2 while(rable 1 has more roms){ 3 Read the First row x in Table 1 4 move x to Table 2 5 while(Tablle 1 has sore rows) { ‘ ead the first row ¥ in Table 1 ‘ ° * FATT the code * 19 move ¥ to Table 3 n d 2 move all rows fron Table 3 to Table 1 Bi?)2 AFGword = Y.word) { $F 0c.Lettercount = Y.Lettercount) { {f¢vcount(x) == veoune(¥)){ count = count + 2 ? 2 ff QC.word t= y.word){ AFCK.Lettercount != y.Lettercount){ 3 {f(vcountO) == veount (VD) 4 count = count + 2 ; ) ‘ 2 AfO.word I= ¥.word){ $f(vcount Oo) = veount(¥)){ 3 Af (x.Lettercount ~ vcount(X) = Y.Lettercount! - vcount(y)){ ‘ count = count +1. 5 ’ 6 1 Qx.word ' Y.word){ $f (veount OD = veount(¥)){ ‘4f(X.Lertercount - veount(X) Im ¥.Lettercount - veount(¥)){ count = count + 2 IConsider the procedure mSum as shown below. 1 Procedure msum(a, 8, C) > sme0 2 AF oe € and A >= ODE ‘ sume Bsc 3] 2 6 alse 7 if(8 >= C and B >= a){ ‘ sm Ase : } 0 eset n fm ease 2 ) bl} u return(sum) 15 ind Sum What will be the value of mSum(4,4,2) ? 6 The following pseudocode is executed using a dataset similar to the ‘Words" dataset, based on the following paragraph. “Surrounded by nature, Susan often takes a stroll savoring the soothing sounds of chirping birds. Rustings in the trees suggest squirrels beginning thelr day, searching for sustenance. Surely, the beauty ofa sunrise holds unparalleled magic.” 1| cmt = 0, Ton = tre 2 |ateCable 1 has wre ros) 2 ead the First row x in Table rove x to Tle? secre ‘ Af (ase Tetter of x.word a= 's°)f ? $f Cand eter Of x, word == 'u'){ 5 count = count + 1 * d » ? ul 22 FOcvord ands with FuTT stop) 2 flag = False uo? wD What would be the value of count at the end of the execution of the above pseudocode? ‘Assume that upper case and lower case are ignored during comparison of letters.The following pseudocode is executed using the “Scores” dataset. What will count represent at the end of the execution? 2 count = 0 2 whiTe(Table 1 has more rows){ 3 Read the first row x fe Table 1 4 wove x to Table 2 5 whiTecrable 1 has more rovs)f ‘ ead the First row ¥ in Table 1 7 wove ¥ to Table 3 5 count = count + Findrair(x, ¥) o> 10 wove all rows fron Table J to Table 1 nu? 12 Procedure Findpair(x, ¥) 1 Aw False, 0 = False AF (x.Gender — y.cender) { 8 an true 1%} LAF QX.CItyToun == y.ciryrown){ * Be True » 10 AF((A and &) oF (not A and not #)){ return(1) ? 23 rewurn(o) 24 tnd Adoni % count represents the number of pairs of students having either the same _ | gender or from the same city or both, % count represents the number of pairs of students having the same gender \_ and from the same city. ‘¥ count represents the number of student pairs who either share the same | gender and come from the same city, or who share neither the same gender nor the same city. % count represents the number of pairs of students having the same gender but not from the same city. -