Solution to 22C:030 Homework 2

Question 1

Sort1 Function

Sort2 Function

Question 2

Sort1 Function

Sort2 Function

Running Time Analysis Plot

Conclusion

Question 3

Full Permutation Function

Running Time Analysis Plot

Conclusion

Note: for Questions 1, 2, and 3, just put apvector.h, apvector.cxx, rando.h, rando.cxx, systimer.h, systimer.cxx, node2.h, node2.template, dnode2.h, driver.cxx in the same directory, type "g++ -o driver driver.cxx rando.cxx systimer.cxx" to compile and link, and type "driver" to run.

Question 4

Adjacency List Representation

Breadth-First Search Tree