算法实践
文章平均质量分 78
MichaelWo
这个作者很懒,什么都没留下…
展开
-
算法实现之希尔排序(C++)
希尔排序原理:希尔排序之前的排序算法时间复杂度都是O(n*n),希尔排序算法是突破这个时间复杂度限制的算法之一。 插入排序:由于插入排序所执行的交换操作涉及近邻元素,使得元素每次只能移动一位,所以插入排序的效率较低。比如当关键字最小的元素刚好在数组的尾端,就需要N步将该元素放到数组最前端。而当整个记录本身是基本有序是,只需插入排序的效率是非常高的。 改进方法:让每次交换操作不要涉及近邻元素,通原创 2014-05-24 10:44:17 · 511 阅读 · 0 评论 -
LeetCode::Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Some examples: ["2", "1",原创 2014-05-29 23:26:57 · 535 阅读 · 0 评论 -
LeetCode::Reverse Words in a String
#include #include using namespace std; class Solution { public: void reverseWords(string &s) { int i, n; string tmp_s; int word_Length = 0; if(s.empty()) return ; for(i = s.len原创 2014-05-27 09:14:16 · 398 阅读 · 0 评论 -
LeetCode::Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.原创 2014-06-11 21:01:38 · 423 阅读 · 0 评论