career cup:3.4 tower of hanoi
来源:互联网 发布:mac程序图标怎么删除 编辑:程序博客网 时间:2024/06/06 14:08
1. represent of hanoi: choice between LinkedList, Stack, ArrayList, Array
(1) one tower can be represented by LinkedList or Stack. LinkedList has more function and it's easier to copy the tower. We need copy the tower
because we use BFS
(2) Array can not contain things like Stack<Integer>, LinkedList<Integer>, since Stack<Integer>[] = new Stack<Integer>[5] will fail. We can use ArrayList instead.
(3) use LinkedList of int[2] to represent the solution, the solution should be a field of Hanoi state and be copied. Otherwise there exists concurrency problem
2. use BFS:
(1) convert the state of tower to a String as key of HashSet so that we can easily mark the visited state. I use "," to separate the tower in Hanoi
(2) In the loop of BFS, if a certain string(state of Hanoi) is not in the HashSet, do not forget to add it into the HashSet or the loop will not stop.
- career cup:3.4 tower of hanoi
- THE TOWER OF HANOI
- Tower of Hanoi
- Tower of Hanoi
- Tower of Hanoi
- Tower of Hanoi问题
- codeforces Tower of Hanoi
- Tower of Hanoi
- 汉诺塔 Tower of Hanoi
- THE TOWER OF HANOI
- pku 3601 Tower of Hanoi
- 汉诺塔(the Tower of Hanoi )
- 1.1 The Tower of Hanoi
- poj 3601 Tower of Hanoi
- Tower of Hanoi by C++
- POJ 3601:Tower of Hanoi
- 1-6 Tower of Hanoi
- POJ 3601 Tower of Hanoi
- 第十九章 TCP的交互数据流
- Lua中的元表和元方法
- rabbitMQ WINDOWS 安装 入门
- Android开发——点击两次手机返回键退出软件
- IOS5.0中UIControllerView新方法的使用
- career cup:3.4 tower of hanoi
- 数据恢复得很好的电话都会发生(Q977177223)
- Codeforces 448 C. Painting Fence
- Linux虚拟机 网卡设置
- jdk、Tomcat、solr的安装和配置
- 网络爬虫基本原理
- ehcache框架配置文件各参数详解
- 【Leetcode长征系列】Remove Element
- [ZOJ 2285][Vjudge 24161] Building Highways [IDA*]