5.7 CS Questions
According to the following table, how many lookups would be required in the worst case to find a number in list of 10000 elements using linear search? Type your answer in the text box. 10 10 4 100 100 7 1000 1000 10 10000 10000 14 10000 10000 17 1000000 1000000 20
10000
According to the following table, how many lookups would be required in the worst case to find a number in a sorted list of 10000 elements using binary search? Type your answer in the text box. 10 10 4 100 100 7 1000 1000 10 10000 10000 14 10000 10000 17 1000000 1000000 20
14
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
Which of the following characteristics is true of bubble sort?
An N2 algorithm. A comparison-based algorithm
The function shown in this graph is known as the base-2 logarithm function, y = log2(x). Which search algorithm behaves like this function?
Binary search
There are 32 students standing in a classroom. Two different algorithms are given for finding the average height of the students. Algorithm A Step 1: All students stand. Step 2: A randomly selected student writes his or her height on a card and is seated. Step 3: A randomly selected standing student adds his or her height to the value on the card, records the new value on the card, and is seated. The previous value on the card is erased. Step 4: Repeat step 3 until no students remain standing. Step 5: The sum on the card is divided by 32. The result is given to the teacher. Algorithm B Step 1: All students stand. Step 2: Each student is given a card. Each student writes his or her height on the card. Step 3: Standing students form random pairs at the same time. Each pair adds the numbers written on their cards and writes the result on one student's card; the other student is seated. The previous value on the card is erased. Step 4: Repeat step 3 until one student remains standing. Step 5: The sum on the last student's card is divided by 32. The result is given to the teacher.
C) Both Algorithm A and Algorithm B always calculate the correct average.
Which of the following characteristics is true of bucket sort?
More efficient than bubble sort. A linear algorithm
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.
In talking about sorting algorithms in general, a sort algorithm's efficiency refers to ______________________.
how long it takes to arrange the values in order.