Exam 14: Sorting and Searching
Exam 1: Introduction96 Questions
Exam 2: Fundamental Data Types103 Questions
Exam 3: Decisionseasy99 Questions
Exam 4: Loops100 Questions
Exam 5: Methods94 Questions
Exam 6: Arrays and Arraylists100 Questions
Exam 7: Inputoutput and Exception Handling100 Questions
Exam 8: Objects and Classes101 Questions
Exam 9: Inheritance and Interfaces99 Questions
Exam 10: Graphical User Interfaces54 Questions
Exam 11: Advanced User Interfaces91 Questions
Exam 12: Object-Oriented Design100 Questions
Exam 13: Recursion100 Questions
Exam 14: Sorting and Searching99 Questions
Exam 15: The Java Collections Framework100 Questions
Exam 16: Basic Data Structures94 Questions
Exam 17: Tree Structures100 Questions
Exam 18: Generic Classes78 Questions
Exam 19: Streams and Binary Inputoutput82 Questions
Exam 20: Multithreading82 Questions
Exam 21: Internet Networking74 Questions
Exam 22: Relational Databases75 Questions
Exam 23: XML74 Questions
Exam 24: Web Applications74 Questions
Select questions type
Selection sort has O(n2) complexity. If a computer can sort 1,000 elements in 4 seconds, approximately how many seconds will it take the computer to sort 1,000 times that many, or 1,000,000 elements?
(Multiple Choice)
4.8/5
(30)
Find the simplest order of growth of the following expression: n3 + log(n5).
(Multiple Choice)
4.9/5
(35)
Which function has a faster growth rate: θ(n1/2) or θ(log(n))?
(Multiple Choice)
4.8/5
(36)
Consider the swap method shown below from the SelectionSorter class. If we modified it as shown in the swap2 method shown below, what would be the effect on the sort method?
Private static void swap(int[] a, int i, int j)
{
Int temp = a[i];
A[i] = a[j];
A[j] = temp;
}
Private static void swap2(int[] a, int i, int j)
{
A[i] = a[j];
A[j] = a[i];
}
(Multiple Choice)
4.8/5
(36)
Complete the following code that is intended to provide a comparator interface that will be used to create an object that implements the Comparator interface so that object can compare Auto objects.
___________________________
{
Int compare(Auto a, Auto b);
}
(Multiple Choice)
4.9/5
(37)
Which of the following classes implement the Comparable interface?
I Date
II Collections
III String
(Multiple Choice)
4.9/5
(44)
Consider an array with n elements. If we visit each element n times, how many total visits will there be?
(Multiple Choice)
4.9/5
(35)
Consider the minimumPosition method from the SelectionSorter class. Complete the code to write a maximumPosition method that returns the index of the largest element in the range from index from to the end of the array.
Private static int minimumPosition(int[] a, int from)
{
Int minPos = from;
For (int i = from + 1; i < a.length; i++)
{
If (a[i] < a[minPos]) { minPos = i; }
}
Return minPos;
}
Private static int maximumPosition(int[] a, int from)
{
Int maxPos = from;
For (int i = from + 1; i < a.length; i++)
{
________________
}
Return maxPos;
}
(Multiple Choice)
4.9/5
(35)
In big-Oh notation, suppose an algorithm requires an order of n3 element visits. How does doubling the number of elements affect the number of visits?
(Multiple Choice)
4.7/5
(41)
In big-Oh notation, when we consider the order of the number of visits an algorithm makes, what do we ignore?
I power of two terms
II the coefficients of the terms
III all lower order terms
(Multiple Choice)
4.7/5
(48)
The following code is an example of a ___ search.
Public static int search(int[] a, int v)
{
For (int i = 0; i < a.length; i++)
{
If (a[i] == v) { return i; }
}
Return -1;
}
(Multiple Choice)
4.8/5
(42)
After 9 iterations of selection sort working on an array of 10 elements, what must hold true?
(Multiple Choice)
4.8/5
(32)
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
(40)
In the textbook, we determined that the merge method requires a total of 5n visits. We found that the number of visits required to sort an array of n elements is T(n) = T(n / 2) + T(n / 2) + 5n. What does T(n / 2) describe?
(Multiple Choice)
4.9/5
(36)
Which of the sorts in the textbook can be characterized by the fact that the best case will have a running time of θ(n) if the data is already sorted?
I quicksort
II selection sort
III insertion sort
(Multiple Choice)
4.8/5
(31)
Suppose the call obj1.compareTo(obj2) returns 0. What can definitely be concluded from the return value?
I obj1 and obj2 are the same object
II obj1 and obj2 objects cannot be compared
III the properties of obj1 and obj2 that are being compared have identical values
(Multiple Choice)
4.8/5
(34)
A search technique where, in each step, you split the size of the search in half is called a____ search.
(Multiple Choice)
4.8/5
(45)
Showing 41 - 60 of 99
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)