Highlights
Task:
Homework #2 For each problem show all work. Homework must be submitted in a Word document
1. A binary search of a sorted array with 3 unique elements where the search is always successful can be viewed as an array with each element having a probability of being selected = 1/3 and the number of comparisons a binary search requires to find the element is shown inside the array. 2 1 2 Then the average number of comparisons would be A(3) = (1/3) [2 + 1 + 2] = 5/3 Find the A(7) for an array with 7 elements for the same binary search.
(a) Draw the 7-element array showing the number of comparisons needed to find each element.
(b) Determine A(7)
(c) Using what you learned from parts (a) and (b), find the summation expression for A(n). To simplify your work, assume that n = 2k – 1. Use k in your summation. Leave your answer in closed form in terms of n.
(d) Simplify your a(n) for large values of n. CSPC 502 Homework #2
2. Consider the algorithm below Precondition: n is a non-negative integer function f ( n ) { temp = 0 if (n != 0) { for (i = 1; i <= 3; i++) temp = temp + n * f(n-1) return temp } else return 1; Solve for the closed form by repeated substitution CSPC 502 Homework #2 3. The recurrence relation is given as an = 2an-1 + 3an-2 Use the method linear homogeneous characteristic roots to solve for the closed form, with given initial conditions a0 = 2 and a1 = 4
(a) Find the general solution
(b) Find the Specific solution
(c) Use your closed form result to find a5
The above IT Assignment has been solved by our IT Assignment Experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire considered worthy of the highest distinction.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.