PRS 27, 30-33

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

After two passes of the Exchange Sort, what should the following list be? (in an ascending order sort) 3, 9, 8, 6, 4, 1, 10 1. 3, 8, 6, 4, 1, 9, 10 2. 3, 6, 4, 1, 8, 9, 10 3. 3, 8, 9, 6, 4, 1, 10 4. 3, 1, 8, 6, 4, 9, 10 5. 3, 1, 4, 6, 8, 9, 10

3, 6, 4, 1, 8, 9, 10

After two insertion operations of the Insertion Sort, what should the following list be? (in an ascending order sort) 3, 9, 8, 6, 4, 1, 10 1. 3, 8, 6, 4, 1, 9, 10 2. 3, 6, 4, 1, 8, 9, 10 3. 3, 8, 9, 6, 4, 1, 10 4. 3, 1, 8, 6, 4, 9, 10 5. 3, 1, 4, 6, 8, 9, 10

3, 8, 9, 6, 4, 1, 10

For an array of 9 elements, what is the first index that will be looked at in a binary search? 1. 0 2. 1 3. 4 4. 8 5. Depends on the value of the item being searched

4

After four passes of the Selection Sort, what should the following list be? (in an ascending order sort) 23, 17, 5, 90, 12, 44, 38, 84, 77 1. 5, 12, 17, 23, 90, 44, 38, 84, 77 2. 5, 17, 23, 90, 12, 44, 38, 84, 77 3. 5, 12, 17, 23, 44, 38, 77, 84, 90

5, 12, 17, 23, 90, 44, 38, 84, 77

Which of the following is not a necessary element of a recursive method? 1. A loop to repeat a procedure. 2. A call to the method of the same name. 3. A terminating end case. 4. A conditional test

A loop to repeat a procedure.

What does Java's AWT stand for? 1. Application Window Techniques 2. Abstract Window Techniques 3. Application Window Tools 4. Abstract Window Toolkit 5. Abstract Windowing Toolkit

Abstract Window Toolkit

Why is it critical to differentiate between successful and unsuccessful searches? 1. Because one type of search may be good for successful searches but poor for unsuccessful searches, and vice versa. 2. Because programs need to know what to output after the search is complete. 3. Because a programmer needs to determine the success rate of any given search. 4. Because the programmer needs know how to implement the search.

Because one type of search may be good for successful searches but poor for unsuccessful searches, and vice versa.

T/F: A recursive solution always results in excessive duplicate computation.

False

T/F: Every exception that is thrown must be caught.

False

T/F: When deleting an object from an array, one must update the length field of the array manually.

False

Which of the following is not a property that the bubble sort exhibits? 1. The largest element is at the end of the array. 2. If no pair of consecutive entries is out of order, then the array is sorted 3. In the worst case, bubble sort makes N-1 passes, where N is the number of elements in the array. 4. In the average case, bubble sort makes logN passes, where N is the number of elements in the array.

In the average case, bubble sort makes logN passes, where N is the number of elements in the array.

How do we have a method propagate an exception? 1. Include "throws Exception" at the end of the method signature 2. Have the class implement Throwable 3. Create a new Throwable object within the method 4. Create a new Exception object within the method

Include "throws Exception" at the end of the method signature

For a quadratic algorithm, if the size of the input quadruples, what will happen to the time it takes to run? 1. It will increase by a factor of 4 2. It will increase by a factor of 8 3. It will increase by a factor of 16 4. It will decrease by a factor of 4 5. It will increase by a factor of 32

It will increase by a factor of 16

Which of the following is not true about binary search? 1. Its complexity is O(n). 2. It runs faster than a linear search. 3. The list of elements involved has to be sorted first. 4. If there are 8 elements (numbers) in the list, in the worst case scenario, the search needs to look at only 3 elements to determine whether a user-specified element is in the list.

Its complexity is O(n)

Which of the following is the greatest complexity (in the general case)? 1. O(n) 2. O(n2) 3. O(log2n) 4. O(n2000) 5. O(2n)

O(2n)

What number should we select to be the pivot in the quicksort algorithm such that the number of comparisons will be minimized? 1. Select the lowest number from the list 2. Select the highest number from the list 3. Select number closest median of the list 4. Select a number at random

Select number closest median of the list

Which of the following is a major advantage of using Swing over AWT? 1. Swing classes provide more compatibility across different operating systems. 2. Swing classes are lightweight classes and AWT classes are heavyweight classes. 3. Swing classes' documentation is easier to read and interpret. 4. Swing allows far more graphical options than AWT does.

Swing classes provide more compatibility across different operating systems.

T/F: A single method can be both the propagator and catcher of an exception.

True

T/F: It is possible that a recursive call will never end (i.e., it will call itself infinitely)

True

T/F: Recursion tends to require more memory than iteration does.

True

T/F: The showConfirmDialog method of the JOptionPane class returns a value that corresponds to the button clicked by the user.

True

When would a programmer be forced to pick a linear search over a binary search? 1. When the items in the array are in ascending order 2. When the items in the array are in descending order 3. When the items in the array are unsorted 4. Linear search is never a better choice than binary search.

When the items in the array are unsorted

A recursive method is __________. 1. a method that makes a call to itself. 2. a method that contains some form of a loop. 3. a method that contains both a conditional and a loop. 4. None of the above.

a method that makes a call to itself.

A frame's content pane __________. 1. is the area that contains everything graphical within the frame 2. designates the area of the frame that excludes the title and menu bars and the border 3. is the aggregate sum of the menu bars, title, and text within a frame 4. is the location for textual information only

designates the area of the frame that excludes the title and menu bars and the border

What does the following statement do? (g is a Graphics object). g.drawRect(200,150,1,2); 1. draws a 2 pixel wide by 1 pixel high rectangle with coordinates at location (200,150) 2. draws a 150 wide by 200 high rectangle with coordinates at location, (1,2) 3. draws a 1 pixel wide by 2 pixel high rectangle at a location with the coordinates, (200,150) 4. draws a 200 wide by 150 pixel high rectangle at the location with the coordinates, (1,2).

draws a 1 pixel wide by 2 pixel high rectangle at a location with the coordinates, (200,150)

GUI stands for ______________. 1. graphics using inheritance 2. graphics user infrastructure 3. graphical user interface 4. None of the above

graphical user interface

When an array is passed to a method ________________. 1. only the reference is passed, and a copy of the array is not created in the method. 2. a copy of the array is created within the method. 3. the value of the array is passed into the method. 4. None of the above.

only the reference is passed, and a copy of the array is not created in the method.

We call a unit of execution in a sort (which usually is repeated) a ________. 1. sorting pass 2. sort iteration 3. sorting run 4. None of the above

sorting pass

Class variables use this modifier: 1. shared 2. static 3. group 4. class

static

What is the worst case scenario for a linear search searching a list for the largest element? 1. the numbers are sorted in descending order 2. the numbers are sorted in ascending order 3. the numbers are completely randomised. 4. the numbers are sorted largest, smallest, second largest, second smallest, etc.

the numbers are sorted in ascending order


Set pelajaran terkait

ANTH 1003 Week 3 (Auburn - Monica Cox)

View Set

Object-Oriented Programming and Java

View Set

MIDTERM- Comparative Health Politics

View Set

abdominal 1 pathology key pearls FINAL

View Set

Cengage Windows Server 2019 - Module 5 - Configuring Resource Access (Exam Notes)

View Set