1 / 2

Computational Time Required to Solve the Tower of Hanoi

Computational Time Required to Solve the Tower of Hanoi.

ellie
Download Presentation

Computational Time Required to Solve the Tower of Hanoi

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computational Time Required to Solve the Tower of Hanoi • To solve the Tower of Hanoi problem, a recursive approach was taken. To move n disk from one tower to another we first move (n-1) disk to an auxiliary tower, then move the bottom disk to its final destination, and then move the (n-1) disk to their final destination. • The time required for various operations was measure and any overhead not associated with the function was subtracted out. • 1E+9 Operations were performed on a Pentium(4) running at 2400.153 MHz. The times required for a single operation are as follows : • To call the function (w/o performing any operations): Tf = 5.171/1E+9 s • To move a single disk w/ necessary bookkeeping: T[1] = 14.157/1E+9 s • To compute auxiliary tower and pass over n=1 case: Taux = 2.742/1E+9 s

  2. Computational Time Required to Solve the Tower of Hanoi • Now a recursive relationship can be written and solved for the time as a function of n • Let T[n] be the time required to solve problem for n disks then : T[n] = Tf + Taux + 2T[n-1] + T[1] = C + 2 T[n-1] (letting C= Tf + Taux + T[1] ) = C + 2 (C +2 T[n-2]) = C + 2 (C + 2 (C + 2 T[n-3]) = C + 2C + 2^2C + …+ 2^(k-1)C + 2^k T[n-k] (In general) = C (2^k – 1) + 2^k T[n – k] = C (2^(n-1) – 1) + 2^(n-1)*T[1] By n – 1  k • Substituting the times found earlier : T[64] = 2.036E+11 + 1.306E+11 = 3.342E+11 s or 10,590 years

More Related