摘要: 题目原文: Suppose that the subarray a[0] to a[n-1] is sorted and the subarray a[n] to a[2*n-1] is sorted. How can you merge the two subarrays so that a[0] 阅读全文
posted @ 2017-07-22 00:00 evasean 阅读(885) 评论(0) 推荐(0) 编辑
摘要: 题目原文: Implement a queue with two stacks so that each queue operations takes a constant amortized number of stack operations. 题目要求用栈实现队列的所有操作。 阅读全文
posted @ 2017-07-21 23:44 evasean 阅读(740) 评论(2) 推荐(0) 编辑
摘要: 题目原文: Given two integer arrays of size n , design a subquadratic algorithm to determine whether one is a permutation of the other. That is, do they co 阅读全文
posted @ 2017-07-21 23:28 evasean 阅读(689) 评论(0) 推荐(0) 编辑
摘要: 题目原文: Given two arrays a[] and b[], each containing n distinct 2D points in the plane, design a subquadratic algorithm to count the number of points t 阅读全文
posted @ 2017-07-21 23:22 evasean 阅读(1000) 评论(0) 推荐(0) 编辑
摘要: 第二周课程的Elementray Sorts部分练习测验Interview Questions的第3题荷兰国旗问题很有意思。题目的原文描述如下: Dutch national flag. Given an array of n buckets, each containing a red, whit 阅读全文
posted @ 2017-07-21 14:48 evasean 阅读(1539) 评论(0) 推荐(0) 编辑
摘要: 题目原文: Suppose that you have an n-story building (with floors 1 through n) and plenty of eggs. An egg breaks if it is dropped from floor T or higher an 阅读全文
posted @ 2017-07-20 00:35 evasean 阅读(1729) 评论(0) 推荐(0) 编辑
摘要: 题目要求: Design an algorithm for the 3-SUM problem that takes time proportional to n2 in the worst case. You may assume that you can sort the n integers 阅读全文
posted @ 2017-07-19 23:32 evasean 阅读(1301) 评论(1) 推荐(0) 编辑
摘要: 作业原文:http://coursera.cs.princeton.edu/algs4/assignments/queues.html 这次作业与第一周作业相比,稍微简单一些。有三个编程练习:双端队列(Deque)设计、随机队列(Randomized Queue)设计,还有一个排列组合类Permut 阅读全文
posted @ 2017-07-19 11:33 evasean 阅读(1932) 评论(6) 推荐(0) 编辑
摘要: 题目原文: Given a set of n integers S = {0,1,…,N-1}and a sequence of requests of the following form: Remove x from S Find the successor of x: the smallest 阅读全文
posted @ 2017-07-19 10:55 evasean 阅读(1613) 评论(0) 推荐(0) 编辑
摘要: 题目原文: Add a method find() to the union-find data type so that find(i) returns the largest element in the connected component containing i. The operati 阅读全文
posted @ 2017-07-19 10:52 evasean 阅读(630) 评论(0) 推荐(0) 编辑