码迷,mamicode.com
首页 >  
搜索关键字:递归    ( 18847个结果
POJ 1696
这题是明显的TU包变形。使用卷包裹法可解,而且是必定可以经过所有点的。直观可知,当经过某点后,相当于把之前的点抹去,求剩下点的TU包,递归下去,也就能把点全部经过了。于是,只需把经过的点标记一下就可以了。#include #include #include #include #include usi...
分类:其他好文   时间:2014-07-30 23:51:15    阅读次数:349
将两个有序链表和为另外一个链表,并保证有序
直接递归 代码: #include #include using namespace std; typedef struct listNode{ int key; struct listNode *pNext; } * pNode,Node; void createNode(pNode &pHead){ bool isFirst=true; int temp; sc...
分类:其他好文   时间:2014-07-30 20:57:14    阅读次数:174
[LeetCode] Binary Tree Maximum Path Sum(递归)
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example: Given the below binary tree, 1 ...
分类:其他好文   时间:2014-07-30 20:33:34    阅读次数:193
四皇后问题
递归#include #include #include #define NUM 4int total = 0;void print_board(int *board){ printf("\n"); for (int i = 0; i < NUM; i++) { fo...
分类:其他好文   时间:2014-07-30 20:20:54    阅读次数:188
Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note: A solution using O(n) space is pretty straight...
分类:其他好文   时间:2014-07-30 17:46:04    阅读次数:244
从尾到头打印链表
使用数据结构stack或者递归 1 使用stack #include #include using namespace std; typedef struct listNode{ int key; struct listNode *pNext; } * pNode,Node; void createNode(pNode &pHead){ bool isFirst=true;...
分类:其他好文   时间:2014-07-30 17:30:34    阅读次数:189
全排列递归实现(二)
/** ?*?@param?args ?*/ public?static?void?main(String[]?args)?{ char[]?raw?=?"12345".toCharArray(); perm(raw,?4); // System.out.println("==========================="); // Syst...
分类:其他好文   时间:2014-07-30 15:07:14    阅读次数:182
Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center)....
分类:其他好文   时间:2014-07-30 14:48:53    阅读次数:216
002-算法-递归法
一、概念:(Recursion)在数学与计算机科学中,是指在函数定义中使函数自身的方法。 定义: 在数学和计算器及科学中,递归是指由一种(或多种)简单的基本情况定义的一类对象或方法,并规定其它所有情况都能被还原为其基本情况。http://zh.wikipedia.org/zh/%E9%80%92.....
分类:其他好文   时间:2014-07-30 11:50:53    阅读次数:201
000-算法-基础概念
1 概述 算法(Algorithm)是指解题方案的准确而完整的描述,是一系列解决问题的清晰指令,算法代表着用系统的方法描述解决问题的策略机制。一个算法的优劣可以用空间复杂度和时间复杂度来衡量。2 特征 一个算法应该有一下五个重要特征:有穷性、确切性、输入项、输出项、可行性。3 要素 一,数据对...
分类:其他好文   时间:2014-07-30 11:48:53    阅读次数:215
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!