Write an algorithm for a program that adds 2 number and prints the result.
Write and algorithm on bubble sort
Assume, we have an array ARR with length N. We want to search a value K in the array.
Step 1: Set J = 0
Step 2: Set I = 0
Step 3: J = J + 1
Step 4: Print “Found”
Step 5: If A<B then
Print A
Else if B<C then
Print B
Else
Print C
Step 6: Repeat steps 7 to 9 while I<N-1
Step 7: Print I
Step 8: I = I+1
Step 9: If I < 10 then
Print N
Step 10: Call SWAP(ARR[J], ARR[J+1])
Step 1: Set T = ARR[J]
Step 2: ARR[J] = ARR[J+1]
Step 3: ARR[J+1] = T
Step 11: Repeat steps 12 to 15 while I<N-1
Step 12: Repeat steps 13 to 14 While J<N-1
Step 13: Print J
Step 14: Print “A”
Step 15 Print “C”
Step 16: If A<B then
Print B
Step 17: Repeat steps 18 to 22 While I < N -1
Step 18: Print A
ARR[J] == K
1. You can assume some variables
2. Number each algorithm line
3. Use “Set” for first time use of variable in algorithm
4. Variables are capital letters only
5. 3 types Statements: general, if else, loop
6. Nested case