算分分析与设计
钻石般的希望
这个作者很懒,什么都没留下…
展开
-
分而治之:实现数组排序
#include <iostream> using namespace std; template <class T> class DivideAndRule{ public: void MergeSort(T *a,int low,int high) { if(low>=high) return ; int mid=(low+high)/2; MergeSort(a,low,mid); ...原创 2021-01-15 19:37:21 · 164 阅读 · 1 评论 -
二分查找
#include <iostream> using namespace std; template <class T> class BinarySearch{ public: //默认为升序排列数组 int Position(T*a,int low,int high,T x) { if(low==high) { if(x==a[low]) return low; else ret...原创 2021-01-15 19:35:57 · 93 阅读 · 0 评论