├── BalanceBinaryTree.cpp ├── HeapSort.cpp ├── Huffman ├── Huffman.cpp ├── Huffman.exe ├── Huffman_1.cpp ├── Huffman_2.cpp └── README.md ├── ImprovedQuickSort.cpp ├── InsertSort.cpp ├── Linked_List.cpp ├── QuickSort.cpp ├── README.md ├── SimpleInsertSort.cpp ├── SimuLatingStack.h ├── StackTest.cpp ├── StraightInsertSort.cpp ├── queue.cpp ├── queue.h └── 二叉树.PNG /BalanceBinaryTree.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuujiro/Data_Structure_and_Algorithm_Analysis/770c40d4034ecb2ad31788065ab7194898974268/BalanceBinaryTree.cpp -------------------------------------------------------------------------------- /HeapSort.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuujiro/Data_Structure_and_Algorithm_Analysis/770c40d4034ecb2ad31788065ab7194898974268/HeapSort.cpp -------------------------------------------------------------------------------- /Huffman/Huffman.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuujiro/Data_Structure_and_Algorithm_Analysis/770c40d4034ecb2ad31788065ab7194898974268/Huffman/Huffman.cpp -------------------------------------------------------------------------------- /Huffman/Huffman.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuujiro/Data_Structure_and_Algorithm_Analysis/770c40d4034ecb2ad31788065ab7194898974268/Huffman/Huffman.exe -------------------------------------------------------------------------------- /Huffman/Huffman_1.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuujiro/Data_Structure_and_Algorithm_Analysis/770c40d4034ecb2ad31788065ab7194898974268/Huffman/Huffman_1.cpp -------------------------------------------------------------------------------- /Huffman/Huffman_2.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuujiro/Data_Structure_and_Algorithm_Analysis/770c40d4034ecb2ad31788065ab7194898974268/Huffman/Huffman_2.cpp -------------------------------------------------------------------------------- /Huffman/README.md: -------------------------------------------------------------------------------- 1 | # Huffman 2 | 数据结构: 哈夫曼编译码器 3 | 4 | 数据结构课作业 5 | -------------------------------------------------------------------------------- /ImprovedQuickSort.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuujiro/Data_Structure_and_Algorithm_Analysis/770c40d4034ecb2ad31788065ab7194898974268/ImprovedQuickSort.cpp -------------------------------------------------------------------------------- /InsertSort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | void print (int a[], int n, int i) 4 | { 5 | cout << i << ":"; 6 | for (int j = 0; j < 8; j++){ 7 | cout << a[j] << " "; 8 | } 9 | cout << endl; 10 | } 11 | void ShellInsertSort(int a[], int n, int dk){ 12 | for(int i = dk; i < n; i++){ 13 | if(a[i] < a[i-dk]){ 14 | int j = i - dk; 15 | int x = a[i]; 16 | a[i] = a[i-dk]; 17 | while(x < a[j]){ 18 | a[j+dk] = a[j]; 19 | j -= dk; 20 | } 21 | a[j+dk] = x; 22 | } 23 | print(a, n, i); 24 | } 25 | } 26 | void shellSort(int a[], int n){ 27 | int dk = n / 2; 28 | while(dk >= 1){ 29 | ShellInsertSort(a, n, dk); 30 | dk = dk / 2; 31 | } 32 | } 33 | int main() 34 | { 35 | int a[8] = {3, 1, 5, 7, 2, 4, 9, 6}; 36 | shellSort(a,8); 37 | print(a,8,8); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /Linked_List.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuujiro/Data_Structure_and_Algorithm_Analysis/770c40d4034ecb2ad31788065ab7194898974268/Linked_List.cpp -------------------------------------------------------------------------------- /QuickSort.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuujiro/Data_Structure_and_Algorithm_Analysis/770c40d4034ecb2ad31788065ab7194898974268/QuickSort.cpp -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DataStructureFoundationAndAlgorithmAnalysis 2 | This repository is used for coding casually。 3 | -------------------------------------------------------------------------------- /SimpleInsertSort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /SimuLatingStack.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | #define MAXSIZE 0xffff 6 | 7 | //Write the stack with the template class (template) of c++ 8 | template 9 | class my_stack 10 | { 11 | int top; 12 | type *my_s; 13 | int MAXSIZE; 14 | 15 | public: 16 | my_stack():top(-1),maxsize(MAXSIZE) 17 | { 18 | my_s = new type[maxsize]; 19 | if(my_s == NULL) 20 | { 21 | cerr << "Dynamic storage allocation failed. " << endl; 22 | exit(1); 23 | } 24 | } 25 | ~my_stack() 26 | { 27 | delete[] my_s; 28 | } 29 | //Determine whether or not it is empty 30 | bool Empty(); 31 | // pushed on the stack 32 | void Push(type tp); 33 | //Return the top element of the stack 34 | type Top(); 35 | //poped out the stack 36 | void Pop(); 37 | //Return the size of the stack 38 | int Size(); 39 | }; 40 | 41 | template 42 | bool my_stack::Empty() 43 | { 44 | if(top == -1){ 45 | return true; 46 | } else{ 47 | return false; 48 | } 49 | } 50 | 51 | template 52 | type my_stack::Top() 53 | { 54 | if(top != -1){ 55 | return my_s[top]; 56 | }else{ 57 | cout << "Empty Stack!" << endl; 58 | exit(1); 59 | } 60 | } 61 | 62 | template 63 | void my_stack::Push(type tp) 64 | { 65 | if(top + 1 < maxsize){ 66 | my_s[++top] = tp; 67 | }else{ 68 | cout << "Full Stack!" << endl; 69 | exit(1); 70 | } 71 | } 72 | 73 | template 74 | void my_stack::Pop() 75 | { 76 | if(top >= 0){ 77 | top --; 78 | }else{ 79 | cout << "Empty Stack!" << endl; 80 | exit(1); 81 | } 82 | } 83 | 84 | template 85 | int my_stack::Size() 86 | { 87 | return top+1; 88 | } 89 | -------------------------------------------------------------------------------- /StackTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "AnalogStackOperation.cpp" 3 | using namespace std; 4 | int main() 5 | { 6 | my_stack stk; 7 | for(int i = 0; i < 50; i++){ 8 | stk.push(i); 9 | } 10 | cout << "The size of YourStack is " << stk.size() << endl; 11 | while(!stk.Empty()) 12 | { 13 | cout << stk.Top() << endl; 14 | stk.Pop(); 15 | } 16 | cout << "The size of YourStack is " << stk.size() << endl; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /StraightInsertSort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | void print(int a[], int n, int i){ 4 | cout << ":"; 5 | for(int j = 0; j < 8; j++){ 6 | cout << a[j] << " "; 7 | } 8 | cout << endl; 9 | } 10 | void InsertSort(int a[], int n) 11 | { 12 | for(int i = 1; i < n; i++){ 13 | if(a[i] < a[i-1]){ 14 | int j = i-1; 15 | int x = a[i]; 16 | a[i] = a[i-1]; 17 | while(x < a[j]){ 18 | a[j+1] = a[j]; 19 | j--; 20 | } 21 | a[j+1] = x; 22 | } 23 | print(a, n, i); 24 | } 25 | } 26 | int main() 27 | { 28 | int a[8] = {3, 1, 5, 7, 2, 4, 9, 6}; 29 | InsertSort(a,8); 30 | print(a,8,8); 31 | } 32 | -------------------------------------------------------------------------------- /queue.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuujiro/Data_Structure_and_Algorithm_Analysis/770c40d4034ecb2ad31788065ab7194898974268/queue.cpp -------------------------------------------------------------------------------- /queue.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuujiro/Data_Structure_and_Algorithm_Analysis/770c40d4034ecb2ad31788065ab7194898974268/queue.h -------------------------------------------------------------------------------- /二叉树.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fuujiro/Data_Structure_and_Algorithm_Analysis/770c40d4034ecb2ad31788065ab7194898974268/二叉树.PNG --------------------------------------------------------------------------------