[COMPSCI 1JC3] - Final Exam Guide - Comprehensive Notes for the exam (27 pages long!)

441 views27 pages

Document Summary

Comp sci 1jc3 dr. anand lecture 2. Objective of game is to move the stack of three disks from one rod to another. Rules: one disk can be moved at a time. Only the disk highest up can be moved. A larger disk cannot be placed on a smaller one: b c. A pattern of 1-2-1 can be seen. First part of solution moves all the blocks minus 1. As you add 1 more block, you add 2n steps. You do(cid:374)"t (cid:449)a(cid:374)t the algo(cid:396)ith(cid:373) to i(cid:374)c(cid:396)ease e(cid:454)po(cid:374)e(cid:374)tiall(cid:455) i(cid:374) steps. How work grows is referred to as complexity. To go from a solution for tower n blocks to tower n+1 blocks using 3 tower example-: Add one step that moves the newest block 4 to b. The(cid:374) (cid:396)epeat p(cid:396)e(cid:448)ious solutio(cid:374) e(cid:454)cept cha(cid:374)gi(cid:374)g c"s to b"s, a"s to c"s a(cid:374)d b"s to a"s.