Page 1 of 1

Question 2 1 pts Suppose you are collecting performance data for the selection sort shown below, and you collect elapsed

Posted: Sun May 15, 2022 2:00 pm
by answerhappygod
Question 2 1 Pts Suppose You Are Collecting Performance Data For The Selection Sort Shown Below And You Collect Elapsed 1
Question 2 1 Pts Suppose You Are Collecting Performance Data For The Selection Sort Shown Below And You Collect Elapsed 1 (24.83 KiB) Viewed 48 times
Question 2 1 Pts Suppose You Are Collecting Performance Data For The Selection Sort Shown Below And You Collect Elapsed 2
Question 2 1 Pts Suppose You Are Collecting Performance Data For The Selection Sort Shown Below And You Collect Elapsed 2 (25.43 KiB) Viewed 48 times
Question 2 1 pts Suppose you are collecting performance data for the selection sort shown below, and you collect elapsed times as shown and graph those times. What trend would you expect the graph to show? 1); void selection_sort(int a[], int size) { int next; for (next = 0; next < size - 1; next++) int min_pos = min_position(a, next, size - if (min_pos != next) { int before = time(); swap(a[min_pos], a[next]); int after = time(); cout << (after - before) << endl; } } } Constant time Linear Log Quadratic

Question 3 1 pts Suppose you want to write an algorithm to find the most frequent element in a vector. The brute force method takes O(n?) time, examining every element and counting the number of occurences for that value. Optimizing the algorithm to not re-examine already tested parts of the vector reduces it to O(n²/2), because each value requires searching one fewer elements. What is that pattern called? Linear Triangle Quadratic Log