Two methods:1. Traverse2. Divide & Conquer 1 // Traverse: usually do not have return value 2 public class Solution { 3 public void traverse(TreeNo...
分类:
其他好文 时间:
2015-10-26 01:56:04
阅读次数:
209
一、关于Quicksort的简单介绍Quicksort算法属于divide and conquer算法,核心思想是取array中的一个元素作为pivot,然后把array除了pivot的其他元素与这个pivot进行比较,比pivot小的元素放在pivot左边,比pivot大的元素放在pivot的右边...
分类:
编程语言 时间:
2015-10-22 12:22:21
阅读次数:
196
题目来源: https://leetcode.com/problems/divide-two-integers/题意分析: 不用乘法,除法和mod运算来实现一个除法。如果数值超过了int类型那么返回int的最大值。题目思路: 初步来说,有两个做法。 ①模拟除法的过程,从高位开始除,不够先右挪...
分类:
编程语言 时间:
2015-10-20 00:00:17
阅读次数:
511
不能使用乘法,除法和mod operator,实现除法功能。Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.用减法可以实现,但是...
分类:
其他好文 时间:
2015-10-18 00:55:14
阅读次数:
253
题意:给定两个点集,一个红点集,另一个蓝点集,询问,能否找到一条直线能,使得任取一个红点和蓝点都在直线异侧。思路:划分成两个凸包,一个红包,一个蓝包。两个凸包不相交不重合。1.任取一个凸包中的点不在另一个凸包中。2.任取一个凸包中的边与另一个凸包不相交。 1 #include 2 #includ.....
分类:
其他好文 时间:
2015-10-15 23:37:29
阅读次数:
267
Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.Runtime: 8ms 1 class Solution { 2 public...
分类:
其他好文 时间:
2015-10-12 01:47:42
阅读次数:
183
归并排序http://blog.csdn.net/morewindows/article/details/6678165归并排序是建立在归并操作上的一种有效的排序算法。该算法是采用分治法(Divide and Conquer)的一个非常典型的应用。归并操作:http://www.tuicool.co...
分类:
编程语言 时间:
2015-10-12 00:32:47
阅读次数:
239
1、算法思想 快速排序是一种划分交换排序。它采用了一种分治的策略,通常称其为分治法(Divide-and-ConquerMethod)。 (1) 分治法的基本思想 分治法的基本思想是:将原问题分解为若干个规模更小但结构与原问题相似的子问题。递归地解这些子问题,然后将这些子问题的...
分类:
编程语言 时间:
2015-10-11 00:31:29
阅读次数:
479
(referrence: GeeksforGeeks)Like Merge Sort, Quick Sort is also a divide & conquer problem.It picks an element as pivot and partitions the given array ...
分类:
其他好文 时间:
2015-10-10 00:18:45
阅读次数:
223
Master theorem provides a solution in asymptotic terms to solve time complexity problem of most divide and conquer algorithms.Recurrence relations of ...
分类:
其他好文 时间:
2015-10-07 06:18:52
阅读次数:
208