CCI_chapter 8 Recurision
8.1 水题
8.2 Imagine a robot sitting on the upper left hand corner of an NxN grid The robot can only move in two directions: right and down How many possible paths are there for the robot?
FOLLOW UP
Imagine certain squares are “of limits”, such that the robot can not step on them
Design an algorithm to get all possible paths for the robot
http://www.cnblogs.com/graph/p/3258531.html
http://www.cnblogs.com/graph/p/3258555.html
8.3 Write a method that returns all subsets of a set(所有子集系列)
http://www.cnblogs.com/graph/p/3216589.html
http://www.cnblogs.com/graph/p/3216496.html
8.4 Write a method to compute all permutations of a string (所有排列系列)
http://www.cnblogs.com/graph/p/3216100.html
http://www.cnblogs.com/graph/p/3215299.html
http://www.cnblogs.com/graph/p/3297845.html
http://www.cnblogs.com/graph/p/3224053.html
8.5 Implement an algorithm to print all valid (e g , properly opened and closed) combinations of n-pairs of parentheses
EXAMPLE:
input: 3 (e g , 3 pairs of parentheses)
output: ()()(), ()(()), (())(), ((()))
http://www.cnblogs.com/graph/p/3194497.html
8.6 水题
8.7Given an infnite number of quarters (25 cents), dimes (10 cents), nickels (5 cents) and pennies (1 cent), write code to calculate the number of ways of representing n cents
int a[] = {, , , };
int makeChange(int n, int index)
{
assert(index >= && index <= );
if(a[index] == ) return ;
int way = ;
for(int i = ; i * a[index] <= n; ++i)
way += makeChange(n - i * a[index], index+);
return way;
}
8.8Write an algorithm to print all ways of arranging eight queens on a chess board so that none of them share the same row, column or diagonal
http://www.cnblogs.com/graph/archive/2013/07/30/3226728.html
CCI_chapter 8 Recurision的更多相关文章
- CCI_chapter 19 Moderate
19 1 Write a function to swap a number in place without temporary variables void swap(int &a, i ...
- CCI_chapter 16 Low level
16.5 Write a program to find whether a machine is big endian or little endian Big-Endian和Little-Endi ...
- CCI_chapter 13C++
13.9Write a smart pointer (smart_ptr) class template<class T>class SmartPoint{ public: SmartPo ...
- CCI_chapter 4 trees and Grapths
4.1Implement a function to check if a tree is balanced For the purposes of this question,a balanced ...
- CCI_chapter 3 Stacks and Queues
3.1Describe how you could use a single array to implement three stacks for stack 1, we will use [0, ...
- CCI_chapter 2 Linked Lists
2.1 Write code to remove duplicates from an unsorted linked list /* Link list node */ struct node { ...
- CCI_chapter 1
1.1Implement an algorithm to determine if a string has all unique characters What if you can not us ...
- Linux系统下搭建DNS服务器——DNS原理总结
2017-01-07 整理 DNS原理 域名到IP地址的解析过程 IP地址到域名的反向域名解析过程 抓包分析DNS报文和具体解析过程 DNS服务器搭建和配置 这个东东也是今年博主参见校招的时候被很多公 ...
- <<C++ Primer>> 第 6 章 函数
术语表 第 6 章 函数 二义性调用(ambiguous call): 是一种编译时发生的错误,造成二义性调用的原因时在函数匹配时两个或多个函数提供的匹配一样好,编译器找不到唯一的最佳匹配. 实 ...
随机推荐
- 【转】ipad死机了,无法退出,也无法关机,怎么办
原文网址:http://zhidao.baidu.com/link?url=oTz6J78hmtCAKddhwu1ITUiPmLnVJIaA_v_0dZblPaIJUhuMdyTCdS6H2737GX ...
- 【转】listView中,checkBox的显示和隐藏
原文网址:http://www.cnblogs.com/vicma/p/3460500.html 在listView中,每个item都有一个ChexBox,当显示的时候在listView外面设置一个按 ...
- Geeks Interview Question: Ugly Numbers
Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence1, 2, 3, 4, 5, 6, 8, 9, ...
- 提升效率的Linux终端快捷操作汇总
很多普通 Linux 桌面用户都对使用终端感到排斥和恐惧,其实它没大家想的那么复杂,很多常见操作都可以直接在终端中进行,如:安装软件.升级系统等. 无论你是新手还是 Linux 终端使用的老鸟,系统极 ...
- win10 pro eclipse maven: Cannot read lifecycle mapping metadata for artifact org.apache.maven.plugins:mav invalid END header (bad central directory offset)
Error:Cannot read lifecycle mapping metadata for artifact org.apache.maven.plugins:mav ... invalid E ...
- js中的数据类型及其转换
Js中的数据类型 Js中的数据类型一共有六种,即number,string,boolean,underfine,null,object. 一,number Number数据类型指的是数字,可以为整型, ...
- MySQL 加密/压缩函数
这些问题可能导致数据值的改变.一般而言,上述问题可能在你使用非二进制串数据类型(如char,varchar,text等数据类型)的情况下发生. AES_ENCRYPT()和AES_DECRYPT() ...
- Velocity 语法示例
一.简介: 1)它允许任何人使用简单而强大的模板语言来引用定义在 java 代码中的对象" 2)Velocity是一个基于java的模板引擎,简称VTL(Velocity Template ...
- python模块基础之getpass模块
getpass模块提供了可移植的密码输入,一共包括下面两个函数: 1. getpass.getpass() 2. getpass.getuser() getpass.getpass([prompt[, ...
- OD: Universal Shellcode
本节讲如果开发通用的 Shellcode. Shellcode 的组织 shellcode 的组织对成功地 exploit 很重要. 送入缓冲区的数据包括: . 填充物.一般用 0x90 (NOP) ...