Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(d) Consider a Binary Search algorithm (Algorithm 2): Algorithm 2 To find which (if any) component of the sorted (sub)array alleft...right) equals target. Set /

image text in transcribed
(d) Consider a Binary Search algorithm (Algorithm 2): Algorithm 2 To find which (if any) component of the sorted (sub)array alleft...right) equals target. Set / = left, and set r = right while I sr do Let m be (a) if target equals a[m] then terminate with answer m. end if if target is less than a[m] then set (b) end if if target is greater than a[m] then set (0) end if end while Terminate with answer none. i. Complete the missing parts of the algorithm at (a), (b) and (c). ii. Using Big-O notation, state the time complexity of the algorithm; justify your answer. iii. At each iteration of the algorithm, it compares the target with the current sub-array element a[m]. For the target value = '5' and the following sorted array: 1,2,4,5,6,7, '8', '10', '15', write values of a[m] in sequence, which will be compared with the target value by the algorithm (e) i. Write the insertion sort algorithm that sorts an array alleft...right) into ascending order. ii. Given the following array, 15 3 12 5 9 run the insertion sort algorithm and show the intermediate status of the array until the sorting is completed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are the classifications of Bank?

Answered: 1 week ago