Table of contents | |
Linear Search | |
Bubble Sort | |
Totalling & Counting | |
Maximum, Minimum & Average |
OUTPUT “Enter a value to find”
INPUT Number
Found ← FALSE
Index ←1
REPEAT
IF Number = Mylist[Index]
THEN
Found ← TRUE
ELSE
Counter ← Counter + 1
ENDIF
UNTIL Found =TRUE OR Counter > LENGTH(Mylist)
IF Found = TRUE
THEN
OUTPUT Number, “ found at position “, Counter
ELSE
OUTPUT Number, “ not found”
ENDIF
Mylist ← [5, 9, 4, 2, 6, 7, 1, 2, 4, 3]
FirstElement ← 1
LastElement ← LENGTH(Mylist)
REPEAT
Swap ← FALSE
For Index ← FirstElement TO LastElement - 1
IF Mylist[Index] > Mylist[Index + 1]
THEN
Temp ← Mylist[Index]
Mylist[Index] ← Mylist[Index + 1]
Mylist[Index + 1] ← Temp
Swap ← TRUE
ENDIF
NEXT Index
LastElement ← LastElement - 1
UNTIL Swap = FALSE OR LastElement = 1
OUTPUT “Your sorted list is:”, Mylist
Total ← 0
FOR Count ← 1 TO ReceiptLength
INPUT ItemValue
Total ← Total + itemValue
NEXT Count
OUTPUT Total
Count ← 0
DO
OUTPUT “Pass number”, Count
Count ← Count + 1
UNTIL Count >= 50
Count ← 50
DO
OUTPUT “Pass number”, Count
Count ← Count - 1
UNTIL Count <= 0
Max ← Score[1]
Min ← Score[1]
FOR Count ← 2 TO ScoreSize
IF ScoreSize[Count] > Max
THEN
Max ← ScoreSize[Count]
ENDIF
IF ScoreSize[Count] < Min
THEN
Min ← ScoreSize[Count]
ENDIF
Next Count
Total ← 0
FOR Count ← 1 TO ScoreSize
Total ← Total + ScoreSize[Count]
NEXT Count
Average ← Total / ScoreSize
92 docs|30 tests
|
1. What is linear search and how does it work? |
2. How does bubble sort algorithm work? |
3. How can totalling and counting be implemented in a program using standard methods? |
4. How can the maximum, minimum, and average of a list of numbers be calculated using standard methods? |
5. What are some common applications of linear search and bubble sort algorithms in real-world scenarios? |
|
Explore Courses for Year 11 exam
|