Vous êtes sur la page 1sur 1

Test 1, Question 1:

Input:

An ordered array A[1,.,n] n,size of array.

Output:

An ordered array B which has all values from A, but without duplicate
entries, and List of all values in A that were duplicate the maximum no
of times.

MYALGO(A, n)
1. samedatatypeas_A: B[1,.,n]
2. integer:C[1,..n]
3. j<=1 k1
4. B[j]A[i]
5. for i2 to n
6.
if B[j]=A[i] then
7.
kk+1
8.
else
9.
C[j]k
10.
k1
11.
jj+1
12.
B[j]A[i]
13.
endif
14. next i
15. maxC[i]
16. for i2 to j
17.
if C[i]>max then
18.
maxC[i]
19.
end if
20. next i
21. outputB
22. for i1 to j
23.
if C[i]=max then
24.
outputB[i]
25.
end if
26. next i

Vous aimerez peut-être aussi