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 UPImagine certain squares are “of limits”, such that the…
19 1  Write a function to swap a number in place without temporary variables void swap(int &a, int &b) { b = a - b; // 4 = 9 - 5 a = a - b; // 5 = 9 - 4 b = a + b; // 9 = 4 + 5 } void swap(int & a, int &b) { a = a^b; b = a^b; a = a^b; } 19…
16.5 Write a program to find whether a machine is big endian or little endian Big-Endian和Little-Endian的定义如下:1) Little-Endian就是低位字节排放在内存的低地址端,高位字节排放在内存的高地址端.2) Big-Endian就是高位字节排放在内存的低地址端,低位字节排放在内存的高地址端.举一个例子,比如数字0x12 34 56 78在内存中的表示形式为:1)大端模式:低地址 ----…
13.9Write a smart pointer (smart_ptr) class template<class T>class SmartPoint{ public: SmartPoint(T *ref){ ref_ = ref; count_ = (unsigned int *)malloc(sizeof(unsigned int )); *count_ = 1; } SmartPoint(SmartPoint<T> &sptr){ ref_ = sptr.ref_…
4.1Implement a function to check if a tree is balanced For the purposes of this question,a balanced tree is defned to be a tree such that no two leaf nodes difer in distance from the root by more than one http://www.cnblogs.com/graph/archive/2013/04/…
3.1Describe how you could use a single array to implement three stacks for stack 1, we will use [0, n/3)for stack 2, we will use [n/3, 2n/3)for stack 3, we will use [2n/3, n) ; ]; ] = {,,}; //栈顶指针,指向下一可以放元素的位置 bool isEmpty(int stackNum){ assert(stack…
2.1  Write code to remove duplicates from an unsorted linked list /* Link list node */ struct node { int data; struct node* next; }; void rem_duplicate(node *head){ if(NULL == head) return ; set<int> hash; set.insert(head->data); while(head->n…
1.1Implement an algorithm to determine if a string has all unique characters What if  you can not use additional data structures? bool isUniqueChars(string str) { unsigned ; unsigned ; ; i < str.size();i++) { ; unsigned int temp; temp = flag ? <<…
2017-01-07 整理 DNS原理 域名到IP地址的解析过程 IP地址到域名的反向域名解析过程 抓包分析DNS报文和具体解析过程 DNS服务器搭建和配置 这个东东也是今年博主参见校招的时候被很多公司问过的,虽然理论性比较强,但是作为一个程序员,个人认为熟悉DNS是非常重要的,要理解它并能帮助解决一些实际问题. 面试实录 打开一个URL,在网络层面都发生了哪些事情?(当中说到了DNS原理,这个是绕不过的) 用过 Linux 么?你用它平时都做什么事情啊?(首先是在该环境下写代码,搭建过一些集群…
术语表 第 6 章 函数 二义性调用(ambiguous call): 是一种编译时发生的错误,造成二义性调用的原因时在函数匹配时两个或多个函数提供的匹配一样好,编译器找不到唯一的最佳匹配.    实参(argument): 函数调用时提供的值,用于初始化函数的形参.    Assert: 是一个预处理宏,作用于一条表示条件的表达式.当未定义预处理遍历NDEBUG时,assert对条件求值.如果条件为假,输出一条错误信息并终止当前程序的执行.    自动对象(automatic object):…