Ejemplo de Algorithm2e
Ejemplo de Algorithm2e
Robert Woodward
25 de diciembre de 2017
1
Entrada: A set C = {c1 , c2 , . . . , cr } of denominations of coins, where
ci > c2 > . . . > cr and a positive number Pk n
Salida: A list of coins d1 , d2 , . . . , dk , such that i=1 di = n and k is
minimized
C←∅
per i ← 1 to r fai
mientras n ≥ ci hacer
C ← C ∪ {ci }
n ← n − ci
fin
fine
devolver C
Algoritmo 2: Change Makes change using the smallest number of coins
2
Entrada: A sequence of integers ha1 , a2 , . . . , an i
Salida: The index of first location witht he same value as in a previous
location in the sequence
location ← 0
i←2
mientras i ≤ n ∧ location = 0 hacer
j←1
mientras j < i ∧ location = 0 hacer
si ai = aj entonces location ← i
en otro caso j ← j + 1
fin
i←i+1
fin
devolver location
Algoritmo 4: FindDuplicate2