Question: 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,

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.

b. 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.

I need an answer for b, I need a log time algorithm for this job

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!