collecting input
input VARIABLE
collecting input with a prompt
VARIABLE = input(“prompt”)
displaying output
output VARIABLE
output “text”
output VARIABLE, “text”, VARIABLE
declaring variables (general)
VARIABLE = value
declaring multiple variables
VARIABLE1 = value1; VARIABLE2 = value2
declaring variables (boolean)
boolean VARIABLE = True or False
declaring variables (array)
VARIABLE ARRAY
Arithmetic Operators
A=3+3 = 6
B=3-3 = 0
C=3*3 = 9
D=3/3 = 1
E = 3 mod 3 = 0 //remainder
F = 3 div 3 = 1 //integer solution
G = abs(C-11) // Calculate the absolute valueB
Boolean Operators
>
<
>=
<=
!=
=
if-then-else
if condition then
//code
else if condition then
//code
else
//code
endif
while loops
loop while condition
//code
endloop
for loops
loop counter from start to end
//code
endloop
create a queue
Q = new Queue()
Add to end of queue
Q.enqueue(VARIABLE)
remove from start of queue
VARIABLE = Q.dequeue()
check if a queue is empty
Q.isEmpty()
declare a new stack
S = new Stack()
Add an element to the top of stack
S.push(VARIABLE)
Remove item from top of stack
S.pop()
check if stack is empty
S.isEmpty()
Linear Search (sequential search)
Progresses from beginning to end of array and check whether each element is equal to the target value
Binary search
Can only be used on a sorted algorithm. The computer checks the middle term, sees if the target value is more or less than, and then proceeds to the corresponding half to repeat the process until the target value is found or the entire designated section has been searched through.
Bubble Sort
Goes through an array, comparing each pair of elements, and swaps the elements if they are out of order. The process repeats until the array is fully sorted and no more swaps are made.
Merge Sort
A sorted and unsorted array are made. The values in the unsorted array are picked out and added to the sorted array in the order that they need to go.