Putting it together · Uniendo los conceptos
Putting it together
- A real algorithm joins the pieces: arrays, loops and selection.
- The exam's standard methods are totalling, counting, linear search, and finding the maximum or minimum.
Uniendo todo
- Un algoritmo real une las piezas: arrays, bucles y selección.
- Los métodos estándar del examen son la suma total, el conteo, la búsqueda lineal y la búsqueda del máximo o mínimo.
DECLARE A : ARRAY[1:5] OF INTEGER
DECLARE I, Total : INTEGER
FOR I ← 1 TO 5
A[I] ← I * 10
NEXT I
Total ← 0
FOR I ← 1 TO 5
Total ← Total + A[I]
NEXT I
OUTPUT Total
Totalling an array · Sumar un array
Totalling — start at 0, then add each array item as the loop visits it. · Sumar — comenzar en 0, luego sumar cada elemento del array a medida que el bucle lo visita.
Searching and counting
- Linear search: check each item, and set a flag if you find the target.
- Counting: add 1 to a counter each time a rule is true.
Búsqueda y conteo
- Búsqueda lineal: revisa cada elemento y establece una bandera si encuentras el objetivo.
- Conteo: suma 1 a un contador cada vez que se cumple una condición.
DECLARE A : ARRAY[1:5] OF INTEGER
DECLARE I, Target : INTEGER
DECLARE Found : BOOLEAN
FOR I ← 1 TO 5
A[I] ← I * 10
NEXT I
Target ← 30
Found ← FALSE
FOR I ← 1 TO 5
IF A[I] = Target
THEN
Found ← TRUE
ENDIF
NEXT I
OUTPUT Found
Common mistakes
- Plan the structure before you write the pseudocode.
- Match the exam's keywords and layout exactly.
Errores comunes
- Planifica la estructura antes de escribir el pseudocódigo.
- Copia exactamente las palabras clave y la estructura del examen.
Now you try
- Each task uses an array that is filled for you — write the algorithm.
- Press Check answer to test it.
Ahora tú intentas
- Cada tarea utiliza un array que ya está lleno — escribe el algoritmo.
- Presiona Comprobar respuesta para verificarlo.
The array A is filled for you. Total all 5 values and output Total = then the total (it is 25). · El array A está lleno para ti. Suma todos los 5 valores y muestra Total = seguido del total (es 25).
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.
The array A is filled for you. Use a linear search · búsqueda lineal to set Found to · hasta TRUE if 9 is in the array, then output Found. · El array A está lleno para ti. Usa una búsqueda lineal para establecer Found como TRUE si 9 está en el array, luego muestra Found.
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.
The array A is filled for you. Count how many values are greater than 4, then output the count (it is 3). · El array A está lleno para ti. Cuenta cuántos valores son mayores que 4, luego muestra el conteo (es 3).
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.