Exam 16: Sorting, Searching, and Algorithm Analysis
Exam 1: Introduction to Computers and Java42 Questions
Exam 2: Java Fundamentals53 Questions
Exam 3: Decision Structures52 Questions
Exam 4: Loops and Files48 Questions
Exam 5: Methods50 Questions
Exam 6: A First Look at Classes49 Questions
Exam 7: A First Look at Gui Applications49 Questions
Exam 8: Arrays and the Arraylist Class52 Questions
Exam 9: A Second Look at Classes and Objects40 Questions
Exam 10: Text Processing and More About Wrapper Classes49 Questions
Exam 11: Inheritance49 Questions
Exam 12: Exceptions and Advanced File Io46 Questions
Exam 13: Advanced Gui Applications46 Questions
Exam 14: Applets and More39 Questions
Exam 15: Recursion34 Questions
Exam 16: Sorting, Searching, and Algorithm Analysis46 Questions
Exam 17: Generics50 Questions
Exam 18: Collections50 Questions
Exam 19: Array-Based Lists20 Questions
Exam 20: Linked Lists36 Questions
Exam 21: Stacks and Queues36 Questions
Exam 22: Binary Trees, Avl Trees, and Priority Queues45 Questions
Select questions type
A contiguous segment of an array is specified using two subscripts,lower and upper.Which expression gives the position of the element in the middle of the array segment?
(Multiple Choice)
4.9/5
(34)
The two criteria most often used to measure the efficiency of an algorithm are
(Multiple Choice)
4.7/5
(32)
Consider the code
Static void doQuickSort(int array[ ],int start,int end){
Int pivotPoint;
If (start < end){
PivotPoint = partition(array,start,end);
DoQuickSort(array,start,pivot-1);
DoQuickSort(array,pivot+1,end);
}
}
In this code,the value pivotPoint returned by partition
(Multiple Choice)
4.8/5
(32)
Assuming a method
Int findMax(int array[ ],int last)that returns the subscript of the largest value in the portion of an array whose elements are at 0 through last (inclusive),a method for sorting an array in ascending order can be written as follows:
Void sort(int array[ ]){
For (int last = array.length-1;last >=1;last --){
Int maxPos = findMax(array,last);
// Code is missing
}
}
If a method
Void swap(int array[ ],int pos1,int pos2)can be used to swap the contents of two array entries,then the logic for the missing code is
(Multiple Choice)
4.9/5
(32)
To compare String objects for the purpose of sorting,a programmer should
(Multiple Choice)
4.8/5
(45)
The method int getPosition(int array[],int X)is designed to return the position of X within the array.If X is not in the array,the method may return either -1 or array.length.Which of the following is a correct implementation for this method?
(Multiple Choice)
4.9/5
(38)
On the average,performing a sequential search on an array of N elements will require
(Multiple Choice)
4.8/5
(34)
A search for an item X in a portion of a sorted array works by repeatedly selecting the middle item and comparing it to X.If X is not found there,the search method selects either the portion of the array to the left of the middle item,or the portion of the array to the right of the middle item,and continues the search.This method is called
(Multiple Choice)
4.8/5
(41)
Let F be an algorithm with complexity function f(n),and let G be an algorithm with complexity function g(n).If the ratio f(n)/g(n)converges to 0 as n increases to infinity,then
(Multiple Choice)
4.8/5
(39)
An array of 4 elements is being sorted in ascending order using the insertion sort algorithm.How many comparisons will insertion sort perform if the array was originally sorted in descending order?
(Multiple Choice)
4.9/5
(34)
Let F be an algorithm with complexity function f(n),and let G be an algorithm with complexity function g(n).If the ratio f(n)/g(n)converges to 2 as n increases to infinity,then
(Multiple Choice)
4.7/5
(43)
If a[ ] is an array of integers,the pseudo code
Int k = 0
Int m = 1
While m < a.length
If a[m] < a[k] Then
K = m
End If
M = m+1
End While
Describes a strategy for
(Multiple Choice)
4.8/5
(32)
If an algorithm with an input size of n has a nested loop,and both loops make a complete pass over the input,then the performance of the algorithm will be
(Multiple Choice)
4.8/5
(30)
The role of the partition(array,start,end)method in Quicksort
(Multiple Choice)
4.9/5
(31)
Showing 21 - 40 of 46
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)