Standard algorithms
Introduzido
9:16
O Ciclo de Vida do Desenvolvimento de Programas
Cada aplicativo no seu celular foi escrito por alguém assim. Mas eles não começaram digitando código. Antes da primeira linha, o problema foi estudado, a solução…
Narração em inglês · legendas em inglês e 中文 que você pode alternar
Nesta aula
| English | Significado |
|---|---|
| algorithms/ˈælɡərɪθəmz/ | A finite sequence of precise steps for solving a problem or carrying out a task. |
| linear search/ˈlɪnɪə sɜːtʃ/ | busca linear |
| bubble sort/ˈbʌbl sɔːt/ | ordenação por bolha |
| counting/ˈkaʊntɪŋ/ | contagem |
| totalling/ˈtəʊtəlɪŋ/ | soma acumulada |
| value/ˈvæljuː/ | An amount, number or item assigned to a variable or expression, or held by a data object. |
| list/lɪst/ | |
| sorting/ˈsɔːtɪŋ/ | |
| max/min | |
| average/ˈævrɪdʒ/ | |
| loop/luːp/ | A structure that repeats a sequence of instructions. |
| pass/pæs/ | |
| ascending order |
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.
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
compare adjacent, swap if needed
Step through a bubble sort — compare neighbours and swap until everything is in order.
A linear search finds a value by:
Dificuldade 1/5 · Moedas 100 + pequeno bônus na primeira conclusão hoje
Linear search examines items one by one until it finds the value or reaches the end.
Este cartão foi corrigido, por isso aparece em inglês até que a tradução seja atualizada.
Bubble sort
FOR Pass ← 1 TO 9
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
NEXT Pass
- 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.

A bubble sort puts a list in order by:
Dificuldade 1/5 · Moedas 100 + pequeno bônus na primeira conclusão hoje
It swaps out-of-order neighbours and repeats passes until no swaps are needed.
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?
Dificuldade 1/5 · Moedas 100 + pequeno bônus na primeira conclusão hoje
Total ← Total + Value accumulates a sum; Count ← Count + 1 counts occurrences.
Match each standard algorithm to how it works.
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
These four — search, sort, total and max — are the building blocks of most exam algorithms.
Using totalling on the list [2, 4, 6, 8], what is the final total?
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
2 + 4 + 6 + 8 = 20.
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

A linear search looks for 7 in the list 4 9 2 7 5. How many items does it compare before it finds 7, including 7 itself?
Dificuldade 2/5 · Moedas 140 + pequeno bônus na primeira conclusão hoje
It checks 4, 9, 2, then 7: four comparisons.
A program has totalled 5 marks to get 340. What is the average?
Dificuldade 1/5 · Moedas 100 + pequeno bônus na primeira conclusão hoje
Average = total ÷ count = 340 ÷ 5 = 68.
Este cartão é novo, por isso aparece em inglês até que a tradução esteja pronta.
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
O que deu errado? Somente a equipe do site vê isso.