Array Sorting and Runtime for different Sorting Algorithms

Ace your homework & exams now with Quizwiz!

Which one of the following factors does the searching and or sorting of data depend on?

Page title

What is the probability of an array that has already been sorted while performing a sort algorithm?

Very low

Let A be an array of size 5, say [4 3 5 2 1]. When the first pair is examined, the algorithm notes that A[1] > A[2] and swaps the values giving [3 4 5 2 1]. When the next pair is looked at, positions 2 and 3, the 4 = A[2} will be compared to the [5] = A[3]. Because A[2] < A[3], the pair will not be swapped. After the first pass, what will array A look like?

[3 4 2 1 5]

Which one of the following sort algorithms has the same best scenario as merge sort?

Heap

Which one of the following should we use when selecting a sort algorithm to perform a task?

Average and worst cases

Which of the following algorithms has an average runtime performance (Big O Notation) of O(n2)?

Bubble sort

Which one of the following sort algorithms is the easiest one to understand and program?

Bubble sort

Which one of the following sort algorithms has the best worst case scenario?

Merge sort

Let A be an array of size 5, say [4 3 5 2 1]. The first scan will look at each pair of elements starting with the elements in positions 1 and 2, 2 and 3, and so on. What is the last pair looked at?

Positions 4 and 5

Which one of the following sort algorithms has the longest average case runtime?

Shell

Which one of the following sort algorithms has the longest worst case runtime?

Shell

At step i, cells i and i + 1 are compared. At step i + 1, cells i + 1 and i + 2 are compared, and so on. How could you tell if the elements in cells i, i + 1, ..., i + 4 are already in order?

There are no swaps in steps i through i + 3.


Related study sets

The Stress Emotions: Anger, Fear, and Joy/ Stress Prone Personality Traits

View Set

RN Pharmacology Online Practice 2019 A

View Set

Policy Provisions, Options and Riders

View Set

A&P Ch.1 Introduction to the Human Body

View Set

CH 1- ETHICAL REASONING. IMPLICATIONS FOR ACCOUNTING

View Set

Real Estate Investment Trusts {REIT's}

View Set