line breaks and indent
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
# Lecture 12 --- Advanced Recursion
|
# Lecture 12 --- Advanced Recursion
|
||||||
|
|
||||||
Review Recursion vs. Iteration
|
Review Recursion vs. Iteration
|
||||||
– Binary Search
|
|
||||||
|
- Binary Search
|
||||||
- “Rules” for writing recursive functions
|
- “Rules” for writing recursive functions
|
||||||
- Advanced Recursion — problems that cannot be easily solved using iteration (for or while loops):
|
- Advanced Recursion — problems that cannot be easily solved using iteration (for or while loops):
|
||||||
– Merge sort
|
– Merge sort
|
||||||
@@ -38,7 +39,8 @@ bool binsearch(const std::vector<T> &v, int low, int high, const T &x) {
|
|||||||
return binsearch(v, low, mid, x);
|
return binsearch(v, low, mid, x);
|
||||||
else
|
else
|
||||||
return binsearch(v, mid+1, high, x);
|
return binsearch(v, mid+1, high, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
bool binsearch(const std::vector<T> &v, const T &x) {
|
bool binsearch(const std::vector<T> &v, const T &x) {
|
||||||
return binsearch(v, 0, v.size()-1, x);
|
return binsearch(v, 0, v.size()-1, x);
|
||||||
|
|||||||
Reference in New Issue
Block a user