Given int number[8] = {15, 27, 16, 49, 62, 75, 83, 96}, and the target values of
ID: 3854789 • Letter: G
Question
Given int number[8] = {15, 27, 16, 49, 62, 75, 83, 96}, and the target values of 83, assuming that binary search is used, list the values of all the array elements which will be compared with 83, in the order in which they will be compared, before binary search concludes that 83 occurs in the array? How many elements compared with 83: ____ Value of second element compared with 83: ____ Value of second element compared with 83: ____ Value of third element compared with 83: ____ Values of other elements compared with 83, if any: ____ Assuming the declaration for a structure named FUN as given below, write C code to declare an array named my_fun of size 20, each of whose elements is of type FUN. typdef struct {char* x: char y: int z[200];} FUN: The required declaration: _____ A sorting algorithm is used to sort an int array with initial contents as shown below: After two passes of the sorting algorithm are executed, the array contents are in increasing order, as shown below: Name of the sorting algorithm used is: ____Explanation / Answer
48. Given array is {15,27,36,49,62,75,83,96};
Indices are, start = 0, end = 7
mid = (start+end)/2; = 3, So, 83 is compared with 49. ----- Comparision 1
start = 4 and end = 7, mid = 5. 83 is compared with 75. -- Comparision 2
start = 6 and end = 7, mid = 6, 83 is compared with 83 ---- Comparision 3
Total 3 comparisions
Value of the first element compared with 83 is 49
Value of the second element compared with 83 is 75
Value of the third element compared with 83 is 83
No elements are compared further. Only three comparisions
49. declaration is FUN my_fun[20];
50. initial contents are 50 40 30 20 10. After 2 passes, the array is
10 20 30 40 50
So, it's approximately equivalent to O(log N) time.
So, sorting algorithm could be Merge Sort
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.