Transcript
Page 1: PreAP Computer Science Quiz 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

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.

Page 2: PreAP Computer Science Quiz 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

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.

Page 3: PreAP Computer Science Quiz 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

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

Page 4: PreAP Computer Science Quiz 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

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.

Page 5: PreAP Computer Science Quiz 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

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.

Page 6: PreAP Computer Science Quiz 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

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.

Page 7: PreAP Computer Science Quiz 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

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.

Page 8: PreAP Computer Science Quiz 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

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.

Page 9: PreAP Computer Science Quiz 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

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.

Page 10: PreAP Computer Science Quiz 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

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

Page 11: PreAP Computer Science Quiz 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

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

Page 12: PreAP Computer Science Quiz 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

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

Page 13: PreAP Computer Science Quiz 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

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

Page 14: PreAP Computer Science Quiz 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

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

Page 15: PreAP Computer Science Quiz 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

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.

Page 16: PreAP Computer Science Quiz 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

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.

Page 17: PreAP Computer Science Quiz 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

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.

Page 18: PreAP Computer Science Quiz 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

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.

Page 19: PreAP Computer Science Quiz 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

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.

Page 20: PreAP Computer Science Quiz 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

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.

Page 21: PreAP Computer Science Quiz 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

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

Page 22: PreAP Computer Science Quiz 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

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);

Page 23: PreAP Computer Science Quiz 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

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


Top Related