Study Guide |Questions And Answers
true or false: in an array is already sorted, linear search / sequential search is more
effective than binary search correct answersfalse
what must be true before performing a binary search correct answersthe elements must
be sorted how are selection sort and insertion sort different correct answerswhen
selection sort places an element into the sorted part of the array, that element is in its
final position. Whereas insertion sort may move that element later if it finds a smaller
element. Selection sort builds up an absolutely sorted array as it goes while insertion
sort builds up a relatively sorted array as it goes. Insertion sort is faster is the array is
already sorted or close to sorted
what is the correct pseudocode for Insertion Sort? correct answersstart with the first
element and sort it with itself
while there is a next element
compare the next unsorted element with the sorted elements
insert the element into the correct position in the sorted elements
for an array containing these numbers [1, 2, 3, 4, 5] how many comparisons are made
using selection sort correct answers10
which of the sorting algorithms we learned uses recursion correct answersmerge sort
what is a potential drawback of using mergesort correct answersit uses more memory
suppose we have a sorted list with 5 elements. We decide to perform an insertion sort
on this already sorted set. how many comparisons will the sort make? what if there are
10 elements correct answersn - 1
what condition must be true in order to sort objects correct answersthey must be
comparable
consider the following recursive function:
public int mystery(int n)
{
if(n = 0)
{
return 2;
}
else
{