Impleminyation of MAJPRITY ALGORITHM

i want to write MAJORITY ALGORITHM in bothrecursive as well asiterative manner.

i tryed but i could not , can any one help me please.

this is the algorithm:

Algorithm MAJORITY

Input An array A[100n] of n element

Output The majorty element if it exist; otherwise none.

1. c < candidate(1)

2. count < 0

3. for j < 1 to n

4.if A[j]= c then

count= count+1

5. end for

6. if count >n/2then return c

7. else return none

Precedure candidate (m)

1. j < m; c< A[m]; count < 1

2. while j<n and count >0

3. j < j+1

4.if A[j]=c then count < count+ 1

5.else count < count-1

6.end while

7. if j=n then return c

8. else return candidate (j+1)

Best regard

[835 byte] By [msasa] at [2007-10-1 9:35:13]
# 1
Sure I can help you. I should be able to start on Sunday anf finish by Tuesday. Is that OK?
sabre150a at 2007-7-10 2:00:55 > top of Java-index,Other Topics,Algorithms...
# 2
> Sure I can help you. I should be able to start on> Sunday anf finish by Tuesday. Is that OK?Billing at your usual $300/hr?
RadcliffePikea at 2007-7-10 2:00:55 > top of Java-index,Other Topics,Algorithms...
# 3
> > Sure I can help you. I should be able to start on> > Sunday anf finish by Tuesday. Is that OK?> > Billing at your usual $300/hr?Nearly right - ?00/hr.
sabre150a at 2007-7-10 2:00:55 > top of Java-index,Other Topics,Algorithms...