Yes , this will work.
Here there are nine elements :
So after pairing , you get
3,1 3,2 3,4 3,5 3
The first four pairs donot yield anything.
The last lone element 3 is alone taken which is infact the majority of the the array.
I would also like to eloborate what Karthik had said:
From the first array , pair the elements. Now if both elements in the pair are the same choose one and add it to another array . say (B) else drop both
This way you will form another array of size N/2+1 (atmost).
Do the same thing recursively to this array and you will get the answer when the array is of size 1.
Vinodh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---
- [algogeeks] Re: find the most occured (... Pradeep Muthukrishnan
- [algogeeks] Re: find the most occur... Vikram Venkatesan
- [algogeeks] Re: find the most ... Pradeep Muthukrishnan
- [algogeeks] Re: find the m... Vikram Venkatesan
- [algogeeks] Re: find the most occured (more tha... Praveen
- [algogeeks] Re: find the most occured (more than N/2... Amit Banwari
- [algogeeks] Re: find the most occured (more tha... Praveen
- [algogeeks] Re: find the most occured (more... Karthik Singaram L
- [algogeeks] Re: find the most occured (... Praveen
- [algogeeks] Re: find the most occur... Vinodh Kumar
- [algogeeks] Re: find the most ... Praveen
- [algogeeks] Re: find the m... Arunachalam
- [algogeeks] Re: find the m... Praveen
- [algogeeks] Re: find the m... Vinodh Kumar
- [algogeeks] Re: find the m... Dhyanesh
- [algogeeks] Re: find the m... Siva
- [algogeeks] Re: find the m... subrahmanyam kambala
- [algogeeks] Re: find the m... Googmeister
- [algogeeks] Re: find the m... Vishal
- [algogeeks] Re: find the most occured (... Googmeister