4. Do you use binary or sequential search for this list? for some would you use
ID: 3812081 • Letter: 4
Question
4. Do you use binary or sequential search for this list? for some would you use binary search or sequential search to search through the following list number? Why? [5, 6, 3, 1, 14, 22] 5. [18ptsl Identify the algorithm being used to sort each of the following lists, and finish sorting the list showing the new list at each step of the algorithm. Algorithm A [4, 1, 3, 7, 2] Original List: [1, 4, 3, 7, 2] First iteration: [1, 3, 4, 7, 2] Second iteration: Third iteration: Fourth iteration (if needed, otherwise leave blank): Fifth iteration d, otherwise leave blank): Name of Algorithm A: Algorithm B [4, 1, 6, 7, 2] Original List: [1, 4, 6, 7, 21 [1, 2, 6, 7, 4] First iteration: Second iteration: Third iteration: Fourth iteration (if needed, otherwise leave blank): Fifth iteration (if needed, otherwise leave blank) Name of Algorithm B:Explanation / Answer
Ans 4: We would use Sequential search instead of Binary Search. This is so because, the input data is not sorted. For Binary search to come into play, input data must be sorted. Sorting data with the most efficient algorithm costs O(nlogn) which is much larger than the cost of carrying out a simple Sequential search of O(n). So, it is meaningless to sort data just to perform a single binary search later. Thus, using sequential search is a better option in this case.
Ans 5) Algorithm A:
Third Iteration : 1,3,4,2,7
Fourth Iteration : 1,3,2,4,7
Fifth Iteration : 1,2,3,4,7
Name of Algorithm A : Bubble Sort
Algorithm B:
Third Iteration : 1,2,4,7,6
Fourth Iteration : 1,2,4,6,7
Fifth Iteration:
Name of Algorithm B: Selection Sort
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.