Exam 16: Sorting, Searching, and Algorithm Analysis

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

A computational problem is

(Multiple Choice)
4.9/5
(38)

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)

The best way to measure the goodness of an algorithm is

(Multiple Choice)
4.9/5
(37)

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)

The addition of two integers

(Multiple Choice)
4.9/5
(28)

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)

The Quicksort algorithm works by

(Multiple Choice)
4.8/5
(32)

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)

The Quicksort algorithm

(Multiple Choice)
4.9/5
(36)

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)

A basic step is

(Multiple Choice)
4.9/5
(42)

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
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)