- 博客(10)
- 资源 (2)
- 收藏
- 关注
原创 crack the code intervie 4.8
You are given a binary tree in which each node contains a value. Design an algorithm to print all paths which sum up to that value. Note that it can be any path in the tree - it does not have to start
2014-03-11 20:08:41 741
原创 crack the code interview 4.7
You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1.#include using namespace std;stru
2014-03-11 20:08:02 570
原创 crack the code interview 4.6
Design an algorithm and write code to find the first common ancestor of two nodes in a binary tree. Avoid storing additional nodes in a data structure. NOTE: This is not necessarily a binary search tr
2014-03-11 20:06:58 509
原创 crack the code interview 4.5
Write an algorithm to find the ‘next’ node (i.e., in-order successor) of a given node in a binary search tree where each node has a link to its parent.#include using namespace std;struct T
2014-03-11 20:06:20 590
原创 crack the code interview 4.4
Given a binary search tree, design an algorithm which creates a linked list of all the nodes at each depth (i.e., if you have a tree with depth D, you’ll have D linked lists).#include #include
2014-03-11 20:05:39 649
原创 crack the code interview 4.3
Given a sorted (increasing order) array, write an algorithm to create a binary tree with minimal height.#include using namespace std;struct TreeNode{ int value; TreeNode * left;
2014-03-11 20:05:02 363
原创 crack the code interview 4.2
Given a directed graph, design an algorithm to find out whether there is a route between two nodes.#include #include #include using namespace std;enum State {unvisited, visited, visiti
2014-03-11 20:04:10 573
原创 计算机图形学——表面细分
表面细分,举一个粒子,一个立方体,细分很多次以后,表面可有变得平滑。表面细分的一个关键步骤就是加点。如上图的a只有几个点,进过多次细分后,可有增加到很多点,像d一样。如何插点呢,看下图:一个图形,是由很多个三角形组成的,首先,在三角形的边上插点。如果一条边包含在两个三角形中,则插入的点的坐标按照第一个图进行分配,即3/8 * left + 3/8 * right +
2014-03-11 19:59:39 2862
原创 计算机图形学——图像压缩
首先,Huffman算法就可以进行压缩,但是直接用Huffman算法对图片的压缩效率并不高。采用Haar Wavelets,对图片的像素进行处理。首先,将第2i个值和第2i+1个值进行操作,相加除以2,得到的值,存放在i个位置,相减除以2,得到的值放在width/2 + i的像素上。其中,i的取值范围:[0,width/2].如下图所示:
2014-03-11 19:25:50 1476
原创 计算几何——凸包
1.1 应用场景有多个手机信号发射器,求解一个最小区域,要求所有的发射器都包含在这个最小区域中,并且任意两台发射器之间的交流包含于在这个区域内。将所有的发射器看做为点,任意两个点之间的连线都包含于一个平面S。1.2 问题定义一个平面的子集S是凸的,当且仅当S中的任意两个点之间的连线都包含于S中。点集P的凸包是所有包含P的凸集中的最小的一个。凸包是唯一的。1.3 算法分析将所
2014-03-11 19:01:21 619
电话簿软件的实现(动态查找表算法的应用)
2011-02-18
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人