随笔分类 -  Algorithms of Coursera

Algortithms 在Coursera上的课程作业
摘要:题目地址:http://coursera.cs.princeton.edu/algs4/assignments/kdtree.html 分析: Brute-force implementation. 蛮力实现的方法比较简单,就是逐个遍历每个point进行比较,实现下述API就可以了,没有什么难度。 阅读全文
posted @ 2017-08-15 21:24 evasean 阅读(1261) 评论(0) 推荐(0)
摘要:题目原文: Design an algorithm to perform an inorder traversal of a binary search tree using only a constant amount of extra space. 1 public void traverse( 阅读全文
posted @ 2017-08-14 17:56 evasean 阅读(849) 评论(0) 推荐(0)
摘要:题目原文: Given a binary tree where each 𝙽𝚘𝚍𝚎 contains a key, determine whether it is a binary search tree. Use extra space proportional to the height 阅读全文
posted @ 2017-08-14 16:46 evasean 阅读(363) 评论(0) 推荐(0)
摘要:1. Java autoboxing and equals(). Consider two double values a and b and their corresponding Double value x and y. Find values such that (𝚊==𝚋) is 𝚝 阅读全文
posted @ 2017-08-09 14:46 evasean 阅读(397) 评论(0) 推荐(0)
摘要:题目原文:http://coursera.cs.princeton.edu/algs4/assignments/8puzzle.html 题目要求:设计一个程序解决8 puzzle问题以及该问题的推广,例如8-puzzle是3*3,程序要能解决n*n的同类问题(2 ≤ n < 128) 典型的8 p 阅读全文
posted @ 2017-08-04 00:03 evasean 阅读(2240) 评论(0) 推荐(0)
摘要:题目原文: Decimal dominants. Given an array with n keys, design an algorithm to find all values that occur more than n/10 times. The expected running time 阅读全文
posted @ 2017-08-02 14:51 evasean 阅读(1435) 评论(0) 推荐(0)
摘要:题目原文 Selection in two sorted arrays. Given two sorted arrays a[] and b[], of sizes n1 and n2, respectively, design an algorithm to find the kth larges 阅读全文
posted @ 2017-08-02 14:32 evasean 阅读(951) 评论(0) 推荐(1)
摘要:题目原文详见http://coursera.cs.princeton.edu/algs4/assignments/collinear.html 程序的主要目的是寻找n个points中的line segment,line segment的要求就是包含不少于4个点。 作业包含三部分程序实现: 一、Poi 阅读全文
posted @ 2017-07-27 21:56 evasean 阅读(1752) 评论(2) 推荐(1)
摘要:题目原文: Nuts and bolts. A disorganized carpenter has a mixed pile of n nuts and n bolts. The goal is to find the corresponding pairs of nuts and bolts. 阅读全文
posted @ 2017-07-25 20:15 evasean 阅读(1356) 评论(1) 推荐(0)
摘要:题目原文: Shuffling a linked list. Given a singly-linked list containing n items, rearrange the items uniformly at random. Your algorithm should consume a 阅读全文
posted @ 2017-07-25 10:30 evasean 阅读(1684) 评论(0) 推荐(1)
摘要:题目原文: An inversion in an array a[] is a pair of entries a[i] and a[j] such that i<j but a[i]>a[j]. Given an array, design a linearithmic algorithm to 阅读全文
posted @ 2017-07-24 20:48 evasean 阅读(1304) 评论(0) 推荐(0)
摘要:题目原文: Stack with max. Create a data structure that efficiently supports the stack operations (push and pop) and also a return-the-maximum operation. A 阅读全文
posted @ 2017-07-24 17:32 evasean 阅读(790) 评论(3) 推荐(0)
摘要:题目原文: 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 阅读(898) 评论(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 阅读(757) 评论(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 阅读(702) 评论(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 阅读(1012) 评论(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 阅读(1580) 评论(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 阅读(1782) 评论(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 阅读(1312) 评论(1) 推荐(0)
摘要:作业原文:http://coursera.cs.princeton.edu/algs4/assignments/queues.html 这次作业与第一周作业相比,稍微简单一些。有三个编程练习:双端队列(Deque)设计、随机队列(Randomized Queue)设计,还有一个排列组合类Permut 阅读全文
posted @ 2017-07-19 11:33 evasean 阅读(1962) 评论(6) 推荐(0)