- 博客(26)
- 资源 (5)
- 收藏
- 关注
原创 ch8-4: find the permutations of a string
This is a similar problem to ch 8.3.In recursion, we can think a little bit different: so here are two recursion version://Write a method to compute all permutations of a string// http://www.chao
2014-01-30 06:31:18
856
原创 Ch8.3: find all the subsets of a set
In this problem, We can still use the power of BINARY number to represent the nth number is shown or not.For example:{2, 0, 1, 4}, if I use _ _ _ _ (4 bits) to represent each numbers. Then I can h
2014-01-30 04:01:44
865
原创 Lesson1: Udacity parallel programming 学习笔记
In this lesson, we learned the 4 partitions of CUDA program and how to utilize the block, thread for parallel programming in GPU.1. CUDA Malloc;2. CUDA Memcpy; from host to device3.
2014-01-28 05:13:27
1166
原创 Ch4.8: find all the path that a Binary tree sums up to a given value, may/maynot have parent pointer
In this problem, we should consider the path to the bottom, instead of hit-and-run.For example:The given sums up value is 8:then these are all correct paths:8;8=-2=2;2=0=6;2=0=6=-1=1;
2014-01-27 05:54:35
683
原创 ch4.7: given 2 huge Binary tree t1, t2(>1millon nodes), decide if one tree is subtree of another one
// Ch4.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 #include #includ
2014-01-25 12:37:56
988
原创 1/22/2014: 纪念第一个C++ programmer电面--F家
经过20天的CC刷题(其实是学习),才刚刚做到第四章。看看其他非ACM牛人,都是leetcode,CC,EPI滚瓜烂熟才去面。而且onsite确实是靠实力,要有做过大project之后才能真正融会贯通C++精神。Anyway,谢谢郭志给的refer,不然连电面的机会都没有。开头是C++基础题:1. Fib的2种写法:recursive和DP2. Struct和Class的区别;在C
2014-01-24 09:53:39
1192
原创 ch4.6: find the LCA of 2 nodes in a binary tree with 3 different methods
In this problem, it is important to fully understand the definition of least common ancestor of 2 nodes:it means: (from leetcode blog: 点击打开链接) _______3______ / \
2014-01-24 09:43:32
1258
原创 Ch4.5: find the (in-order tranversely) successor of a node in BST.
There are 3 methods:1. simply in order tranverse and get the ascending array, every next element is the successor of previous element.2. It is Hawstein's method: There are 2 conditions: 1st: hav
2014-01-23 11:14:30
850
原创 Ch4.4: array to Balanced tree and print each level
Q: an ordered array is given, need to convert into a balanced binary tree and then BFSly print each level as a D-dimentional linked listNeed to understand list, vector, BFS, recursion, scope of memb
2014-01-22 17:16:41
681
原创 Ch4.3: transform an ordered array into a balanced Tree
In this problem, it is like the classical recursion example: draw the ruler as the sign of algorithms 4th textbook.In order to draw a balanced tree from an array, we need to keep left subtree.height
2014-01-22 08:45:52
803
原创 Ch4-2: find if 2 given vertices are connected in a directed map,BFS + JUST fix the DFS recursion
In this problem, there are 2 ways: BFS or DFS.Hawstein used BFS:#include #include #include #include using namespace std;const int maxn = 100;bool g[maxn][maxn], visited[maxn];int n;
2014-01-20 14:49:56
872
原创 Ch4-1: identify if a tree is "balanced" (注:CTCI 第四版和第五版的定义不一样)
To identify if the most different leaves, it is: If So we need to traverse the tree to find the leaves' depth, so we pick 1 of 3 traverse oders: the inorder.In order to implement a tree, need a s
2014-01-19 12:03:36
825
原创 二叉树的insertLC
今天看到学堂的05-d-2里面讲到insertLC,所以又复习了一下This pointer,constructor。二叉树里面最基本元素:BinNode的constructor是这样的:BinNode(T e, BinNodePosi(T) p = NULL, BinNodePosi(T) lc = NULL, BinNodePosi(T) rc = NULL,int h = 0, i
2014-01-16 18:38:00
887
原创 Ch3-6: sorting a stack in an ascending order
if only use 1 additional stack, then mimic the selection sort.or with 2 additional stacks, we can mimic merge sort or quick sort.Full code:// solution for Ch3-6 by mimicing selection sort
2014-01-15 17:49:29
700
转载 Ch3-6参考资料:C++的7种排序
看看对不对,再学习。#include #include using namespace std;//C++經典的7種排序演算法/*參考網頁:: http://www.caogenit.com/caogenxueyuan/yingyongfangxiang/rengongzhineng/1724.html*////////////////////////////
2014-01-15 16:24:27
559
原创 Ch3-5: implement myqueue with 2 stacks
since Stack is LIFO, Queue is FIFO;in order to implement LIFO, need to have a stack1 to buff the data and back to stack2 for pop. it is just like cooling the hot water with 2 cups, it can reverse th
2014-01-15 16:04:39
596
原创 Ch3-4: solve Hanoi in C++ with recursion, and with stack explicitly
Hanoi has these conditions:3 rods, N disks, initially N disks are ascendingly from top to down in 1st rod. Objective: move all N disks to the 3rd rod.It must follow these 3 laws:1. every t
2014-01-15 08:41:59
656
原创 Ch3-3: popat(int idx) of setofstack
Continue to use class to design solution, also, start to use STL, such as container (vector, stack, set, ...). save time and to be more professional.The design without popat method is similar to the
2014-01-15 07:00:24
887
原创 cc150做题计划
计划:12.29.2013 - 1.29.2013 做完第一遍题目,然后2月做leetcode。2月底面试前完成200题C++。这里记录一下ctci学习的参考资料。1. hawstein的blog2. https://github.com/ChengTian/CtCI3. absolute C++ 5th4. Primer C++5. learncpp:http
2014-01-14 08:45:30
2815
原创 Ch3-2: implement min() for a stack with O(1)
Here will show the thinking flow from bad to good.idea 1:const int MAX_INT = ~(1<<31);//2147483647struct node{ int val, min;};class StackWithMin{public: StackWithMin(int size){
2014-01-13 17:13:24
898
原创 Ch3-1: use a single array to implement three stacks.
Here it explains why Hawstein use this in his constructor, because he use size a parameter in his constructor while "size" is also a member variable(it's private), so he use this->size = size, explici
2014-01-13 06:57:13
1035
原创 Ch2-5: find the beginning of loop in a circular linked list---two solutions
Given a circular linked list, implement an algorithm which returns node at the beginning of the loop.DEFINITIONCircular linked list: A (corrupt) linked list in which a node’s next pointer poin
2014-01-11 09:48:28
927
原创 Ch2-4:add reverse 1 digit format number in linked list
You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1’s digit is at the head of the list. Write a function
2014-01-11 09:06:13
841
原创 Ch2-3: remove the middle node in a singly linked list
Implement an algorithm to delete a node in the middle of a single linked list, given only access to that node.EXAMPLEInput: the node ‘c’ from the linked list a->b->c->d->e Result: nothing is retur
2014-01-10 10:19:09
883
原创 Ch2-2: return the nth to the last node data of a singly linked list
In this problem, I need to find the nth to the last node data of a singly linked list. In order to do so, one good way is to use recursion, since it is automatically put recursion part into stack an
2014-01-05 13:56:51
1226
原创 Ch2-1: de-duplicate a linked-list with/without additional buffer
Chap 2 deal with linked-list. So I finished XuetangCh2-1:The different is the time complexity and the reason we use 2 poniters/3 pointers:p is the base addr, q is the increased pointer;c is th
2014-01-05 07:01:40
820
FreeRTOS textbook
2014-02-12
韩国SSL论文
2013-09-17
Tomasulo 代码
2013-09-17
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人