Standard algorithms · Algoritmos padrão
| English | Português |
|---|---|
| linear search/ˈlɪnɪə sɜːtʃ/ | busca linear |
| bubble sort/ˈbʌbl sɔːt/ | ordenação por bolha |
| counting/ˈkaʊntɪŋ/ | contando |
| totalling/ˈtəʊtəlɪŋ/ | totalização |
The classic recipes
- A few standard algorithms appear again and again.
- You must know linear search 线性查找, bubble sort 冒泡排序, and the counting 计数/totalling 求和 patterns.
- Each is short, but worth recognising instantly.
As receitas clássicas
- Alguns algoritmos padrão aparecem repetidamente.
- Você precisa conhecer busca linear 线性查找, ordenação bubble 冒泡排序 e os padrões de contagem 计数/soma total 求和.
- Cada um é curto, mas vale a pena reconhecer instantaneamente.
Linear search
- A linear search checks each item in turn, from the start, until it finds the value (or reaches the end).
- It works on any list — no sorting needed.
A flowchart for the sum algorithm, using the standard symbols (start/end, input/output, process, decision).
Busca linear
DECLARE Found : BOOLEAN
Found ← FALSE
FOR I ← 1 TO 10
IF List[I] = SearchValue
THEN
Found ← TRUE
ENDIF
NEXT I
OUTPUT Found
- Uma busca linear verifica cada item sequencialmente, do início, até encontrar o valor (ou chegar ao fim).
- Funciona em qualquer lista — sem necessidade de ordenação.

Um fluxograma para o algoritmo de soma, usando símbolos padrão (início/fim, entrada/saída, processo, decisão).
Standard algorithms · Algoritmos padrão
compare adjacent, swap if needed · comparar adjacentes, trocar se necessário
Step through a bubble sort — compare neighbours and swap until everything is in order. · Faça o passo a passo de uma ordenação bubble — compare vizinhos e troque até que tudo esteja em ordem.
A linear search finds a value by: · Uma busca linear encontra um valor por:
Linear search examines items one by one until it finds the value or reaches the end. · A busca linear examina itens um por um até encontrar o valor ou atingir o fim.
Bubble sort
- A bubble sort compares each side-by-side pair and swaps them if they are out of order.
- It repeats this until no more swaps are needed — leaving the list sorted.
Bubble sort compares each side-by-side pair and swaps them if they are out of order, repeating until sorted.
Ordenação bolha (Bubble sort)
FOR I ← 0 TO 8
IF List[I] > List[I + 1]
THEN
Temp ← List[I]
List[I] ← List[I + 1]
List[I + 1] ← Temp
ENDIF
NEXT I
- Uma ordenação bubble compara cada par lado a lado e troca eles se estiverem fora de ordem.
- Repete isso até que nenhuma troca seja mais necessária — deixando a lista ordenada.

Ordenação bubble compara pares lado a lado e os troca se estiverem fora de ordem, repetindo até ordenar.
A bubble sort puts a list in order by: · Uma ordenação bubble coloca uma lista em ordem através de:
It swaps out-of-order neighbours and repeats passes until no swaps are needed. · Ela troca vizinhos fora de ordem e repete as passagens até que nenhuma troca seja necessária.
Totalling, counting, max/min/average
- Totalling — keep a running total:
Total ← Total + Value. - Counting — add 1 each time something happens:
Count ← Count + 1. - Maximum/minimum — keep the largest/smallest value seen so far.
- Average — divide the total by how many values there are.
Soma total, contagem, máximo/mínimo/média
- Soma total — manter um total acumulado:
Total ← Total + Value. - Contagem — adicionar 1 sempre que algo acontecer:
Count ← Count + 1. - Máximo/mínimo — manter o maior/menor valor visto até agora.
- Média — dividir o total pela quantidade de valores.
Which line adds a value to a running total? · Qual linha adiciona um valor a um total acumulado?
total ← total + value accumulates a sum; count ← count + 1 counts occurrences. · total ← total + value acumula uma soma; count ← count + 1 conta ocorrências.
Match each standard algorithm to how it works. · Combine cada algoritmo padrão com como ele funciona.
These four — search, sort, total and max — are the building blocks of most exam algorithms. · Estes quatro — busca, ordenação, totalização e máximo — são os blocos de construção da maioria dos algoritmos de exame.
Using totalling on the list [2, 4, 6, 8], what is the final total? · Usando totalização na lista [2, 4, 6, 8], qual é o total final?
2 + 4 + 6 + 8 = 20.
You've got it
- linear search checks each item in turn (works on any list)
- bubble sort swaps out-of-order neighbours, repeating until sorted
- totalling (
Total ← Total + Value) and counting (Count ← Count + 1) - max/min = keep the best so far; average = total ÷ count
Entendeu?
- busca linear verifica cada item sequencialmente (funciona em qualquer lista)
- ordenação bubble troca vizinhos fora de ordem, repetindo até ordenar
- soma total (
Total ← Total + Value) e contagem (Count ← Count + 1) - máx/mín = manter o melhor até agora; média = total ÷ contagem