COP3530 1st practice assignment
Insert 0 into 1 2 3 4 5 & count steps
Starting from the end,
- compare 0 to 5
- 0 is smaller than 5, shift 5 to the right
- compare 0 to 4
- 0 is smaller than 4, shift 4 to the right
- compare 0 to 3
- 0 is smaller than 3, shift 3 to the right
- compare 0 to 2
- 0 is smaller than 2, shift 2 to the right
- compare 0 to 1
- 0 is smaller than 1, shift 1 to the right, insert 0
10 steps total.
Insert 10 into 1 2 3 4 5 & count steps
Starting from the end,
- compare 10 to 5
- 10 is larger than 5, insert 10 at the end
2 steps total.
Implemented using C++
Артём阿尔乔姆 University of Florida Computer Science cise.ufl.edu