
coursera题目
codefreestyle
这个作者很懒,什么都没留下…
展开
-
Coursera week4 Programming Assignment 4: 8 Puzzle
题目链接8 puzzle题意简介拼图游戏,该拼图板是一个n*n的方格,但是只放了n*n-1个卡片,有一个空卡片便于我们移动,要求最后把拼图按照从上到下从左到右的顺序放卡片(1~n*n-1),求最少的步数。题目解析1、使用A*搜索算法,其实就是BFS的变体,每次选择优先级最高的节点出队列。我们直接使用老师提供的MinPQ数据结构即可。2、剪枝。代码中设计了一个数据结构,一个私有类——No...原创 2018-12-21 16:57:09 · 440 阅读 · 0 评论 -
Coursera Programming Assignment 2: Deques and Randomized Queues
完整代码如下Deque.javaimport java.util.Iterator;import java.util.NoSuchElementException;public class Deque<Item> implements Iterable<Item> { private Node first, last; private int N; ...原创 2018-12-08 12:07:41 · 307 阅读 · 0 评论 -
InterviewQuestion: Union–Find
Social network connectivity. Given a social network containing nn members and a log file containing mm timestamps at which times pairs of members formed friendships, design an algorithm to determine ...原创 2018-12-01 15:53:41 · 373 阅读 · 0 评论 -
Java generics. Explain why Java prohibits generic array creation.
Java generics. Explain why Java prohibits generic array creation.to start, you need to understand that Java arrays are covariant but Java generics are not: that is, String[] is a subtype of Object[], b原创 2017-08-29 14:50:19 · 1369 阅读 · 0 评论 -
能返回最大值的栈
Stack with max. Create a data structure that efficiently supports the stack operations (push and pop) and also a return-the-maximum operation. Assume the elements are reals numbers so that you can comp原创 2017-08-29 14:29:42 · 689 阅读 · 0 评论