PreAP Computer Science Quiz

Slides:



Advertisements
Similar presentations
Lesson 8 Searching and Sorting Arrays 1CS 1 Lesson 8 -- John Cole.
Advertisements

PreAP Computer Science Quiz
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
Practice Quiz Question
Topic 24 sorting and searching arrays "There's nothing in your head the sorting hat can't see. So try me on and I will tell you where you ought to be."
Chapter 9: Searching, Sorting, and Algorithm Analysis
Copyright © 2012 Pearson Education, Inc. Chapter 8: Searching and Sorting Arrays.
Objectives Learn how to implement the sequential search algorithm Explore how to sort an array using the selection sort algorithm Learn how to implement.
Searching Arrays Linear search Binary search small arrays
C++ for Engineers and Scientists Third Edition
Programming Logic and Design Fourth Edition, Comprehensive
Searching and Sorting Arrays
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 9 Searching.
CS 106 Introduction to Computer Science I 10 / 16 / 2006 Instructor: Michael Eckmann.
Chapter 8 ARRAYS Continued
PreAP Computer Science Quiz
Chapter 7: Arrays. In this chapter, you will learn about: One-dimensional arrays Array initialization Declaring and processing two-dimensional arrays.
Array operations II manipulating arrays and measuring performance.
PreAP Computer Science Quiz
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 8: Searching and Sorting Arrays.
Copyright © 2012 Pearson Education, Inc. Chapter 8: Searching and Sorting Arrays.
Chapter 19 Searching, Sorting and Big O
CHAPTER 09 Compiled by: Dr. Mohammad Omar Alhawarat Sorting & Searching.
Chapter 10 Strings, Searches, Sorts, and Modifications Midterm Review By Ben Razon AP Computer Science Period 3.
SEARCHING UNIT II. Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances.
PreAP Computer Science Quiz
Chapter 8 Searching and Sorting Arrays Csc 125 Introduction to C++ Fall 2005.
1 Searching and Sorting Linear Search Binary Search.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 9 Searching Arrays.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 8: Searching and Sorting Arrays.
 2006 Pearson Education, Inc. All rights reserved Searching and Sorting.
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Searching Course Lecture Slides 28 May 2010 “ Some things Man was never.
Array (continue).
PreAP Computer Science Review Quiz 08 Key
C++ for Engineers and Scientists Second Edition Chapter 11 Arrays.
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Modified for use by MSU Dept. of Computer Science.
Week # 2: Arrays.  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently  Types of data.
Chapter 9 slide 1 Introduction to Search Algorithms Search: locate an item in a list (array, vector, table, etc.) of information Two algorithms (methods):
PreAP Computer Science Quiz
CS 106 Introduction to Computer Science I 03 / 02 / 2007 Instructor: Michael Eckmann.
Take out a piece of paper and PEN.
Course Code #IDCGRF001-A 5.1: Searching and sorting concepts Programming Techniques.
PreAP Computer Science Quiz
PreAP Computer Science Quiz Take out a piece of paper and PEN. The quiz starts ONE minute after the tardy bell rings. You will have 30 – 60 seconds.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
AP Computer Science DYRT Quiz
 Introduction to Search Algorithms  Linear Search  Binary Search 9-2.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 8: Searching and Sorting Arrays.
Searching and Sorting Arrays Shirley Moore CS 1401 Spring 2013 cs1401spring2013.pbworks.com April 15-16, 2013.
Algorithm Definition An algorithm is a step-by-step solution to a problem.
Algorithm Definition An algorithm is a step-by-step solution to a problem.
1 compares each element of the array with the search key. works well for small arrays or for unsorted arrays works for any table slow can put more commonly.
Take out a piece of paper and PEN. The quiz starts TWO minutes after the tardy bell rings. You will have 30 seconds per question. Exposure Java 2014 for.
Searching and Sorting Arrays
COP 3503 FALL 2012 Shayan Javed Lecture 15
Introduction to Search Algorithms
Searching and Sorting Arrays
Standard Version of Starting Out with C++, 4th Edition
24 Searching and Sorting.
Principles of Computing – UFCFA3-30-1
Topic 24 sorting and searching arrays
Searching and Sorting Arrays
PreAP Computer Science Review Quiz 08
PreAP Computer Science Quiz Key
Take out a piece of paper and PEN.
PreAP Computer Science Quiz
Take out a piece of paper and PEN.
Searching and Sorting Arrays
Principles of Computing – UFCFA3-30-1
Presentation transcript:

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 60 seconds per question.

Title the quiz as shown below The quiz starts in ONE minute. Name Period Date Quiz 13.03-07 1. 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 have an int array? The int array does not provide any methods to access the array elements. The int array does not provide methods to perform operations on the array. The int array does not protect against unwanted access of data members. All of the above

Question 02 What is the purpose of the pause method? It slows down the output of an animated graphics program. It permanently stops the output of a graphics-based program in the middle of its execution. It permanently stops the output of a text-based program in the middle of its execution. 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. 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 any list of data. lists of data sorted in ascending order only. lists of data sorted in descending order only. lists of random data only.

Question 04 The efficient linear search stops searching when the data is found. finds requested data faster. works only with lists of sorted data. has less program code than the inefficient linear search.

Question 05 The reason for sorting data is people prefer data sorted. sorted data takes less space. searching is faster with sorted data. all of the above.

Question 06 The partial sort – as demonstrated in Chapter 13 – only sorts half the list. arranges data in ascending order. arranges data is descending order. places one element in the correct location.

Question 07 The bubble sort – as demonstrated in Chapter 13 – sorts only half the list. data in ascending order. data in descending order. one element in the correct location.

Question 08 Which 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? The index where it was found. -1 true false Index Out of Bounds Exception

Question 10 What is returned by the Efficient & Practical Linear Search if the desired item IS in the list? The index where it was found. -1 true false Index Out of Bounds Exception

Question 11 What is returned by the Inefficient Linear Search if the desired item is NOT in the list? The index where it was found. -1 true false 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? The index where it was found. -1 true false Index Out of Bounds Exception

Question 13 You 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? exactly 1 about 500,000 about 1,000,000 It will not find the person.

Question 14 You 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? exactly 1 about 500,000 about 1,000,000 It will not find the person.

Question 15 You 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? exactly 1 about 500,000 about 1,000,000 It will not find the person.

Question 16 You 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? exactly 1 about 500,000 about 1,000,000 It will not find the person.

Question 17 The advantage of the binary search over the linear search is that it requires writing less program code. finds data much faster. quits when the required data is found. all of the above.

Question 18 The disadvantage of using the binary search is that it requires writing less program code. finds data much faster. requires sorted data. 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. linearSearch binarySearch swap partialSort bubbleSort

Question 20 (a) for (int p = 1; p < size; p++) 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 23