f*m
2 楼
自己顶一个
h*e
3 楼
不用专门练recursion的,还是多看多做题吧。有的题目recursive的解法
非常明显,难的反而是改成非recursive的,例如binary tree的遍历。
也有的题目recursive的解法不明显,但是最后做下来要比非recursive的
简洁。还有的题目硬用recursive反而不优。
DP的不少问题都可以用recursion来解,但是往往为了优化你还得改成
bottom-up的。不然你就多找些DP的问题来练练吧。
http://people.csail.mit.edu/bdean/6.046/dp/
【在 f*********m 的大作中提到】
: 自己顶一个
非常明显,难的反而是改成非recursive的,例如binary tree的遍历。
也有的题目recursive的解法不明显,但是最后做下来要比非recursive的
简洁。还有的题目硬用recursive反而不优。
DP的不少问题都可以用recursion来解,但是往往为了优化你还得改成
bottom-up的。不然你就多找些DP的问题来练练吧。
http://people.csail.mit.edu/bdean/6.046/dp/
【在 f*********m 的大作中提到】
: 自己顶一个
f*m
4 楼
谢谢。马上就要面试,不知还来不来得及多看多做题啊。
f*m
6 楼
谢谢。希望如此吧。
y*n
7 楼
Function to check if a singly linked list is palindrome has a very beautiful
recursive solution.
http://www.geeksforgeeks.org/archives/1072
recursive solution.
http://www.geeksforgeeks.org/archives/1072
p*2
8 楼
recursion就是DFS。
f*m
9 楼
"recursion就是DFS。"
这个心得恐怕需要做过很多题才能体会得到。
这个心得恐怕需要做过很多题才能体会得到。
b*e
11 楼
sort, link list, trees are great study cases for recursion.
For link list and trees, cuz these structures are defined recursively.
Sometimes, the recursive solution is more intuitive.
Only for linked list:
a few examples:
1: Get the length of the link list
2: Get the max/min value of linked list
3: Get the nth/last nth number of the list
4: Reverse linked list(There should be 2 recursive version, one with
carryover)
5: Sort linked list (this is hard)
6: Copy linked list
7: Delete a value in a sorted/unsorted linked list
8: Find a number in unsorted/sorted linked list
9: Insert a number in sorted linked list
10: Get the sum of linked list
These are simple coding problems, you can solve this non-recursively but
doing it recursively will get your hands warm.
【在 f*********m 的大作中提到】
: 对于recursive总是掌握不了,大家有什么比较好的这方面的学习资料推荐吗?
: 谢谢。
For link list and trees, cuz these structures are defined recursively.
Sometimes, the recursive solution is more intuitive.
Only for linked list:
a few examples:
1: Get the length of the link list
2: Get the max/min value of linked list
3: Get the nth/last nth number of the list
4: Reverse linked list(There should be 2 recursive version, one with
carryover)
5: Sort linked list (this is hard)
6: Copy linked list
7: Delete a value in a sorted/unsorted linked list
8: Find a number in unsorted/sorted linked list
9: Insert a number in sorted linked list
10: Get the sum of linked list
These are simple coding problems, you can solve this non-recursively but
doing it recursively will get your hands warm.
【在 f*********m 的大作中提到】
: 对于recursive总是掌握不了,大家有什么比较好的这方面的学习资料推荐吗?
: 谢谢。
f*m
12 楼
谢谢:)
【在 b********e 的大作中提到】
: sort, link list, trees are great study cases for recursion.
: For link list and trees, cuz these structures are defined recursively.
: Sometimes, the recursive solution is more intuitive.
: Only for linked list:
: a few examples:
: 1: Get the length of the link list
: 2: Get the max/min value of linked list
: 3: Get the nth/last nth number of the list
: 4: Reverse linked list(There should be 2 recursive version, one with
: carryover)
【在 b********e 的大作中提到】
: sort, link list, trees are great study cases for recursion.
: For link list and trees, cuz these structures are defined recursively.
: Sometimes, the recursive solution is more intuitive.
: Only for linked list:
: a few examples:
: 1: Get the length of the link list
: 2: Get the max/min value of linked list
: 3: Get the nth/last nth number of the list
: 4: Reverse linked list(There should be 2 recursive version, one with
: carryover)
相关阅读
刚工作一个月,公司说工资定高了,要降IT bubble的标志:本版全都在讨论代码面试我也来求个祝福吧老中一个很大的问题是奢谈高线,漠视底线。 (转载)用于申请H1B的简历要写多详细?支持共和党的,共和党急需高科技码工的帮助 (转载)怎么回答公司问你要不要sponsor H1bh1b的prevailing wage是要在10/1后达到?哪位大侠给refer下redfin?冬天面试,可以穿西装而不打领带么?H1B/LCA申请有需要本人签名的地方吗?[Refer,招工] 02/2014刚在meeting上跟老印干了一仗 (转载)小公司被收购对普通员工核算还是IPO千老小留都来刷题挨踢吧A家aws VS G家gtechLinkedIn 的online test 是什么样子的?有人做过吗?Job openning for Sr Accountant弱问 consultant VS headhunterPhD申请opt问题第二波.....