AP CSP Unit 5 Test
URL
(uniform resource locator) it is the global address of documents and other resources on the World Wide Web
For searching a sorted list, which search algorithm is the better choice?
Binary search
When might a bucket sort be more efficient than a bubble sort?
As the size of the list grows
What are the values in the list after executing the following code: list ← [ 0, 3, 5 ] APPEND( list, 4 ) INSERT( list, 2, 1 ) REMOVE( list, 1 )
[1, 3, 5, 4]
Suppose you are sorting the following list of words in alphabetical order using bubble sort: [apple, banana, lemon, tomato, orange, squash, papaya, pumpkin]. Which of the following gives the correct order of the list after two passes through the list?
[apple, banana, lemon, orange, papaya, pumpkin, squash, tomato]
firewall
a part of a computer system or network that is designed to prevent unauthorized access to or from that network
cache
a special high-speed storage mechanism
The Halting Problemis an example of
an undecidable problem
To say that bucket sort is more efficient than bubble sort means that _________________.
as the size of the list grows, bucket sort will be faster than bubble sort.
True or false: All intractable problems (that cannot be solved in a reasonable time) are bad.
false
In talking about sorting algorithms in general, a sort algorithm's efficiency refers to ______________________.
how long it takes to arrange the values in order.
HTML
hypertext markup language, a standardized system for tagging text files to achieve font, color, graphic, and hyperlink effects on World Wide Web pages
foreground
in multiprocessing systems, the process that is currently accepting input from the keyboard or other input device
What block would you use to determine the number of items in a list?
length of list list (light blue)
background
multitasking computers are capable of executing several tasks, or programs, at the same time
binary
pertaining to a number system that has just two unique digits
bot
short for robot, a computer program that runs automatically.
Suppose you are sorting the following list of words into alphabetical order using bubble sort: [apple, orange, banana, papaya, lemon, pumpkin, squash, tomato]. After the first pass through the list, what word would appear on the right of the list?
tomato
Under which of the following conditions is it most beneficial to use a heuristic approach to solve a problem?
(C) When the problem cannot be solved in a reasonable time and an approximate solution is acceptable.
Suppose you are sorting the following list of numbers in ascending order using bubble sort: [16, 5, -1, 4, 12, 17, 3, 10, 5, 9]. After the first pass through the numbers, what value would appear on the right of the list?
17
For a list of 500 numbers, at most how many guesses would it take using binary search to guess the secret number if after each guess you were told whether your guess was too high or too low or just right? Type your answer into the text box.
9. Keep dividing 500 by 2 until you run out of numbers
What is bubble sort? How does it work? When would it be useful?
A comparison sort, on each pass of the data, the highest value bubbles to the top.
Which of the following characteristics is true of bubble sort? Choose all that apply
A comparison-based algorithm. An N2 algorithm.
pseudocode
A mixture between a natural language and a formal programming language
Define algorithm and give an example
A sequence of precise instructions, step by step procedures, consists of sequences, selections and repetitions. If button 1 is clicked Then add 1 to global score
What is true about algorithms?
Algorithms are a sequence of precise instructions, step by step procedures, consists of sequences, selections and repetitions
For which of the problems would the bubble sort algorithm provide an appropriate solution. Choose all that apply.
Arranging a deck of cards from the lowest to the highest value cards. Sorting a stack of paper money into denominations -- i.e., $1, $5, $10 etc. Arranging books on a bookshelf by author's last name.
True or False: An algorithm can be found for any computational problem whatsoever.
False
What does a sort algorithm's efficiency refer to?
How long it takes to arrange the values in order
Which code below could be placed in the following loop to print out the item in a list that has the lowest (minimum) value? list ← 1, 0, 4, 2 x ← 99 FOR EACH item IN list { <MISSING CODE> } DISPLAY(x)
IF (item < x) x ← item
Is the following problem tractable (solvable in a reasonable amount of time) or intractable (cannot be solved in a reasonable amount of time)? For any length string of letters using any combination of the letters 'a' through 'z', write down all possible strings.
Intractable
For searching an unordered list, which search algorithm is the better choice?
Linear search
For which of the problems would the binary search algorithm be useful? Choose all that apply.
Looking up a phone number in the phone book given the person's full (unique) name. Looking up a word in a dictionary.
For which of the problems could the linear search algorithm be used? Choose all that apply.
Looking up a phone number in the phone book given the person's full (unique) name. Looking up a word in a dictionary. Looking up a person's name in the phone book given the person's phone number. Guessing a secret number between 1 and 100.
Which of the following characteristics is true of bucket sort? Choose all that apply.
More efficient than bubble sort. A linear algorithm
List one "good" and one "bad" reason to retain/delete your search history.
Retain-To go back to the website that you have searched for importance Delete-Privacy concerns/reasons
What are the three types of control structures found in algorithms? Provide an example of each type of control structure.
Sequence-To go in order Selection-If then else, to choose something Repetition-repeat
Find the bug. When Button1 is clicked, Label1 is supposed to be set to a name that is selected from the names list by the displayName procedure. But the label's Text never changes. Why? (5.5)
The displayName procedure is not being called when the button is clicked.
Describe the significance of the global variable index. How was the indexing used with lists in our Quiz App?
The index variable is used with all of the lists to select a particular item. The items in each list at the same index are related to each other. It allowed us to move from question to question.
The following blocks specify what happens when the user clicks "Next" in a quiz app: There is a subtle error in the code such that the quiz won't work as desired. What is the problem? (5.5)
The last question in the quiz will never be reached.
You should be able to draw a square of any size with this procedure by calling it and specifying the parameter L. However, this procedure has a bug. What is the bug? (5.1)
The procedure always draws a square with sides of size 50. The parameter L is ignored,
sequencing
To execute in the order they are given
What is a binary (ordered) search? When would it be used?
Used for an ordered or sorted list F(N) = log2N
What is a sequential (linear) search? When would it be used?
Used to search an unordered list by going through each item. F(N) = N
Under what conditions is it most beneficial to use a heuristic approach to solve a problem?
Used when a problem cannot be solved in a reasonable time and an approximated solution is acceptable.