摘要: 所有排序算法总结:冒泡排序,快速排序,插入排序,归并排序,堆排序,shell排序,选择排序算法排序的稳定性是指:关键码相同的记录排序前后相对位置不发生改变。举个例子:待排序数组:int a[] ={1, 2, 2, 3, 4, 5, 6};在快速排序的随机选择比较子(即pivot)阶段:若选择a[2... 阅读全文
posted @ 2015-03-13 16:07 雄哼哼 阅读(415) 评论(0) 推荐(0) 编辑
摘要: 原文地址,两种思路都不错第一种前序void preOrder(Node *p) //非递归{ if(!p) return; stack s; Node *t; s.push(p); while(!s.empty()) { t=s.top(); prin... 阅读全文
posted @ 2014-11-10 10:17 雄哼哼 阅读(5762) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After re... 阅读全文
posted @ 2014-11-06 15:51 雄哼哼 阅读(307) 评论(0) 推荐(0) 编辑
摘要: 基础有待加强啊,由该题引发出来一些问题,现在来总结下。首先是二叉树的结构: struct TreeNode { EleType val; TreeNode *left; TreeNode *right; };然后是二叉树,先序遍历的构建方法,由于只有扩展后的二叉树可以做到一个... 阅读全文
posted @ 2014-10-23 17:40 雄哼哼 阅读(371) 评论(0) 推荐(0) 编辑
摘要: Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ... 阅读全文
posted @ 2015-04-03 17:04 雄哼哼 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 原文链接# echo "abcd"|tr 'a' 'b'bbcdtr 命令用途转换字符。语法tr[-c|-cds|-cs|-C|-Cds|-Cs|-ds|-s] [-A]String1String2tr{-cd|-cs|-Cd|-Cs|-d|-s} [-A]String1描述tr命令从标准输入删除或... 阅读全文
posted @ 2015-04-03 11:15 雄哼哼 阅读(735) 评论(0) 推荐(0) 编辑
摘要: Write a bash script to calculate the frequency of each word in a text filewords.txt.For simplicity sake, you may assume:words.txtcontains only lowerca... 阅读全文
posted @ 2015-04-03 11:14 雄哼哼 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 思路:代码:class Solution {public: int rob(vector &num) { if(num.empty()) return 0; int size=num.size(); if(size==1) return num[0];... 阅读全文
posted @ 2015-04-03 10:44 雄哼哼 阅读(265) 评论(0) 推荐(0) 编辑
摘要: 思路:用归并排序。对一个链表采用递归进行二等分,直到每个部分有序,然后对其进行合并。其实就是两步,先分解,然后合并有序链表。代码://对链表采用递归排序class Solution {public: ListNode* sortList(ListNode* head){ if(h... 阅读全文
posted @ 2015-03-30 22:29 雄哼哼 阅读(2473) 评论(0) 推荐(0) 编辑
摘要: http://blog.csdn.net/haoel/article/category/9197 阅读全文
posted @ 2015-03-25 15:19 雄哼哼 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 功能:去掉字符串首尾的空格,换行符等空白。代码:#include #include #include char *trim(char *str){ char *p = str; char *p1; if(p) { p1 =... 阅读全文
posted @ 2015-03-23 22:00 雄哼哼 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 功能:去掉字符串首尾的空格,换行符等空白。代码:#include #include #include char *trim(char *str){ char *p = str; char *p1; if(p) { p1 =... 阅读全文
posted @ 2015-03-23 22:00 雄哼哼 阅读(2412) 评论(0) 推荐(0) 编辑
摘要: 1.首先安装QT,同时要有gcc2.然后就是先安装sip,然后安装pyqt4python configure.py -q /usr/bin/qmake-4.8 -d /Library/Python/3.4/site-packages/ --sip /System/Library/Frameworks... 阅读全文
posted @ 2015-03-23 13:57 雄哼哼 阅读(848) 评论(0) 推荐(0) 编辑
摘要: 前两天发布那个 rsync 算法后,想看看数据压缩的算法,知道一个经典的压缩算法 Huffman 算法。你应该听说过David Huffman和他的经典的压缩算法——Huffman Code,这是一种通过字符出现频率,Priority Queue,和二叉树来进行的一种压缩算法,这种二叉树又叫 Huf... 阅读全文
posted @ 2015-03-20 19:41 雄哼哼 阅读(2122) 评论(0) 推荐(1) 编辑