AP CSP Unit 5

¡Supera tus tareas y exámenes ahora con Quizwiz!

In the bubble sort demo, 13 cards are being sorted. How many passes does this version of the algorithm require to sort the cards?

13

A cipher is _________________________. A) a person who makes up secret codes B) an algorithm that is used to scramble text so that it can be passed in secret C) a lock that can be used to lock a message in a lock box D) any puzzle, such as a crossword or Sudoku puzzle

B

For searching a sorted list, which search algorithm is the better choice? Sequential search Binary search

Binary search

Under which of the following conditions is it most beneficial to use a heuristic approach to solve a problem? A) When the problem can be solved in a reasonable time and an approximate solution is acceptable. B) When the problem can be solved in a reasonable time and an exact solution is needed. C) When the problem cannot be solved in a reasonable time and an approximate solution is acceptable. D) When the problem cannot be solved in a reasonable time and an exact solution is needed.

C

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? 16 17 9 -1 5

17

Study Mobile CSP

5.2, 5.5, and 5.7

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?

9

To say that bucket sort is more efficient than bubble sort means that _________________. A) for any size list, bucket sort will always be faster than bubble sort. B) as the size of the list grows, bucket sort will be faster than bubble sort. C) bucket sort requires fewer comparisons than bubble sort. D) bucket sort requires fewer swaps than bubble sort.

B

Which of the following characteristics is true of bubble sort? Choose all that apply. A) A comparison-based algorithm. B) Useful only for sorting numbers. C) An N^2 algorithm. D) More efficient than bucket sort. E) Widely used to sort large data sets.

A, C

For which of the problems would the bubble sort algorithm provide an appropriate solution. Choose all that apply. A) Arranging a deck of cards from the lowest to the highest value cards. B) Looking up a name in the phone book. C) Sorting a stack of paper money into denominations -- i.e., $1, $5, $10 etc. D) Sorting a basket of laundry into socks, shirts, shorts, and sheets. E) Arranging books on a bookshelf by author's last name.

A, C, E

The Halting Problemis an example of an intractable problem an exponential problem an undecidable problem a difficult problem

An undecidable problem

For which of the problems would the binary search algorithm be useful? Choose all that apply. A) Arranging a deck of cards from the lowest to the highest value cards. B) Looking up a phone number in the phone book given the person's full (unique) name. C) Looking up a word in a dictionary. D) Looking up a person's name in the phone book given the person's phone number. E) Finding the smallest number in a list of numbers arranged randomly.

B, C

For which of the problems could the sequential search algorithm be used? Choose all that apply. A) Arranging a deck of cards from the lowest to the highest value cards. B) Looking up a phone number in the phone book given the person's full (unique) name. C) Looking up a word in a dictionary. D) Looking up a person's name in the phone book given the person's phone number. E) Guessing a secret number between 1 and 100.

B, C, D, E

In talking about sorting algorithms in general, a sort algorithm's efficiency refers to ______________________. A) how many comparisons are needed to sort the values. B) whether the algorithm correctly arranges the values in order. C) whether or not the algorithm contains a bug. D) how long it takes to arrange the values in order. E) how many swaps are needed to sort the values.

D

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? A) [apple, banana, lemon, tomato, orange, squash, papaya, pumpkin] B) [apple, banana, lemon, squash, tomato, orange, papaya, pumpkin] C) [apple, banana, lemon, orange, papaya, pumpkin, tomato, squash] D) [apple, banana, lemon, orange, papaya, pumpkin, squash, tomato] E) [apple, banana, lemon, orange, papaya, squash, tomato, pumpkin]

D

Which of the following characteristics is true of bucket sort? Choose all that apply. A) A comparison-based algorithm. B) Useful only for sorting numbers. C) An N2 algorithm. D) More efficient than bubble sort. E) A linear algorithm

D, E

True or False: An algorithm can be found for any computational problem whatsoever.

False

True or false: All intractable problems (that cannot be solved in a reasonable time) are bad.

False

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. Tractable Intractable

Intractable

For searching an unordered list, which search algorithm is the better choice? Sequential search Binary search

Sequential search

A Caesar cipher is an example of a ______________________. transposition cipher bimodal cipher substitution cipher substantial cipher

Substitution cipher

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? apple squash tomato pumpkin papaya

Tomato


Conjuntos de estudio relacionados

Chapter 9: Legal Issues with a New Business

View Set

Database Fundamentals (aioTestKing)

View Set