码迷,mamicode.com
首页 >  
搜索关键字:swap nodes in pairs    ( 8848个结果
HDU 5002 Tree(动态树LCT)(2014 ACM/ICPC Asia Regional Anshan Online)
Problem DescriptionYou are given a tree with N nodes which are numbered by integers 1..N. Each node is associated with an integer as the weight.Your t...
分类:其他好文   时间:2014-09-18 16:03:14    阅读次数:325
交互二叉树的所有左子树和右子树.
递归实现:真正对递归的调用过程很熟悉的哥们才很顺,虽然这个题目代码看起来不难,但是我在纸上画出调用过程后,才弄明白是什么个过程. 1 //交换所有二叉树的左子树和右子树. 2 void 3 swap(PNode p) { 4 if(!p) return; 5 6 swap...
分类:其他好文   时间:2014-09-18 13:11:43    阅读次数:204
Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2-...
分类:其他好文   时间:2014-09-18 05:24:13    阅读次数:195
冒泡排序算法
冒泡排序算法的时间复杂度是什么?时间复杂度是O(n^2)。 1 #include "stdafx.h" 2 #include 3 using namespace std; 4 void Swap(int &a, int &b) 5 { 6 int temp = a; 7 a = b...
分类:其他好文   时间:2014-09-17 23:05:02    阅读次数:184
用函数指针实现的快速排序算法
K&R第五章介绍了用函数指针实现的快速排序算法,对其中的代码比较困惑,所以看了下《算法导论》上对快排的介绍,下面这张图说明了快排的原理及过程: 用C实现上面的过程: #include /* declare function pointer */ typedef int(*fp_operation)(int a, int b); void swap(int *a, int...
分类:其他好文   时间:2014-09-17 21:58:12    阅读次数:320
Leetcode_num2_Maximum Depth of Binary Tree
题目: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. AC率第二高的题啦,二项树的最长路径。初看此题...
分类:其他好文   时间:2014-09-17 20:26:52    阅读次数:162
STL之Pairs
什么是Pair 关于类Pair的介绍,下面是引自《C++ Standard Library》的一段话: The class pair is provided to treat two values as a single unit. It is used in several places wi.....
分类:其他好文   时间:2014-09-16 22:03:51    阅读次数:176
[Linux] day03——REHL部署
REHL 部署Linux 树形目录结构最顶层 根 /在Linux中 一切皆文件文件系统 swap /安装方式 PXE U盘 光盘配置安装程序选择包 5.9 6.4
分类:系统相关   时间:2014-09-16 21:56:31    阅读次数:225
Reverse Nodes in k-Group[leetcode]递归和非递归的解法
题目不难,但是容易出错,需要考虑各种边界情况 非递归代码如下: ListNode *reverseKGroup(ListNode *head, int k) { if (head == NULL || k <= 1) return head; ListNode * start = NULL, * end = NULL, *newHead = NULL, *p...
分类:其他好文   时间:2014-09-16 19:00:54    阅读次数:201
[leetcode] Minimum Depth of Binary Tree ,到叶子节点的最小距离 (python)
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest le...
分类:编程语言   时间:2014-09-16 18:48:00    阅读次数:242
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!