Okay
Okay
Okay
## 10.2 Arrays
The upper and lower bounds of an array refer to the smallest/highest number index
of an array dimension.
**Linear search**
Checking each element of an array in turn for a required value, O(n).
```
DECLARE MyList: ARRAY[0:6] OF INTEGER
MyList <- LoadedList (of same size)
Index <- -1
Found <- FALSE
MaxIndex <- 6
INPUT SearchValue
REPEAT
Index <- Index + 1
IF MyList[Index] = SearchValue THEN
Found <- TRUE
ENDIF
UNTIL FOUND = TRUE OR Index = MaxIndex
**Bubble sort**
A sort method where adjacent values are compared and swapped. This code will sort
them to ascending order.
```
DECLARE UnsortedList: ARRAY[0:6] OF INTEGER
UnsortedList <- LoadedList (of same size) //unsorted integers
MaxIndex <- 6
n <- MaxIndex - 1
REPEAT
NoMoreSwaps <- TRUE
FOR i <- 0 TO n
IF UnsortedList[i] > UnsortedList[i+1] THEN
Temp <- UnsortedList[i]
UnsortedList[i] <- UnsortedList[i+1]
UnsortedList[i+1] <- Temp
NoMoreSwaps <- FALSE
ENDIF
NEXT i
UNTIL NoMoreSwaps = TRUE
```
## 10.3 Files
**Write pseudocode to handle text files that consist of one or more lines**
- Files are needed for data to be stored permanently.
```
//reading from one file and writing to another (copying)
OPENFILE "one.txt" FOR READ
OPENFILE "two.txt" FOR WRITE
CLOSEFILE "one.txt"
CLOSEFILE "two.txt"
```