My professor in ‘project in algorithms’ class created this problem just for this assignment. I implemented an algorithm that finds majority element in private array using “group counts” in C.
The problem is to determine whether 0 or 1 is the majority element of a private array who we don’t have an direct access to. We can only use “group counts” method, which, given 4 indices in the array, returns one out of three values.
These are some of the most frequent mistakes students made in the lab when I worked as a tutor for ICS 46, Data Structure Implementation and Analysis. Anyone who is taking the class could benefit by reviewing these examples and trying to figure out what is wrong with each of them. I will explain what kind of errors each method contains and how to fix them at the bottom of this post.