I've been stuck on a divide a conquer algorithm problem for about an hour now, and I'm not sure how to solve it. I need to use divide-and-conquer to implement an algorithm that finds the dominant element of an array of positive integers and returns -1 if the array does not have a dominant element (a dominant element is one that occurs in more than half the elements of a given array).
No sorting may be used, and the only comparison that may be used is a test for equality.
I understand the general process I need to follow to solve this problem, but I'm not sure exactly how to convert my thoughts to code. I know that if a number x is the dominant element of an array A, the x must be the dominant element in either the first half of A, the second half of A, or both.
As a d&c I may recommend to find a median (linear time, http://en.wikipedia.org/wiki/Selection_algorithm) and then check if this element is a dominant one. But median search will require comparison.
Thanks for the input tfityo, I didn't find either link helpful. I just need to find out how many times each number occurs in the array, and if any number occurs in more than half the elements, output that number to the console.
I was never taught how to do some of the stuff required for this program, so any help is still appreciated!