![]() Var sparePeg = hanoi.getSparePeg(fromPeg, toPeg) īut despite all that, even though it only seems to ask for the solveHanoi() to be filled out with the parameters, it wont progress. You can find the spare peg by using the getSparePeg function.Ī call to hanoi.getSparePeg(peg1,peg2) returns the remaining peg that isn't peg1 or peg2. move (numDisks - 1) disks to the spare peg. Make a recursive function call to move the disks sitting on top of the bottom disk on the fromPeg to the spare peg, i.e. Posting here really about the(just prior to this page) stage 2 Challenge Solve hanoi recursively (no place to put questions on that page). Θ ( n lg n ) \Theta(n \lg n) Θ ( n l g n ) \Theta, left parenthesis, n, \lg, n, right parenthesis Θ ( n ) \Theta(n) Θ ( n ) \Theta, left parenthesis, n, right parenthesis Θ ( n 2 ) \Theta(n^2) Θ ( n 2 ) \Theta, left parenthesis, n, squared, right parenthesis Step 1:-insert 2,3 Step 2:-insert 5 step 3:-insert 5 step 4:-insert 13 step 5:-insert 7,9 step 6:- Root node represent the optimal merge cost,so the Optimal Merge Cost :5 10 23 16 3993.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |