1. ## algorthims

i need to verify that the following algorthims works on the list 2, 3,6,2,6

Begin
input $x_1$ $x_2$... $x_n$
count := 0
for i:= 2 to n do
begin
for j:=1 to (i-1) do
begin
if $x_i = x_j$ then
begin
count := count +1
end
end
output count
end

much thanks

2. What's it supposed to do? If you are counting duplicates, that's not it. Try 2 3 6 2 6 5 5 5 5 to disprove it.

3. it is meant to count the number of pairs of integers in a list

4. In your universe of inputs, will there EVER be more than two of any single integer?

Your algorithm will produce 3 from 2 2 2. If the trio condition never occurs, then perhaps you are done.

5. Originally Posted by TKHunny

Your algorithm will produce 3 from 2 2 2. If the trio condition never occurs, then perhaps you are done.

i don't understand that how can you get 2 2 2, when there are only two 2's in the list