WGU C949 GRADED A+ TO PASS
WGU C949 GRADED A+ TO PASSbinary search first checks the middle element of the list. If the search key is found, the algorithm returns the matching location. If the search key is not found, the algorithm repeats the search on the remaining left sublist (if the search key was less than the middle element) or the remaining right sublist (if the search key was greater than the middle element) linear search may require searching all list elements 00:02 01:45 selection sort sorting algorithm that treats the input as two parts, a sorted part and an unsorted part, and repeatedly selects the proper next value to move from the unsorted part to the end of the sorted part. selection sort f(numbers, numbersSize) { i = 0 j = 0 indexSmallest = 0 temp = 0 for (i = 0; i < numbersSize - 1; ++i) { indexSmallest = i for (j = i + 1; j < numbersSize; ++j) { if ( numbers[j] < numbers[indexSmallest] ) { indexSmallest = j } } // Swap numbers[i] and numbers[indexSmallest] temp = numbers[i] numbers[i] = numbers[indexSmallest] numbers[indexSmallest] = temp } } insertion sort sorting algorithm that treats the input as two parts, a sorted part and an unsorted part, and repeatedly inserts the next value from the unsorted part into the correct location in the sorted part. insertion sort f(numbers, numbersSize) { i = 0 j = 0 temp = 0 // Temporary variable for swap for (i = 1; i < numbersSize; ++i) { j = i // Insert numbers[i] into sorted part // stopping once numbers[i] in correct position while (j > 0 && numbers[j] < numbers[j - 1]) { // Swap numbers[j] and numbers[j - 1] temp = numbers[j] numbers[j] = numbers[j - 1] numbers[j - 1] = temp --j } } } shell sort sorting algorithm that treats the input as a collection of interleaved lists, and sorts each list individually with a variant of the insertion sort algorithm. shell sort Uses gap values to determine the number of interleaved lists shell sort def g(numbers, start_index, gap): for i in range(start_index + gap, len(numbers), gap): j = i while (j - gap >= start_index) and (numbers[j] < numbers[j - gap]): temp = numbers[j] numbers[j] = numbers[j - gap] numbers[j - gap] = temp j = j - gap def f(numbers, gap_values): for gap_value in gap_values: for i in range(gap_value): g(numbers, i, gap_value) quicksort sorting algorithm that repeatedly partitions the input into low and high parts (each part unsorted), and then recursively sorts each of those parts. merge sort sorting algorithm that divides a list into two halves, recursively sorts each half, and then merges the sorted halves to produce a sorted list
Written for
- Institution
- WGU C949
- Course
- WGU C949
Document information
- Uploaded on
- November 28, 2022
- Number of pages
- 2
- Written in
- 2022/2023
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
- the algor
-
wgu c949 graded a to pass
-
binary search first checks the middle element of the list if the search key is found
-
the algorithm returns the matching location if the search key is not found
Also available in package deal