Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello this quesion is related to Java Please don\'t answer with your handwriting

ID: 3741361 • Letter: H

Question

Hello

this quesion is related to Java

Please don't answer with your handwriting

thank you

Explain how we can apply Binary Search algorithm either directly or indirectly in the following cases: a) Array1 is an array of sorted integers numbers: (You must choose an element to show the steps) Array1: 15 7 13 16 2238 55 70 90 b) Array2 is an array of unsorted integers numbers (You can choose an element to show the steps) Array2: 300 20 121 30 110 25 122 200 250 20 c) Array3 is an array of Strings The order of sorting is alphabetical (e.g. "AA* before "BC" and "AA before "AB"). (You san choose an element to show the stespes) Array3

Explanation / Answer

Binary search is applied of an array
if it is already sorted. If we want to apply binary search to an unsorted array
the array has to be sorted first

A)
Given array is
1 5 7 13 16 22 38 55 70 90

Since the array is already sorted, binary search can be directly applied to search and element in the sorted array.


B)
Given array is
300 20 121 30 110 25 122 200 250 20

Since the array is unsorted, binary search cannot be directly applied. First the array needs to be sorted. After sorting array will be
20 20 25 30 110 121 122 200 250 300

Now the array is sorted and binary search can be directly applied to search an element in array

C)
Given array is
AA AB BA BC CN FA LZ MN ZN

Since the array is already sorted, binary search can be directly applied to search and element in the sorted array without changing the array

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote