Question: Q.5 An array has each distinct value 3 times contiguously except one value that is exactly 2 times. For example, 8, 8, 8, 2, 2,

Q.5 An array has each distinct value 3 times contiguously except one value that is exactly 2 times. For example, 8, 8, 8, 2, 2, 2, 0, 0, 0,3,3,3,7,7,6, 6, 6. Your job is to find the value that occurs two times. a. Write a linear time algorithm that does the job. Your code should be well-commented and variable names should make sense. 5. Write a logarithmic time algorithm that does the job. You can write your code recursively or iteratively. Your code should be well-commented and variable names should make sense. Q.6 Find the recurrence relation for the time function of this function. MysteryFunction (A, start, end) if end > start: breakpointl = start + (end-start) /4 breakpoint2 = start + 2* (end-start) /4 Breakpoint3 = start + 3* (end-start)/4 MysteryFunction (A, start, breakpoint3) Another Function (A, start, end) else: blahblah 1/blahblah takes constant time where AnotherFunction is quadratic as a function of n Note: I am only asking you to write the recurrence relation for this recursive function. Don't solve the recurrence relation
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
