![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
落难的清哇
这个作者很懒,什么都没留下…
展开
-
算法——排序专题
快速排序(算法导论版) version1:左边第一个元素为主元#include #include #include using namespace std; int Partition(int A[], int left, int right)// { int x = A[left];//主元 int i = left; for (int j = left+1; j <=right; j+原创 2015-12-29 20:34:42 · 306 阅读 · 0 评论 -
二叉搜索树(c++)
该版本翻译了算法导论中的伪代码。 水平有限,不足之处望指出。 #ifndef BST_H #define BST_H using namespace std; template struct BstNode{ BstNode(T k = 12, BstNode* lt = NULL, BstNode *rt = NULL, BstNode *pt = NULL) :key(k), left(l原创 2015-12-19 09:45:10 · 299 阅读 · 0 评论 -
链式二叉树
清华数据结构 殷人昆版本的代码。 传到博客上,作为备份。底下实现了绝大部分的代码(部分使用了文件操作) #include #include #include #include using namespace std; template struct BinTreeNode{ T data; BinTreeNode *leftChild, *rightChild; BinTreeNode(原创 2015-12-03 23:11:15 · 410 阅读 · 0 评论 -
堆排序
利用最小堆的性质。每次都移除最顶端的元素,然后重新排序成最小堆,如此循环。 #include #include"MinHeap.h" using namespace std; int main() { int Cnt = 9; int x; int A[] = { -2, 1, 7, 8, 0, 6, 5, 5, 4 }; cout << "The array is: "; for (i原创 2015-12-03 23:14:28 · 271 阅读 · 0 评论 -
单链表 C++实现
自己开学写的小作业,留给自己看。 #include #include using namespace std; template struct LinkNode{ T data; LinkNode * link; LinkNode(LinkNode *ptr = NULL) { link = ptr; } LinkNode(const T& item, LinkNode *ptr = N原创 2015-12-03 23:31:07 · 291 阅读 · 0 评论 -
算法导论 动态规划之钢条切割
#include #include using namespace std; int UpToBottom(int *p,int n)//普通的自顶向下实现 { if (n == 0) return 0; int q = -1; for (int i = 1; i <= n; i++) { q = max(q, p[i]+UpToBottom(p, n - i)); } re原创 2016-03-25 13:47:02 · 536 阅读 · 0 评论 -
[LeetCode412] Fizz Buzz
Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”.原创 2016-12-11 09:52:11 · 487 阅读 · 0 评论 -
[leetCode] Reversing String
Write a function that takes a string as input and returns the string reversed. Example: Given s = "hello", return "olleh". Subscribe to see which companies asked this question public S原创 2016-12-11 13:37:49 · 608 阅读 · 0 评论