cs3003-unit1-notes
Insertion into Sorted List
Description
Algorithm in pseudocode
func INSERT_INTO_SORTEDARRAY:
(input) sorted list, and key to be inserted
(output) sorted list with key inserted
key: <- last element in A // A is already sorted
index: <- length(List) - 1
iterate j from index to 1
if A[j-1] > key then
shift the element right
else
break
if j != index:
A[j] = key // inserted at the right location
return A
end funcExample
Source Code
Output

Tower of Hanoi
Pseudocode 1
Pseudocode 2
Output for 3 disc Hanoi Problem
Python Code
Hanoi Output
Thinking about Recursion
Last updated