- 博客(8)
- 资源 (10)
- 收藏
- 关注
原创 自己写的一个基于数组实现的栈,欢迎大家批评指正,共同进步
头文件: #include using std::cout; using std::endl; using std::cin; #pragma once template class Stack{ public: Stack(void); ~Stack(void); private: T* arr; static const int EVERY_SIZE
2012-08-23 23:12:38
307
原创 中位数和顺序统计(线性时间)算法导论9.2
The general selection problem appears more difficult than the simple problem of finding a minimum. Yet, surprisingly, the asymptotic running time for both problems is the same: Θ(n). In this section,
2012-08-23 12:31:45
585
原创 线性时间排序之基数排序
头文件 Number.h #pragma once #include #include #include using namespace std; class Number{ public: Number(void); Number(int num); ~Number(void); int value; int operator[](int i){//ret
2012-08-22 22:49:45
311
原创 线性时间排序之计数排序(算法导论8.2)
Counting sort assumes that each of then input elements is an integer in the range 0 to k, for some integer k. When k =O(n), the sort runs in Θ(n) time. The basic idea of counting sort is to deter
2012-08-22 15:38:12
462
原创 冒泡排序,鸡尾酒排序,插入排序,堆排序,快排序,归并排序
#include #include using namespace std; //int arr[11]= {3423,4,6,2,8,3,1,34,234,523,1234}; void printArray(int arr[], int num){ for(int i=0;i cout } cout } void swap(int& a,int&b){ int
2012-08-20 20:38:40
436
原创 堆(算法导论 part1 foundations, chapter 6 heapsort)
#include #include using namespace std; const int AD = 6; int arr[AD]; void initializeArray(int arr[], int n){ srand(time(0)); for(int i=0;i arr[i] = rand()%400; } } void swap(int& a, i
2012-08-20 11:36:14
323
原创 给定一个十进制正整数N,写下从1开始,到N的所有整数,然后数一下其中1的个数(编程之美P128)
#include #include struct SpliteNum{ int high; int cut; int low; }; using namespace std; int f(long num){ int counter = 0; for(int i=1;i int temp = i; while(temp){ counter +=
2012-08-17 22:05:34
5011
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人