由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问一道crack tech interview里面的题
相关主题
汉若塔问题还有两个题。
M家一道题请问申F家都要先做puzzle吗
还是career cup请教一道题
32MB 内存如何 sort 1GB data[合集] M$ interview question
1G内存读10G文件问个简单的GooG题目
征解几道large scale的数字题请教一个问题的答案,好像以前有人讨论过
问个CareerCup上external sort的题请教一道google面试算法题
超大young矩阵查找问个微软面试题
相关话题的讨论汇总
话题: disk话题: disks话题: rod话题: top话题: sorted
进入JobHunting版参与讨论
1 (共1页)
v***n
发帖数: 562
1
#3.4
In the classic problem of the Towers of Hanoi, you have 3 rods and N disks
of different sizes which can slide onto any tower. The puzzle starts with
disks sorted in ascending order of size from top to bottom (e.g., each disk
sits on top of an even larger one). You have the following constraints:
(A) Only one disk can be moved at a time.
(B) A disk is slid of the top of one rod onto the next rod.
(C) A disk can only be placed on top of a larger disk.
Write a program to move the disks from the first rod to the last using
Stacks.
初始的时候,这些disks已经在第一个rod上了吧,也就是说input已经是sorted stack
,对吗?
谢谢。
c****p
发帖数: 6474
2
是的。。这个问题的中文名字叫汉诺塔。

disk

【在 v***n 的大作中提到】
: #3.4
: In the classic problem of the Towers of Hanoi, you have 3 rods and N disks
: of different sizes which can slide onto any tower. The puzzle starts with
: disks sorted in ascending order of size from top to bottom (e.g., each disk
: sits on top of an even larger one). You have the following constraints:
: (A) Only one disk can be moved at a time.
: (B) A disk is slid of the top of one rod onto the next rod.
: (C) A disk can only be placed on top of a larger disk.
: Write a program to move the disks from the first rod to the last using
: Stacks.

v***n
发帖数: 562
3
谢了!
1 (共1页)
进入JobHunting版参与讨论
相关主题
问个微软面试题1G内存读10G文件
问一道题征解几道large scale的数字题
triplets 题怎么做比较高效?问个CareerCup上external sort的题
刚做了一道有些怪异的题超大young矩阵查找
汉若塔问题还有两个题。
M家一道题请问申F家都要先做puzzle吗
还是career cup请教一道题
32MB 内存如何 sort 1GB data[合集] M$ interview question
相关话题的讨论汇总
话题: disk话题: disks话题: rod话题: top话题: sorted