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

static int s; \"f1.s)5 . F2.s); sf3.s); oo fi new FooC) System.out i s 11.41.ss

ID: 3909555 • Letter: S

Question

static int s; "f1.s)5 . F2.s); sf3.s); oo fi new FooC) System.out i s 11.41.ss out . printin("f2.? is " + f2.1+ " f2.s is Foo f2-new Foo) Foo f3 -new Foo) out .printin(-F3.1 ?,' + f3.1 + " f3.5 ?s-+ is f3.i public Foo) i++i a) 3.i is 1 13.s is 4 b) f3.i is 1 f3.s is 3 c) f3.i is 1 13.s is 2 d) f3.i is 3 f3.s is 1 CA 6. 12 points] Suppose you have a sorted list of 4000 names, and you are searching through it using binary search. What's the maximum number of steps (worst case) it would take 7. 15 points] For the following box, show how each list is sorted using Merge sort algorithms, indicates after every swap or after any change in the list step by step ( no Java code) Merge sort: [2, 7, 4,9, 3, 1]

Explanation / Answer

5. The answer is b)

6 Binary Search .The worst case will be depth of the tree .For binary tree we have
the height of the binary tree is of O(log2(n)) . So with that we have

        log2(4000) = 11.9 approx 12 steps


7
Mergesort [2,7,4,9,3,1]

    start index = 0   end index = 5
    mid = 0 + 5/2 = 2

Step1   [2,7,4]      [9,3,1]


Step2 [2,7] [4]      [9,3] [1]


Step3 [2] [7] [4]    [9] [3] [1]

Step4 [2,7] [4]      [3,9] [1]

Step5 [2,4,7]        [1,3,9]

Step6 [1,2,3,4,7,9]