0% found this document useful (0 votes)
391 views26 pages

Pseudocode Book

Uploaded by

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

Pseudocode Book

Uploaded by

VAIBHAV TIWARI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 26
4 CAMPUSMONK ebook [email protected] +919760178789 1. a) °) a) 2 a} cy a) #includesiostream> using namespace std; class Test { statle Int x; public: Test) { x#+ } static int etx) { retumx; } int Test:x=0; intmaing { coutss Test:-g6tX()<<" "; Test t{5]; coulss TestizgetX(); —} Answer #include=lostream> using namespace std; class Point { Potnt() { cout<<"Gonstructar called"; } } int maing) { Point tt; return 0; } Constructor called Compile time error Run time error Blank line #includesstdio.n> using namespace std; int main() for (Int x= 10; x>= 0; xe) 4 Int z= x & (x >> 4); Fe) prinif("%d *, ) oe a) b) ¢) qa) a) b) °) a) b) sc) d) a) b) 6) a) campusmonk.in oon axae Rohe Where are placed the list of processes that are prepared ta be executed and walting? Job queue Ready queue Execution queue Process queue Who among the follewing ean block the running process? Fork Read Down Allof these Answer Which of the following does net Interrupt the running process? Timer interrupt Device Power failure Scheduler process The \u0021 aricie referred to.as a Unicode escape sequence Octal escape Hexadecimal Line teed Which of the following is a valid declaration of a char? char ch = "tea; campusmonk.in ») °) a) char ca = ‘tea’; Bi ‘char ct = \u0223; z har ce = Nitea’s ‘Which of the following Is a valid long literal? ‘ABHAOS? 990023 904423 ‘Oxnfo20L Answer 10, What does the expression float a = a) b) c) a) 1. b) °) a) 412, a) b) 8) 4) 35/0 return? 0 Not a Number Infinity Run time exception ‘Which option is false about the tinal keyword? A final method cannot be ‘overridden in its subclasses. A final class cannot be extended. A final class cannot extend other classes. Be Afinal method can be a inherited. ite Answer Construct post order Transversal for the constructed wee with the given In-Order and Preorder Traversal In-Order: 97 1068 Pre-Order: 6 79 108 910786 976108 891076 981076 Answer campusmonk.in 13. What wil be the output of this, program fragment? inti = 263; putchar(!); a) prints 263 b) prints the ASCII equivalent of 263 ¢) rings the bell 4g) prints garbage aos Answer 14, What will be the output of this, statement? printf (%4d", 9/5); a) 1.8 b) 4.0 ce) 20 d) None of the these Answer 15. What will be the output of this program? #include int main() { inti = 5; printf(“%6d", retum 0; = +ti a) b) sy a ska 16. Which of the following declarations Is Invalid In C language? a) char *str = “campus monk Is the best platform for learn"; b) char su{] = “campus monk is the best platform for learn’; ¢) char str[20] = “campus monk is the best platform for learn"; 4) char] str= “campus monk is the best platform for learn"; campusmonk.in TT. What will be the output of this program? Ainclude enum figia, b, ¢}; enum gif{e, &, fi main() t enum fig hy heb: printfe“9ed", fy); return 0; } a) 1 b) enor: redeclaration of an enumerator ce) h a) 3 Answer 48. What will be the output of this program? main () t (5 <5) printt(“5*) else printl(: NOT EQUAL TO 5") + a) ENO b) 5 6) | d) Not equal to 5 Answer 19. What will be the output of the following pseudo code? Input m = 8. = 6, campusmonk.in iffmen) print m else printn co) 8 nee d) 12 : Answer 20, What will be the output of the following pseudocode? Integer i Seti=3 while(I not equals 0) end while a) 666 b) 656 0) 555 a 4) 654 Answer 24.f the sequence of operations are performed on a stack, the sequence of pop will be? Push(1), Push(2), Pop{), Push 1), Push(2), Pop), Pop(), Pop(), Push(2), Pop(). a) 22112 b) 22122 co) 21224 5 d) 21222 ay Answer 22,In an empty BST, Insert the following elements in a similar sequence. Which element will be at lowest level? 105 95 122 89 97 120 a) 95 b) 97 6) 98 campusmonk.in d) 120 Answer 28, The concatenation of two lists is to be perfarmed in 0(1) time. Which of the following implementation of a list should be used? a) Singly linked list b) Doubly linked list ¢) Clreular doubly linked list d) Array implementation of li ea Answer 24, Which of the following sequence can be obtained in the output (Ia same order) using a stack assuming thal the input is in the sequence 1,2,3,4,5 order? a) 34.512 b) 3.4,5,2,1 ©) 18,234 Be @) 543,12 ia Answer 25. Let A be a square matrix of size nxn, Consider the following program and state the output. G=100 for i= 4 tondo for j= 1 tondo t Temp = Ali) + C Allg] = 4 U0 Ajili]= Temp ~ c Wori= 1 ton do for j= 1 tondo Output (Alp): a) The matrix A itself b) Transpose of matrix A ¢) Adding 100 to the upper diagonal elements and subtracting 190 from diagonal elements of A d) None of the above campusmonk.in Gis: Answer 26. The value of j at the end of the 2) b) ¢) d) execution of the following pseudo code Is? Integer incr( Integer i) ‘Static Imeger count = 0 ‘count = eount +i retum count Main() Integer ij for(statt i from 0 to. 4) iF incr(i) end for 10 4 6 T 27.What is printed by the print a) b) ¢) 4) statement in the program Pt assuming call by reference parameter passing? program P1() { X=10 y=3 Funsi(¥.X,X) Print X Print Y } Funet(X,y,2) { Y= Yes Ze XeVeZ } 10,3 31.3 277 None of these campusmonk.in 28. The value returned by the following function for f(1} is? int Rint n) { ‘static int | =1; if (n>=8) return n; nen +i: fer; retum f(n); } a) b) 6) 4) aaa 29.Find the output of the following pseudo code, Integer n Setn=11 Integer ara] = { 10, 11, 4,2} an(1}=anrft}-arr[3] arri2|=arf2}+arri2] arri3}=1+30r[3] n=arr[3] it(rearr{2)) nent Else nent Endit Printin a) 7 b) 18 «) 22 a2 Answer 30. Find the autput of the following pseudo code. Integer xyz Set x=, y=2, 2=1 it (xty > 8) iF (7> xz) ze7 End if campusmonk.in It 9> x-2) z=8 End if yeyezet End it Print x+y+z a) 31 b) 14 o) az mage d) 30 Q 31. Find the output of the following pseudo code. Integer x,y,z Set x=1, y=8,2=2 it (chy BB xy 8B xAy2) 1 End if Print xey+z, a) 14 b) 13 ) 16 a9 32.Find the output of the following pseudo code Integer p.g,r Set p11, Q=1, 1 Ma"p > 2 1] a>p) If (p>q) pet Else g=t0 Engi Endif Print pratt a) 13 b) 10 15 d) 3 Answer campusmonk.in 33.Fing the output of the following pseuda code: Integer x, yz Set , 210 (Gey) > yx) z=74y if ((ytz) < (ey) ) ys3rx End if za" 11) ay Ene if Printx + y +z a) 22 b) 24 c) 26 d) 28 34, Post order traversal of atree-is: VR TSU QP Which of the following vertices will occupy positions 2 and ® eo © eee S828 xenw eo. <4070 Answer 95, Which cannot be the number of vertices in a full binary tree? a) 3 b) 7 ©) 15 4) 30 Ansivet campusmonk.in 36. Sam sorts an array by repeatedly swapping the adjacent elements it they are in wrong order. Identify the sorting technique used. a} Merge Sort b) Selection Sort 6) Bubble Sort d) Insertion Sort a 37. What will be the output of the following pseudocode? Integer a, b, & Set b = 10, Ht (0 asa-1 else =1 38. What will be the output of the following pseudocode? Integer a Siring str’ Set siri = "momo" For (each a from 1 to 2) Strt = strt + "mm" End for Print (stringLength (str1)) a)? by 4 6) 6 ae ae nen Answer campusmonk.in 39. opr ne a) b) cy a) 40. b) cy a. a) b) ¢) a) Consider a stack of integers. The stack Is allocated 7 memory celis: STACK: 12, 34, 66, 79,_, Now consider the operations: PUSH (STACK, 8) PUSH (STAC, 54) POP (STACK, ITEM) The above operations should be performed in which of the following sequences, such that no overtiow or underflow situation occurs: following - BP ASC A> BC CoB>A Only 1 Any of them . Only 2 See Only 3 a Answer Find the output of the following pseudo cade, if function is called for xe and y=4. Integer fun (Integer x, Integer y) IF(y> x) return 14 fun (x, y=1) End if retum x +4 End function fun) 5 “15 14 2 String strt = “Abpcdeffghillkimnnooo” Print countVowel(strt) + countConso(stri+str1) + countVowel(str1+str1 +str1) 49 42 56 35 Answer 42. a) b) e) dq) 43, campusmonk.in Find the output of the following pseudo code, iffunction is called for a=1 and bad, Integer fun (Integer a, Integer b) a= (ata) &(ava) b= (ara) &(aea) retuna+b End function funt) 7 a 0 aye 6 a Ansiver Integer a, b, & Seta =4, b=5, c= 3 asatb Printa+b+c 20 25 30 35 Answer |. For k= 3 || Jed Integer func(Integer k, Integer |) It (kequals 1 or k equals 0) Return 1 Else Return funotk-1, j-1) + fune(k-2, J+3) Eng it End function fune 1 2 3 4 ‘Answer campusmonk.in 45. Integer xyz x=-3, y=0 M(y-2<2) For(each z from 0 t0(3-2)) X=K+(y-3) End for Ena 1) For(each z from 0 to(3-2)) xext(y+5) End for End if Print x+y a) 1 b) 2 e) 3 my 4 46, dinclude intmain() { inta = 11, b=4, ¢=3; printf"%ed %d", b,c); return 0; t a) 14 b) 24 c) 34 a d) 44 ae Answer 47.For a B. tree of order 6, to be a multhway search tree, each non root node has at least haw many Non empty Children? a) 3 4 c) 8 6 Answer campusmonk.in 48, Evaluate the given postfix expression: 12+3'42-31+*- a) 3 b) 1 ) 0 a2 49, If you are using bubble sort to sort th given numbers in ascending order, then find out the minimum number of swaps required, 10,7,5.8,9 a) 7 b) 6 co) 5 dj) 4 Answer 50. Find out the array representation of the given min-heap, if the value 25 Is inserted in it, 10, 18,30,40,50,100 a) 10,15,25,50,40,100,30 b) 10,15, 25,40,50,100,30 ¢) 15,10,25,40,50,100,30 a) 10,15,25,40,50,30,100 Answer 51. Which of the following Is not an array representation of max heap? 1. 31, 27,23, 17, 13, 11 2. 10,5,3,2,4 3. 12, 15,17, 18, 19 a) Only 4 b) Only 3 ©) Only 2 and $ d) Only 1 and 3 campusmonk.in For(each c from 4 to 7) a=(d+8)ea End for anata Printaeb ay 122 b) 127 o) 118 gd) 131 53. What will be the output of follawing pseudocode? function val; Integer return (0) end-function function maln() int x=val(10) display x end-function a) oO b) 1 oy 2 a3 5d, What will be the output of following pseudocode? Set integer y=0 for z=0 to 4-1 step1 do display ~ y end-for a) -3-1-0-2 b) -1-3-4-2 co) -2-4-1-0 oy d) 12-34 a 55. What will be the output of following pseudocode? for x=0 10 27%7 step 1 do campusmonk.in display x end-for a) 6453210 b) 0123456 ¢) 1265340 Bye d) 0612354 Answer 56, What wil be the output of following pseudocode? Set integer array=[2,4,0,1,6,0] Set integer res=[2Varrayl4]; display res a) 0 bd 6) 2 d) 3 57. What will be the output of following pseudocode? while(1*4"4== 4°44) display false break endwhile a) 4 False b) 3False c) 2False Ica] d) 1False Answer 58, How many times will the loop execute? for val=0 to 3 do val=2"val val - endfor a) -1 b) 1 ¢) Infinite Loop aye d) Infinite 5 ‘Answer ‘campusmonk.in ‘59. What will be the output of following pseudocode? ‘Set integer a=1 ‘Set integer b=-1 ‘Set integer c=0 display (a orb and ¢) ao by t 2 ge Answer 60. What will be the output of following ? pseudocade’ for i=0 to 6'5 step 1do display i end-for a) Ot by 12 <) 23 334 64, Set integer m =3 Set integer n=5 Syetch(mimten) Caset: m=m-n Case2: m=men Cage3: m=m"n ‘Cases: m=min Default: mam End switch Display m at bb 2 3 a4 campusmonk.in $2. Integer ep, 99. rr ‘Set pp=3. qq=7, 1=8 pp =0 err If (per) < (re-pp) 99 = (99 + mt) +pp Endit Print ppeqger R 4 36 B aoee 6a. Integer a,b,c ‘Set a=, B=7, o=8 (o-a) < (e+) ox eb os (a*T}ea ae (ceb}*e Endit Print arb+c campusmonk.in 65, Integer funn(integer a. integer b, integer c) 70. b=3, c=8 a=(5+7}+0 i#(e"7) < (B+e)) aa lec bad+0, atceb End it Print sebec » uM 32 a aeow 66. Integer p,q. r ‘Setp=7, 93, r=4 {ger BB (g*3)<3) a= (Se1}4r Endit Print psqer W 4 10 2 aeow 67. Integer abe ‘Seta=6, b=4, 0=7 feeb || (G+5}6) Ifiz>=y AND 2>=x) sears ene Frnt count 3. Find out the largest number Sr scene b. Find out the smallest b. 0123336008 comes & 01212688 . opo00sese 89. ints. Seta=t,c=t . Forjeach b trom(a82}t0(428)) ; b=b>>t Riper Print bes Int a=0 a : BZ 2 «3 a4 Answer 90. Setm=t Int a(3}={t.2.03 For each | from Oto 2 94, find the output of the following penal code. Print m a 10 public class Main: bit c 12 { a 13 public static void main(String[] args) { int 8: 4. Setm=2 Int af3}={1.1.3.1) For each j from 1to 3 } } memsati] | Nothing will be printed Print m 5. Symbol not found error ‘campusmenk.in cc. Runtime error d. Compile time error 95. John wants to go to different Jecation of a city in which he is. currently in. He has listed all of them. However, he wants to visit one location before visiting the other. Wnat application of graph he uses to determine that locaton? 3.DFS b.BFS ©. Djikstra’s aigorthm ©. Topological sorting Answer 96. Which among the following is 2 server-based model? a. Request for information b. Cloud i ¢. Total cost of ¢. Data validation routine pe Linked list Queue aeee campusmonk.in ‘98. vhat is the output of the following code? class Main) { public static void main(String args{)) 4 inti, j, x=0; for(i; i<8; ++) fore: jx8: e+) { ae(teH) ‘System out print(x): break } ‘System out print(x): } a b. © d ‘99. Find the postfix of the given Infix expression: 11420/5°(20-15)*8*5 a. 11.20 5/20 15-6°5"*+ b. 11.21 5/20 15+6*5**- ©. 11.22 5/20 156°5"*- d. 2011 5/20 15+5**+ campusmonk.in ccampusmonk.in 100. Find the pre order of the { given tree. i int cet) A ifx==0.5) t \ ‘System out printixet); 8 c ‘System out printi2): my mA } DE FG } \ \ a Ho ®. &. ABDEHCFIG a b. BASUEKDHS © AABSBLIKDMSD d. CAMPUSMONK 101. Which combination of integer variables 3, b and o makes the variable m get the value 4 in the following expression? m= (2>b)?((2>¢)7a:e)-((b>e) 7c) 856, D3, o=8 . amd, b=S, C=3 355, bed, o=5 am}, bed, C= aoem 102. _ what is the mathematical function used to round off 6.23 to- 7? ‘@ floor(6.23) b. cel6.23.7) & floor(6.23,7) 4. cei(@.23) 103. Find the output of the 405. Find the ofthe code following code. snippet —— public class Main Integer funfint a, int b) t if (a B&B) 1 bt public static oid main(String args) ieee et) campusmonk.in campusmonk.in Return 0 { Eno fenczon fun int m=t00. b 4 § t d 13 atm 106. Find the output of the code einen, Snipcet, Integer n Setn=11 Integer arr{4]={10,19,1,12} 107. Find the output of the code: snippet. Integer xy.z ‘Setx=1, y=8, Iaty tary wy | im xy*z) forget: x<=10; xes) 108. Find the output of the code { snippet. int main() — eampusmenk.in campusmonk.in continue: a. No output printed b. 0123.....85535 ae © 0123... 32767-32788 - break. 3276810 strate") 2. inifinite loop ps 7 , } } 113. Find the output of the code a. Infinite times ‘stippet &. 11 times i int mand © Otimes 0. 10 times int 2=500.b=100, c; if(la>=400) b=300: 200; Print %d%e.b.c) feu a. 200200 b. 100200 e100 Garbage value d. 300 Garbage value OEDE+E ae 2 312 b. 288 « 302 d 208 412. Find the output of the code Sha a Sincludecstdio.h> 415. Seven elements - AB.C.D.EF andG are pushed int main) ‘onto a stack in reverse orderLe. { starting from G. the stack is | popped five times and each unsigned int i=65535; ‘element inserted into a queue. Two: while(ies '= 0) elements are deleted from queue & pushed back onto stack. Now one print ted, +43); element is popped from stack. sonarn ‘Wich isthe tt popped element? } BB cE campusmonk.in 116. the sequence of operations are performed on a stack, the sequence of pop wil be? Pusn(t), Push(2), Pop). Pusn(t), Fush(2), Pop(). Pop), Push(2), b. 22122 e@ 21221 a 21221 117. Consider the following operations performed on a stack of size 5. Push(a), Pop(). Push(t). Push(c), Pop, Push(d), Pop0. Pop(), Push(e) Which of the following statements is correct? . Underfiow occurs . Stack operations are performed smoothly Overfiow occurs None ao 118. Consider the tree with given post: sb-od"+ The labels on the nodes to 7 will be?2 119. Convert the following infix expression inte pref expression. infix expression: (A+B)"(C+D) 3 ABSCDe campusmonk.in Db. +eA°BCD co. *ehBeCD d, ABC*+D+ Answer 120. Which of the following relation is correct for a binary ‘Search tree? a. Parent node> Right node> Left node 2. Rightnode> Parent node> Left node, c. Ripht node> Left node> Rightnode fe d, Parent nede> Left node> Right node 4a. In an empty BST, insert the following elements in a similar sequence. Which element will be at lowest level? 105 95 122 G6 07 120 3 3 6 oT c. d. 120 Answer 122. Find the output of the pseudo code. Integer a. b,c ‘Set a=5, b=3 For( each ¢ from 6 to a) if(a) a=e-1n End if fb) bebt End if End for Print seb a4 b. 6 campusmonk.in 123. aoe =o find the output. integer 2, bc ‘Set b=10, a=20, c=20 Find the output. Integer a, bc. 5 Set a=16, b=23, c=7 $= (a+b)B&(a-5) || (a*c) iHfa not equals 0) Print sea-b*c 125. Find the output of the following code. a=4, b=8 Integer funn(Integer a, Integer b) 2) End funeren funn) campusmenk.in aoe one 3S 126. Find the output of the following code. Integers, b, ¢,¢,2 ‘Set 3=20, b=0, c=88, d=30 e=cmods Brasb+e d=c mods Print d a0 b. a7 ce 14 a 12 427. Find the output ofthe following code. Integer a, b,c, sum Set sum= sebec Hi{(sum EQUALS 180jand (a NOT EQUALS 0) and (b NOT EQUALS. 0) and (c EQUALS 0}) Print "Success" Else Print “Fait 3. Success b. Fail 2. 0 ad Answer 428. Find the output ofthe following code. Integerx, y, Z Setx=0, y=2, 2=1 If (y>8) lf (7>xez) zt End If (>x-2) 20 End # yeyezet Ent campusmonk.in Print xeyaz ait bit int x=2.y=0, int Z=(ye+)?y==188x :0: printi("Sadin*.z) return 0: campusmonk.in retum 0; ae ee s 432. Find the complete of the following code where the output is ara 433. Find the output ofthe following code. Sinclude e main(void) inti: forint JO; jx; j++) i(i==0.1) { print('Be a programmer’): } ee { pnt ‘Leaming ¢"}; } printitadin’, +4); retum 0; 3. Bea programmer! 8. Bea programmerd campusmonk.in Learning cd Answer 134. ‘Which of the following: cannot be checked in 3 switch case statement” 3a. Char b. Float Int Enum 135. find the output of the following code. int main() { char ch: iffch = pringf(* printf No Outputin’): ese printi"Outputin’): return 0: i eampusmonk.in 437, —_find the output of the following code. ‘#include void maint) { int a=12. b=30 earner. 386): 488 1 4 Error pp oe a 138, find the output of the following code. Sincludestdio.h> void main() intx printf(tedin, 453): printf(edin, 4-3): printf(edin, -4%3): printi(“tedin, 44-3); return 0; } 114-1 141-1 ope 438. —_ find the output of the following code. #include void main) { int. a=20, b=40. x m(si=10)68(6=50): printi"x=% din’, x): return 0; } a bo e 2 g ® i campusmonk.in 20 owe campusmonk.in Sis) a 48 nde Answer 143. find the output of the following code. Sinclude void maing) 144. What is the value of 587.071%2? 20 b. 263 co. 263.835 d. Error 145. why is the main () in java state? a. JVM cant create objects: b. main() can't be changed ©. Class has the access to main d. Objects can directly campusmonk.in Answer 8A 10.4 vA 438 558 e7c 788 208 102.0 1148 128.0 1384 oo 20.0 RA 44.0 554 688 738 018 10.0 21A BA 45a 57D campusmonk.in 11.C8D 228 23.0 MA 360 460 47A 58.C 508 69.Ans in link 7A BOA 224 81D 828 93.0 O44 103.C 104.D 105.8 108.0 188 1168 1178 1188 127.8 128.0 1208 130A 190A 1400 1410 1420 campusmonk.in

You might also like