Section 11.You are doing a survey and need to store the values of responses from your respondents. Thevalues are integers from 0 to 10, inclusive. What is the minimum number of bits you need tostore each value?a. 3 bitsb.* 4 bitsc. 5 bitsd.10 bitse.32 bits2.The string “I love studying for final exams!” is stored in an array of characters called lies. What isthe value of lies[3]?a.‘l’b.* ‘o’c.‘v’d.‘e’e.‘love’3.Consider the following pseudo code. What condition needs to be added at *CODE HERE* for thealgorithm to correctly find the minimum in an array A?Input:A // array of integersn // number of elements in arrayOutput:Min // value of smallest elementMinimum(A, n) // name of algorithmMin = A[0] // initialize min as first el.for i = 1 to n-1if *CODE HERE* thenMin = A[i]endifendforreturn MinendMinimuma.* A[i] < Minb.A[i] > Minc.A[i] >= Mind.A[i] == Mine.A[i] = Min4.Suppose we have a list with variable name myList. The list contains [1, 2, 3, 4, 5]. What will thelist contain if we call myList.append(6) in Python?a.[6, 1, 2, 3, 4, 5]b.* [1, 2, 3, 4, 5, 6]c.[1, 2, 3, 4, 5]d.append is not a valid list method and cannot be used.e.It will return a syntax error.5.Recall Project 4 where you were asked to implement Convolve2D and Scale. Recall thatConvolve2D took a 3x3 kernel K and that Scale used a scale factor scf. If we were to useConvolve2D in our implementation of Scale, what kernel would we use?a.K = [ [ 0, 0, 0 ] , [ 0, 0, 0 ] , [ 0, 0, 0 ] ]b.K = [ [scf, scf, scf ] , [scf, scf, scf ] , [scf, scf, scf ] ]c.K = [ [scf/9, scf/9, scf/9 ] , [scf/9, scf/9, scf/9 ] , [scf/9, scf/9, scf/9 ] ]d.* K = [ [ 0, 0, 0 ] , [ 0, scf, 0 ] , [ 0, 0, 0 ] ]e.K = [ [scf, scf, scf ] , [scf, 0, scf ] , [scf, scf, scf ] ]6.Consider the following recursive Python function. The function does not compute the factorial,as intended. Which of the following statements are true?# this function computes factorialdef Fact(n):return n * Fact(n-1)I. The function is missing a termination condition.II. The function does not call itself recursively.III. The function should return 1 if n==1.IV. The return statement is not necessary.V. The function will run for too long, making too many recursive calls.a.I and IIb.I and IIIc.I, II, and IIId.* I, III, and Ve.II and IVSection 2PART 1:Q1. Which statements regarding recursion are true:I.Recursion is implemented with a function calling itself with subset of original input as its input II.Recursion is implemented with a function calling itself with the original input as its inputIII.Every recursive algorithm has an iterative solutionIV.Recursive algorithm must have a base case or terminating conditiona.I, II, IIIb.I, II, III, IVc.*I, III, IVd.II, IIIe.III, IVQ2. Convert hexadecimal number “201” into decimal.a.127b.*513c.401d.101Q3. What is the expression for the following expression tree:a. ((5 + (z / -8)) * (4 ^ 2))b. (((5 + z) / (-8 * 4)) ^ 2)c. ((5 + ((z / -8) * 4)) ^ 2)d. *(((5 + z) / -8) * (4 ^ 2))PART 2:Q1. Suppose you have a file named “test” containing the following 3 lines:To whom it may concern:I am not selling my textbooks.Seriously.What is the output of the following function:def my_func():file = open("test","rt")contents = file.read()print contents[11:12]file.close()a.* mb. ac.yd.mae.aySection 31.What is the result of the following Python code, given that parameters a and b are positive integers? def function(a,b):for i in range(b):a = a+1return aa. a+ab. b-ac. a-bd. (*) a+b2.What is the result of the following Python code, given that parameters a and b are positive integers?def function2(a,b):result = 0for i in range(b):result = result + areturn resulta. a*ab. (*) b*ac. a-bd. b/a3.What is the purpose of the following Python code, given that parameter a is a positive integer?import mathdef function3(a):sqa = (int) (math.sqrt(a))if sqa * sqa == a:return Truereturn Falsea. returns True if a is evenb. returns True if a is oddc. * returns True if a is a perfect squared. returns True if a is prime6.What is the purpose of the following Python code, given that input list is a list of integers?def function6(list):for i in range(len(list)-1):if(abs(list[i]-list[i+1])>1):return Falsereturn Truea. returns True alwaysb. returns True if list size is evenc.returns True if numbers in list are in ascending orderd. * returns True if difference between neighboring numbers is no more than 11. How many different values can a one byte memory location have?A. 2B. 8 *C. 256D. 65,536E. 4,294,967,3002.Which of the following is the decimal value of the binary number 1110?A. 10B. 12C. 13D. 14E. 153. What is the output produced by this code snipet below.x = 3if 2 > x :print 'First'else :print 'Second'if 2 > x :print 'Third'print 'Fourth'print `Fifth'A.* SecondFourthFifthB.SecondThirdFifthC.FirstSecondThirdD.FifthE.FirstFifth5. What is the output of func(5) for the following codes:def func(n):if n == 1:return 1if n == 2:return 2return func(n – 1) + func(n – 2)a. 6b.7c.* 8d.9e.101) A number is represented in binary as 0100 1100. What is its equivalent hexadecimal representation?a) *4Cb) 10F0c) 410d) 4D2) Consider the following recursive algorithm to find the length (i.e. the number of nodes) in a linked list. Fill in the blank in the algorithm with the best option to find the length of the inked list correclty.LinkedListLength(L)if (L == Null)return 0elsereturn ________________a) *1 + LinkedListLength(L.next)b) LinkedListLength(L.next)c) LinkedListLength(L)3) A complete binary tree is one where all internal nodes have both the left and right children, i.e., neither link is null and all levels are filled. For a complete binary tree with 31 nodes, how many levels does the tree have?a) *5b) 4c) 16d) 154) What is the purpose of the *import* statement in Python?a) * Allows the use of functions defined in other modulesb) Creates and names a new module.c) Restricts the use of functions defined in the current module.5) The following Python function prints out only the even numbers out of a given list.import mathdef func(list):for x in list:if(_______):print xWhich of the following conditions can be used in the *if* statement?a) x%2 == 0b) x%2c) x is evend) x/26) What is the output of the following Python function? def func(str):str = str.replace("apples", "oranges")print(str)str = "apples are not oranges"func(str)print(str)a) *oranges are not orangesapples are not orangesb) apples are not orangesoranges are not orangesc) oranges are not orangesoranges are not orangesd) apples are not orangesapples are not orangesSection 6Part 11. Order the following running times from fast to slow:I. n II. log(n) III. nlog(n) IV. n2a. I, II, III, IVb. IV, I, II, IIIc. *II, I, III, IVd. II, III, I, IVe. none of the above2. What is the hexadecimal representation of the following binary number: 0101 1101 0001 0100a. 6C18*b. 5D14c. 5E18d. 6C14e. none of the abovePart 21. Consider the following piece of python code:def func(a):b=eval(input('please type in a number:'))c=a*breturn cWhat is the output for the call func(5) and the user enters 2?a. 2b. 5*c. 10d. The program will produce an errore. 522. Consider the following piece of python code:def func(A):sum = 0for i in range(3):sum = sum + A[i][2]return sumWhat is the return value of func([[1,2,3],[4,5,6],[7,8,9]])a. 45b. 19*c. 18d. 24e. none of the above3. Consider the following piece of python code:count = 0str = "No"while str[0].lower() != 'Y'.lower():print("The count is:",count)count = count + 1str = input("stop? Yes or No:")print("while loop ended")Which of the following input strings CANNOT end the while loopa. “Yes!”b. “Yeap!”c. “yep”d. * “End”e. “Yuck”Section 7Part IQuestion 1:1.Sometime we are interested in swapping two variables withoutusing any temporary variable. The two variables a and b areswapped as followsa)a=a+bb=a-ba=a-bb)a=a*bb=a/ba=a/bc)Neitherd)*Both (a) and (b)Question 2:Consider a new type of tree in which each internal node has exactly four children. How many nodes at most are there on level 4, where level 0 corresponds to the root, level 1 corresponds to the children of the root, level 2 corresponds to the children of the children of the root, etc.?a)16b)64c)*256d)1024e)None of the aboveIn computer science, binary numbers are used since computer hardware can easily represent 2 states. Assume that in 2050 a technological breakthrough will allow representing 3 states in hardware. What is the base 3 representation of the decimal number 12?a)12b)* 110c)120d)1100e)None of the abovePart IIQuestion 1:What is the output of the following python program?def myFun(x, y, z):if(z == 1):return (x + y)else:return (y + x)print(myFun(‘U’, myFun(‘V’, ‘Z’, 1), 0))a)UVZb)UZVc)VUZd)*VZUe)None of the aboveWhat is the output of the following python code? x = 10def myFun(y):x = y + 1return xmyFun(x)x = x+2print(x)a) 10b) 11c)* 12d) 13What is the output of the following python program?def myFun(x):x = x +1return xx = 10x = x+1myFun(x)x = x+2print(x)a) 10b) 11c)* 13d) 14Section 8Correct answers are marked in red.1.In order to use a function in your code from a different file, which line of code do you have tohave at the beginning of your file?a.import filenameb.from filename import *c.import from filename *d.both a and b can be used2.Which of the following recursive functions will accurately return the factorial of a numberpassed as a parameter?a.def factorial(n)if (n > 1)return 1elsereturn n * factorial(n-1)b.def factorial(n)if (n <= 1)return 1elsereturn n * factorial(n-1)c.def factorial(n)if (n <= 1)return factorial(1)elsereturn n * factorial(n-1)d.def factorial(n)if (n <1)return 0elsereturn n * factorial(n-1)3.What is the value of T[3][1] if T = [[24,1,2],[3,-1,3],[32,4,-1]]?a. 4b.32c. 2d.Index out of range4.In order to take a string as user input for a program you can use the following line of code: = eval(input("What is your name?”)) = input("What is your name?”) = eval("What is your name?”)d.both a and b are ok to use5.In order to append a node to a linked list in constant time you need:a. A while loopb. A for loopc. A reference to the end of the listd. A reference to the beginning of the list6.If you convert 101 from binary to hexadecimal you get:a. Ab. 4c. 5d. CSection 9The answer key is provided at the end of the section.1. Which of the following statements is true?A. A for loop can sometimes, but not every time, be replaced with a while loop.B. A recursive algorithm can always be replaced with an iterative algorithm.C. An iterative algorithm always works in linear time.2. How many bits per symbol do you need to encode a set of 37 symbols?A. 3B. 4C. 5D. 63. What's wrong with the following recursive algorithm?#This function is supposed to print the answer to the current problem#and then print the answer to the next problemdef answerToExamQuestion(b):printAnswerTo(b)return answerToExamQuestion(b)A. The word 'return' is not part of the Python language.B. It will run forever and never finish the task.C. The syntax of the function declaration is incorrect.D. Nothing. It works as intended.4. Which of the following is true about trees?A. Trees are only useful for binary search.B. You cannot find the maximum of a tree.C. Trees are the only way to store sorted lists.D. Trees and lists are two different kinds of data structures.5. What does this code do?def examCode1(n):if n % 5 >= 2.5:return n - n % 5 + 5elsereturn n - n % 5A. It tells whether a number is a multiple of 2.5.B. It returns the number you give it.C. It divides the number by 5.D. It turns the number into two numbers and returns an array.E. It rounds the number to the nearest multiple of 5.#A is an array of numbers of length n def examCode2(A):total = 0for a in A:print(a)if a < 0:a = -atotal = total + areturn totalA. log(n) (logarithmic)B. n (linear)C. n^2 (quadratic)D. n^3 (cubic)E. 2^n (exponential)#A is an array of numbers of length n def examCode3(A,n):total = 0for a in A:for b in A:total += a*breturn totalA. log(n) (logarithmic)B. n (linear)C. n^3 (cubic)D. n^2 (quadratic)E. 2^n (exponential)8. What does this code do?#a is a non-negative number#b is a positive numberdef examCode4(a, b):val = awhile val > b:val -= breturn valA. Calculates a - bB. Calculates a % bC. Calculates a / bD. Calculates a * bE. Calculates a + b9. Node A connects to nodes B and C. Node B connects to nodes C and D. Node E connects to node F. What do we have?A. One treeB. Two treesC. Three treesD. A single graphE. A graph and a tree10. The following adjacency matrix represents a graph. Which of the following adjacency matrices represents the SAME graph?1 1 0 01 1 1 00 1 0 00 0 0 1A.0 0 1 00 1 1 01 1 0 10 0 1 1B.0 1 0 11 0 1 10 1 0 11 1 1 1C.0 1 0 11 0 1 00 1 0 11 0 1 00 1 1 11 1 0 11 0 0 11 0 1 0E. None of the above11. You've learned how to figure out how many bits it takes to store things in binary. By the same logic used to figure that out, how many bits do you need to store things in base 3? (A base3 digit can be 0, 1, or 2.)A. log(n) base 2B. log(n) base 3C. 3*ln(n)D. 2*ln(n)E. n12. A linked list is always a tree.A. TrueB. FalseC. Apple13. A tree is always a linked list.A. TrueB. FalseC. Apple14. Linked lists and trees are always graphs.A. TrueB. FalseC. Apple15. What is the output of this code?def examCode5():a = "A"b = "p"c = "e"d = "l"f = a + b + b + d + cprint(f)A. TrueB. FalseC. Apple16. Bob is taking a math exam and realizes that math is really easy and that a computer should be doing it for him. Which of the following will help Bob find the slope of a line?A.#y1 is the y coordinate of a point#y2 is the y coordinate of a different pointdef examCode6A(y1, y2):return y1/y2B.#x1 is the x coordinate of a point#x2 is the x coordinate of a different pointdef examCode6B(x1, x2):return x1/x2C.#x1 is the x coordinate of a point#y1 is the x coordinate of the same pointdef examCode6C(x1, y1):return x1/y1D.#x1 and y1 are the coordinates of a point#x2 and y2 are the coordinates of a different pointdef examCode6D(x1, y1, x2, y2):slope = (y2 - y1)/(x2 - x1)E.#x1 and y1 are the coordinates of a point#x2 and y2 are the coordinates of a different pointdef examCode6E(x1, y1, x2, y2):return (y2 - y1)/(x2 - x1)19. How many times will the body of the innermost loop of this code be run if A = [1,2,3,4,5]? def examCode8(A):total = 0for a in A:for i in range(a): #This is the innermost looptotal += 1return totalA. 15B. 10C. 20D. 24E. 12020. Grant said hello to Adam and Jamie. Adam said hello to Tory and Kari. Tory said hello to Buster. Buster said hello to nobody. What kind of data structure would model this data the best?A. Linked listB. TreeC. GraphD. None of the aboveKey:1. B //Harrison's questions2. D3. B4. D5. E6. B7. D8. B9. E10.A11.B12.A13.B14.A15.C16.E17.D18.D19.A20.BSection 10What does the following code output?a = 5b = "hello"if (a == 5 and b == 3) or not (a == 3):a = "one"print(a,b)else:b = "one"print(b)print("finally", a, b)A.finally hello 3B. *one hellofinally one helloC.5 hellofinally 5 helloD.finally hello 52. In a binary tree with n nodes and where all levels have the maximum number of nodes, what is the height of the tree?A. nB. 2nC. * log(n)D. 2^n3. In a binary tree with n nodes, what is the maximum height of the tree?A. * nB. 2nC. log(n)D. 2^nSection 111.In broadcast communication, there isa.*One sender and many receiversb.Two senders and many receiversc.Many senders and one receiverd.Many senders and two receivers2.What are the advantages of packet switching?a.If a packet is lost only that packet needs to be resentb.There is no need for rigid routingc.It benefits parcel carriers such as UPS, USPS, and FedExd.It allows all networks to use a common communication protocole. a and b3.With the page rank algorithm, a page receives a higher rank ifa.it points to many other pagesb.many other pages point to itc.it points to a page with high rankd. a page with high rank points to ite.* b and df. a and cg.a, b, c, and ding the shift cipher with k = 1, what is the coded text for “M AYDAY”a.* “NBZEBZ”b.“YADYAM”c.“PCAFCA”d.“TOOBAD”e.“DAYMAY”5.Which of the following is true about substitution cyphersa.They are vulnerable to frequency analysis attacks.b.They always replace a letter with the same letter.c.They are vulnerable to testing all alphabet permutations.d.* a and be. b and cf. c and a。