Final Cheat Sheet.pdf – Towers of Hanoi Design a function (algorithm) that solves the Towers of Hanoi game for the following graph = (, ) with = {, , | Course Hero

Towers of Hanoi

Design a function (algorithm) that solves the Towers of Hanoi game for the following graph

࠵? = (࠵?, ࠵?)

with

࠵? =

{࠵?࠵?࠵?࠵?࠵?, ࠵?࠵?࠵?࠵?, ࠵?࠵?࠵?1, ࠵?࠵?࠵?2}

and

࠵? = {

࠵?࠵?࠵?࠵?࠵?, ࠵?࠵?࠵?࠵?

,

࠵?࠵?࠵?࠵?, ࠵?࠵?࠵?1

,

࠵?࠵?࠵?1, ࠵?࠵?࠵?2

,

࠵?࠵?࠵?2, ࠵?࠵?࠵?࠵?࠵?

}

. Estimate the time complexity of

your function, in terms of the number

࠵?

of disks to be moved.

Time Complexity

࠵?

࠵?

= 2

࠵? − 1

+ 1

1

=

࠵?

2

;

Space Complexity

࠵?(࠵?)

Design a function (algorithm) that solves the Towers of Hanoi game for the following graph

࠵? = (࠵?, ࠵?)

with

࠵? =

{࠵?࠵?࠵?࠵?࠵?, ࠵?࠵?࠵?1, ࠵?࠵?࠵?࠵?, ࠵?࠵?࠵?2}

and

࠵? = {

࠵?࠵?࠵?࠵?࠵?, ࠵?࠵?࠵?1

,

࠵?࠵?࠵?1, ࠵?࠵?࠵?2

,

࠵?࠵?࠵?2, ࠵?࠵?࠵?࠵?

,

࠵?࠵?࠵?࠵?, ࠵?࠵?࠵?1

}

. Estimate the time complexity of

your function, in terms of the number

࠵?

of disks to be moved.

Time Complexity

࠵?

࠵?

= 3

࠵? − 1

+ 2

1

=

࠵?

3

;

Space Complexity

࠵?(࠵?)

Design a function (algorithm) that solves the Towers of Hanoi game for the following graph

࠵? = (࠵?, ࠵?)

with

࠵? =

{࠵?࠵?࠵?࠵?࠵?, ࠵?࠵?࠵?1, ࠵?࠵?࠵?2, ࠵?࠵?࠵?࠵?}

and

࠵? = {

࠵?࠵?࠵?࠵?࠵?, ࠵?࠵?࠵?1

,

࠵?࠵?࠵?1, ࠵?࠵?࠵?2

,

࠵?࠵?࠵?2, ࠵?࠵?࠵?࠵?

,

࠵?࠵?࠵?࠵?, ࠵?࠵?࠵?࠵?࠵?

}

. Estimate the time complexity of

your function, in terms of the number

࠵?

of disks to be moved.

Time Complexity

࠵?

࠵?

= 3

࠵? − 1

+ 2

1

=

࠵?

3

;

Space Complexity

࠵?(࠵?)