PreAP Computer ScienceQuiz 13.03-07
Take out a piece of paper and PEN.
The quiz starts ONE minute after the tardy bell rings.
You will have 30, 45 or 60 seconds per question.
Title the quiz as shown belowThe quiz starts in ONE minute.
Name Period Date
Quiz 13.03-071. 11.2. 12.3. 13.4. 14.5. 15.6. 16.7. 17.8. 18.9. 19.10. 20.
EC.
Question 01
Why is a List class necessary, if you already havean int array?
(a) The int array does not provide any methods to access the array elements.
(b) The int array does not provide methods to perform operations on the array.
(c) The int array does not protect against unwanted access of data members.
(d) All of the above
Question 02What is the purpose of the pause method?
(a) It slows down the output of an animated graphics program.
(b) It permanently stops the output of a graphics-based program in the middle of its execution.
(c) It permanently stops the output of a text-based program in the middle of its execution.
(d) It temporarily stops the output of a text-based program, to give you a chance to see it, and then continues when you press the <enter> key.
(e) It temporarily stops the output of a graphics-based program, to give you a chance to see it, and then continues when you click the mouse.
Question 03
The linear search works with
(a) any list of data.(b) lists of data sorted in ascending order
only.(c) lists of data sorted in descending order
only.(d) lists of random data only.
Question 04
The efficient linear search
(a) stops searching when the data is found.(b) finds requested data faster.(c) works only with lists of sorted data.(d) has less program code than the inefficient
linear search.
Question 05
The reason for sorting data is
(a) people prefer data sorted.(b) sorted data takes less space.(c) searching is faster with sorted data.(d) all of the above.
Question 06
The partial sort – as demonstrated in Chapter 13 – only
(a) sorts half the list.(b) arranges data in ascending order.(c) arranges data is descending order.(d) places one element in the correct location.
Question 07
The bubble sort – as demonstrated in Chapter 13 – sorts
(a) only half the list.(b) data in ascending order.(c) data in descending order.(d) one element in the correct location.
Question 08Which of the following is a problem with the inefficient Linear Search?
I. The algorithm cannot find an item in the list.II. The algorithm will always search through to the end of the list even after the item is already found.III. The algorithm does not tell you the index of where
an item was found.
(a) I only (b) I & II only(c) I & III only (d) II & III only(e) I, II & III
Question 09
What is returned by the Inefficient Linear Search if the desired item IS in the list?
(a) The index where it was found.(b) -1(c) true(d) false(e) Index Out of Bounds Exception
Question 10
What is returned by the Efficient & Practical Linear Search if the desired item IS in the list?
(a) The index where it was found.(b) -1(c) true(d) false(e) Index Out of Bounds Exception
Question 11
What is returned by the Inefficient Linear Search if the desired item is NOT in the list?
(a) The index where it was found.(b) -1(c) true(d) false(e) Index Out of Bounds Exception
Question 12
What is returned by the Efficient & Practical Linear Search if the desired item is NOT in the list?
(a) The index where it was found.(b) -1(c) true(d) false(e) Index Out of Bounds Exception
Question 13You have a sorted array of about 1,000,000 people. You are using the linearSearch method to find someone in who is at the very beginning of the list. How many people does the computer look at before it finds the one you are looking for?
(a) exactly 1(b) about 500,000(c) about 1,000,000
(d) It will not find the person.
Question 14You have a sorted array of about 1,000,000 people. You are using the linearSearch method to find someone in who is at the very end of the list. How many people does the computer look at before it finds the one you are looking for?
(a) exactly 1(b) about 500,000(c) about 1,000,000
(d) It will not find the person.
Question 15You have a sorted array of about 1,000,000 people. You are using the linearSearch method to find someone in the exact middle on the list. How many people does the computer look at before it finds the one you are looking for?
(a) exactly 1(b) about 500,000(c) about 1,000,000
(d) It will not find the person.
Question 16You have a sorted array of about 1,000,000 people. You are using the binarySearch method to find someone in the exact middle on the list. How many people does the computer look at before it finds the one you are looking for?
(a) exactly 1(b) about 500,000(c) about 1,000,000
(d) It will not find the person.
Question 17
The advantage of the binary search over the linear search is that it
(a) requires writing less program code.(b) finds data much faster.(c) quits when the required data is found.(d) all of the above.
Question 18
The disadvantage of using the binary searchis that it
(a) requires writing less program code.(b) finds data much faster.(c) requires sorted data.(d) requires random data.
Question 19
Below are a list of methods from Chapter 13.If you had to pick one method to be declared private which would it be? NOTE: All of the methods are in the same class.
(a) linearSearch(b) binarySearch(c) swap(d) partialSort(e) bubbleSort
Question 20
This program segment is a bubble sort and it has 3 less than ( < ) signs in it and will sort data in descending (largest to smallest) order. Which sign do I need to “flip” (change to a >) so it will now sort in ascending (smallest to largest) order?
(a) for (int p = 1; p < size; p++)(b) for (int q = 0; q < size-p ; q++)(c) if (intArray[q] < intArray[q+1])(d) swap(q,q+1);
Extra Credit
The population of planet Earth is about 7 billion. If all of these people were stored in one gigantic array, how many tries would it take the Binary Search to find any individual on the planet?
(a) 20 (b) 23(c) 30 (d) 31(e) 32 (f) 33(g) 34 (h) 3 to 3.5 billion