P8cdn4static.sharpschool.com



A+ Computer ScienceAP CSP Algorithms M/C TEST ADirections :: On your answer sheet, record the letter of the best answer to each question. 1.Which of the following best describes and algorithm?a.A group of ideas that could solve a problemb.A list of steps to solve a problemc.A typed document that explains thingsd.A programe.A and B2.If an algorithm was written in one the following, which would typically make reading the algorithm the easiest?a.natural languageb.pseudocodec.Pythond.Javae.C3.If an algorithm was written in one the following, which would most likely make the algorithm the most detailed?a.Javab.Pythonc.Cd.Depends on the problem the algorithm was designed to solve.e.All of the answer choices could be true4.When taking a natural language or pseudocode algorithm and translating it into programming language code, which of the following is true?a.Some languages are easier to read than others.b.Some languages add more detail to the final programming language solution.c.Some languages may simplify the code as they may have features that make the code writing easier.d.A and B onlye.A, B, and C5.Which of the following is the most important thing to consider when picking the language to be used to turn an algorithm into a computer program?a.Some languages should be used for all algorithms.b.Some languages should never be used for algorithms.c.Some languages are better suited for some algorithms as they have features that simplify the algorithm.d.Most languages are hard to read as code is hard to read.e.No languages are hard to read as most all read like english.6.Which of the following is the most important thing to consider when picking the language to be used to translate an algorithm into a computer program?a.Does the programming language contain the features required by the algorithm.b.Will the programming language create code that is logical and easy to understand.c.Will the programming language create code that will run efficiently for the problem being solved.d.A and B onlye.A, B, and C7.Which of the following algorithms will run in reasonable time?a.Linear Searchb.Binary Searchc.Even Checkerd.Odd Checkere.All of the above8.Which of the following algorithms will NOT run in reasonable time?a.Maze Solverb.Traveling Salesmanc.Binary Searchd.Odd Checkere.A and B only9.Which of the following best describes a decidable problem?a.An algorithm that solves all instances of a problem for all data set sizes.b.An algorithm that solves some instances of a problem for all data set sizes.c.An algorithm that solves some instances of a problems for some data set sizes.d.An algorithm that runs really slowly for all data set sizes.e.A and B only10.Which of the following best describes an undecidable problem?a.An algorithm that solves all instances of a problem for all data set sizes.b.An algorithm that solves some instances of a problem for all data set sizes.c.An algorithm that solves some instances of a problems for some data set sizes.d.An algorithm that runs really slowly for all data set sizes.e.A and B only11.An algorithms efficiency helps a programmer determine what?a.If the algorithm will run in reasonable time.b.If the algorithm will run in unreasonable time.c.There is no mathematical way to evaluate the run time of an algorithm.d.If the algorithm solves the problem, the run time does not matter.e.A and B only12.Which of the following are true about algorithms?a.There may be several algorithms and programming language solutions for a problem with run times that vary greatly.b.Creating an efficient working code solution for an algorithm may help solve larger versions of the problem later if the code can be scaled for the larger problem.c.Most algorithms can only be written in only one language for only one specific problem.d.A and B onlye.A, B and C13.Which is true about a linear search?a.Will search any data set.b.Does not work on unsorted data sets.c.Works sometimes on large data sets.d.Does not work well on small data sets.e.Should not be used to sort complicated data sets.14.Which is true about a binary search?a.Will search any data set.b.Does not work correctly on unsorted data sets.c.Works sometimes on large data sets.d.Does not work well on small data sets.e.Should not be used to sort complicated data sets.15.Which of the following would be the best situation to use a linear search?a.searching the list several timesb.the list has already been sortedc.searching the list just one timed.A and B onlye.A, B, and C16.Which of the following would be the best situation to use a binary search?a.searching the list several timesb.the list has already been sortedc.searching the list just one timed.A and B onlye.A, B, and C17.Questions 19 - 30 are python questions. Python version 3.x is used for these questions.What is output by the code below?fruit = ["apples", "bananas", "oranges"]for i in range(len(fruit)): print(i, fruit[i])a.applesbananasorangesb.0 apples1 bananas2 orangesc.012d.0 apples 1 bananas 2 orangese.There is no output due to a runtime error.18.What is output by the code below?fruit = ["a", "b", "c", "a", "b", "a"]count = 0for x in fruit: if x == "a" : count = count + 1print( count )a.0b.1c.2d.3e.There is no output due to a runtime error.19.What is output by the code below?fruit = ["a", "b", "c", "a", "b", "a"]count = 0for x in fruit: if x == "z" : count = count + 1print( count )a.0b.1c.2d.3e.There is no output due to a runtime error.20.Consider method go.def go( list, val): for i in range( len( list ) ): if list[i] < val: return list[i] return -1What will method go return?a.The first value in the list smaller than val or -1 if no value found.b.The first value in the list larger than val or -1 if no value found.c.The last value in the list smaller than val or -1 if no value found.d.The last value in the list larger than val or -1 if no value found.e.The smallest value in the list or -1 if no value found.21.Consider method go.def go( list, val): save = -1 for i in range( len( list) ): if list[i] > val: save = list[i] return saveMethod go should return the first value greater than val or -1 if no values are greater than val. Why does method go not work as intended?a.Method go returns the last value greater than val.b.Method go returns the last value less than val.c.Method go returns the first value greater than val.d.Method go returns the first value less than val.e.Method go works as intended and needs no changes.22.Consider method go.def go( list, val): save = -1 for i in range( len( list) ): if list[i] > val: save = list[i] #line 1 return saveMethod go should return the first value greater than val or -1 if no values are greater than val. Which of the following lines of code could replace #line 1 so that method go would work as intended?a.return list[i]b.save = list[i-1]c.save = list[i+1]d.save = list[0]e.Method go works as intended and needs no changes.23.Consider method go.def go( list, val): save = -1 for i in range( len( list ) ): if list[i] > val: save = list[i] return saveWhat will method go return?a.The first value in the list smaller than val or -1 if no value found.b.The first value in the list larger than val or -1 if no value found.c.The last value in the list smaller than val or -1 if no value found.d.The last value in the list larger than val or -1 if no value found.e.The smallest value in the list or -1 if no value found.24.Which of the following could correctly fill /* blank */ in method everyOther()? # method everyOther should return the list of items with even indices in theListdef everyOther(theList): myList = [] for z in range(len(theList)): /* blank */ myList.append(theList[z]) return myLista.if( z % 2 == 0):b.if(theList % 2 == 1):c.if( theList[z] % 2 == 1) :d.if( theList[z] % 2 == 0) :e.if( z % 2 == 1):25.Consider the following incomplete method. The method double should create a new list that contains a value which is double of each old value in the list.def double(oldList): newList = [] /* blank */ return newListWhich of the following code segments shown below could be used to replace /* blank */ so that method double will work as intended?I. for i in range(len(oldList)): newList.append(oldList[i]*2)II. for i in range(len(oldList)): newList.append(i*2)III. for n in oldList: newList.append(n*2)a.I onlyb.II onlyc.III onlyd.I and II onlye.I and III only26.Which of the following blocks of code will correctly find the largest number in the list?I.ray = some valuesx = 0for i in range( 1, len(ray) ) : if ( ray[ x ] > ray[ i ] ): x = iprint( ray[ x ] ) II.ray = some valuesx = 0for i in range( 1, len(ray) ) : if ( ray[ x ] < ray[ i ] ): x = iprint( ray[ x ] ) III.ray = some valuesx = 0for i in range( 1, len(ray) ) : if ( ray[ x ] > ray[ i ] ): x = iprint( x ) a.I onlyb.II onlyc.III onlyd.I and IIe.II and III27.Which of the following blocks of code will correctly find the smallest number in the list?I.ray = some valuesx = 0for i in range( 1, len(ray) ) : if ( ray[ x ] > ray[ i ] ): x = iprint( ray[ x ] ) II.ray = some valuesx = 0for i in range( 1, len(ray) ) : if ( ray[ x ] < ray[ i ] ): x = iprint( ray[ x ] ) III.ray = some valuesx = 0for i in range( 1, len(ray) ) : if ( ray[ x ] > ray[ i ] ): x = iprint( x ) a.I onlyb.II onlyc.III onlyd.I and IIe.II and III28.Which of the following blocks of code will correctly find the average of all numbers in the list?I.ray = some valuesx = 0for i in range( 0, len(ray) ) : x = x + ray[i]print( x / len(ray) ) II.ray = some valuesx = 0for i in range( 1, len(ray) ) : x = x + ray[i]print( x / len(ray) ) III.ray = some valuesx = 0for i in range( 0, len(ray)-1 ) : x = x + ray[i]print( x / len(ray) ) a.I onlyb.II onlyc.III onlyd.I and IIe.II and III29.The pseudocode used on the next 10 questions [ questions 29 - 40 ] is similar to python and the pseudocode used on the AP CS Principles Exam. Consult the pseudocode quick reference for the AP CS Principles Exam. For the AP CSP pseudocode, lists[] start at position 1 not 0.For the AP CSP pseudocode, <- is the assignment operator [ = ].What is output by the pseudocode below?list <- [11, 2, -2, 8]count <- 0for each x in list if( x > 5 ) count <- count + 1display( count ) a.0b.1c.2d.3e.430.What is output by the pseudocode below?list <- [11, 2, -2, 8]count <- 0for each x in list if( x > 10 ) count <- count + 1display( count ) a.0b.1c.2d.3e.431.What is output by the pseudocode below?list <- [11, 2, 8, 5, 10]count <- 0for each x in list if( x mod 2 = 0 ) count <- count + 1display( count ) a.0b.1c.2d.3e.432.What is output by the pseudocode below?list <- [11, 2, 8, 5, 10]sum <- 0for each x in list if( x mod 2 = 0 ) sum <- sum + xdisplay( sum ) a.0b.10c.16d.20e.3633.What is output by the pseudocode below?list <- [11, 2, 8, 5, 10]sum <- 0for each x in list if( not x mod 2 = 0 ) sum <- sum + xdisplay( sum ) a.0b.10c.16d.20e.3634.What is output by the pseudocode below?list <- [11, 2, 8, 5, 10]count <- 0for each x in list if( not x mod 2 = 0 ) count <- count + 1display( count ) a.0b.1c.2d.3e.435.What is output by the pseudocode below?list <- [1]append( list, 4 )append( list, 5 )display( list )a.[1, 4, 5]b.[1]c.[4 ,5]d.[5]e.[]36.What is output by the pseudocode below?list <- [1]append( list, 4 )display( list )a.[1, 4]b.[1]c.[4 ,5]d.[5]e.[]37.What is output by the pseudocode below?list <- []append( list, 5 )display( list )a.[1, 4, 5]b.[1]c.[4 ,5]d.[5]e.[]38.For the AP CSP pseudocode, lists[] start at position 1 not 0.What is output by the pseudocode below?list <- [1, 2]append( list, 10 )remove( list, 1 )insert( list, 2, 5 )display( list )a.[1, 2, 10]b.[1, 2, 5, 10]c.[1, 2 ,5]d.[5, 10]e.[2, 5, 10]39.For the AP CSP pseudocode, lists[] start at position 1 not 0.What is output by the pseudocode below?list <- [1, 2]append( list, 10 )insert( list, 2, 5 )display( list )a.[1, 2, 10]b.[1, 5, 2, 10]c.[1, 2 ,5]d.[5, 10]e.[1, 2, 5, 10]40.For the AP CSP pseudocode, lists[] start at position 1 not 0.What is output by the pseudocode below?list <- [1, 2, 3, 4, 5]remove( list, 3 )remove( list, 3 )append( list, 3 )display( list )a.[1, 2, 3]b.[1, 5, 2, 3]c.[1, 4 ,5, 3]d.[5, 3]e.[1, 2, 5, 3]AP CSP Algorithms M/C TEST A KEY1.E2.A3.E4.E5.C6.E7.E8.E9.A10.C11.E12.D13.A14.B15.C16.D17.B18.D19.A20.A21.A22.A23.D24.A25.E26.B27.A28.A29.C30.B31.D32.D33.C34.C35.A36.A37.D38.E39.B40.E ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download