Exam 14: Sorting and Searching
Exam 1: Introduction98 Questions
Exam 2: Using Objects76 Questions
Exam 3: Implementing Classes103 Questions
Exam 4: Fundamental Data Types125 Questions
Exam 5: Decisions120 Questions
Exam 6: Loops128 Questions
Exam 7: Arrays and Array Lists118 Questions
Exam 8: Designing Classes95 Questions
Exam 9: Inheritance101 Questions
Exam 10: Interfaces85 Questions
Exam 11: Inputoutput and Exception Handling109 Questions
Exam 12: Object-Oriented Design104 Questions
Exam 13: Recursion110 Questions
Exam 14: Sorting and Searching109 Questions
Exam 15: The Java Collections Framework110 Questions
Exam 16: Basic Data Structures104 Questions
Exam 17: Tree Structures110 Questions
Exam 18: Generic Classes75 Questions
Exam 19: Graphical User Interfaces76 Questions
Exam 20: Streams and Binary Inputoutput82 Questions
Exam 21: Multithreading82 Questions
Exam 22: Internet Networking74 Questions
Exam 23: Relational Databases75 Questions
Exam 24: XML74 Questions
Exam 25: Web Applications75 Questions
Select questions type
Which sort algorithm is used in the sort method in the Java Arrays class when the array length is less than 7?
(Multiple Choice)
4.8/5
(36)
Assume we are using quicksort to sort an array in ascending order. What can we conclude about the indexes of two pivot elements placed in consecutive recursive calls?
(Multiple Choice)
4.8/5
(33)
A portion of your program implements a loop in which each step contains a fixed number of actions. What can you conclude about the running time of this section of code?
(Multiple Choice)
4.8/5
(45)
Which function has a faster growth rate: θ(n1/2) or θ(log(n))?
(Multiple Choice)
4.9/5
(38)
Merge sort has a O(n log2(n)) complexity. If a computer can sort 1,024 elements in an amount of time x, approximately how much longer will it take the computer to sort 1,024 times that many, or 1,048,576 elements?
(Multiple Choice)
4.7/5
(35)
The code segment below displays a pattern of asterisks. Select an expression to complete the code segment so that the resulting algorithm has O(n) running time. for (int k = 0; k < n; k++)
{
For _______________________
{
System.out.print("*");
}
System.out.println();
}
(Multiple Choice)
4.9/5
(37)
Consider the following code snippet: public static void sort(int[]A) insertion sort
(Multiple Choice)
4.9/5
(40)
If the Arrays static method binarySearch is called on an array of 10 elements and returns a value of 10, what can be concluded?
I the element is not found
II that value cannot be returned from method binarySearch
III if added, the element would be the largest element in the array
(Multiple Choice)
4.8/5
(44)
The sort method of the Arrays class sorts arrays containing objects of classes that implement the ____ interface.
(Multiple Choice)
4.8/5
(38)
In the worst case, a linear search locates a value in an array of length n in ____ steps.
(Multiple Choice)
4.7/5
(38)
After 9 iterations of selection sort working on an array of 10 elements, what must hold true?
(Multiple Choice)
4.8/5
(32)
The analysis for the number of visits in a binary search begins with the equation, T(n) = T(n / 2) + 1. What does the number 1 represent in this equation?
(Multiple Choice)
4.8/5
(36)
Suppose you have a phone number and need to find the address that it corresponds to. If there are 2,000,000 entries, how many do you expect to search in a printed phone directory before finding the address you are looking for?
(Multiple Choice)
4.8/5
(38)
Given an ordered array with 15 elements, how many elements must be visited in the worst case of binary search?
(Multiple Choice)
4.8/5
(37)
Given an ordered array with 31 elements, how many elements must be visited in the worst case of binary search?
(Multiple Choice)
4.9/5
(42)
A portion of your program includes the loop shown in the code snippet below to examine the elements of an array arr:
Int count = 0;
Int targetVal = 70;
For (int i = 0; i < arr.length; i++)
{
If (arr[i] >= targetVal)
{
Count++;
}
}
What can you conclude about the running time of this section of code?
(Multiple Choice)
4.8/5
(38)
Which sort algorithm starts with an initial sequence of size 1, which is assumed to be sorted, and increases the size of the sorted sequence in the array in each iteration?
(Multiple Choice)
4.8/5
(37)
If a call to the Arrays static method binarySearch returns a value of -10, what can be concluded?
I the element is not in the array
II the element is at index 10
III the element can be inserted at index 9
(Multiple Choice)
4.9/5
(39)
The method findLargest examines the elements of an array arr which contains non-negative values public static int findLargest(int[] arr)
{
Int curLargest = -1;
For (int i = 0; i < arr.length; i++)
{
If (arr[i] >= curLargest)
{
CurLargest = arr[i];
}
}
Return curLargest;
}
What can you conclude about the running time of this section of code?
(Multiple Choice)
4.8/5
(38)
A search technique where, in each step, you split the size of the search in half is called a____ search.
(Multiple Choice)
4.9/5
(37)
Showing 81 - 100 of 109
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)