In the linear search, the array [20, -20, 10, 0, 15] is iterated sequentially until the element 0 is found, The binary search for the array [20, 0, 10, 15, 20] finds the element 0 by dividing the search space in half at each iteration, The bubble sort iteratively swaps adjacent elements until the array [20, -20, 10, 0, 15] is sorted in ascending order and The selection sort swaps the smallest unsorted element with the first unsorted element, resulting in the sorted array [20, -20, 10, 0, 15].
The array is now sorted: [-20, 0, 10, 15, 20]
a) Linear Search for 0 in the array [20, -20, 10, 0, 15]:
Iteration 1: Compare 20 with 0. Not a match.
Iteration 2: Compare -20 with 0. Not a match.
Iteration 3: Compare 10 with 0. Not a match.
Iteration 4: Compare 0 with 0. Match found! Exit the search.
b) Binary Search for 0 in the sorted array [0, 10, 15, 20, 20]:
Iteration 1: Compare middle element 15 with 0. 0 is smaller, so search the left half.
Iteration 2: Compare middle element 10 with 0. 0 is smaller, so search the left half.
Iteration 3: Compare middle element 0 with 0. Match found! Exit the search.
c) Bubble Sort for the array [20, -20, 10, 0, 15]:
Iteration 1: Compare 20 and -20. Swap them: [-20, 20, 10, 0, 15]
Iteration 2: Compare 20 and 10. No swap needed: [-20, 10, 20, 0, 15]
Iteration 3: Compare 20 and 0. Swap them: [-20, 10, 0, 20, 15]
Iteration 4: Compare 20 and 15. No swap needed: [-20, 10, 0, 15, 20]
The array is now sorted: [-20, 10, 0, 15, 20]
d) Selection Sort for the array [20, -20, 10, 0, 15]:
Iteration 1: Find the minimum element, -20, and swap it with the first element: [-20, 20, 10, 0, 15]
Iteration 2: Find the minimum element, 0, and swap it with the second element: [-20, 0, 10, 20, 15]
Iteration 3: Find the minimum element, 10, and swap it with the third element: [-20, 0, 10, 20, 15]
Iteration 4: Find the minimum element, 15, and swap it with the fourth element: [-20, 0, 10, 15, 20]
To know more about Iteration refer to-
https://brainly.com/question/31197563
#SPJ11