Note of introduction of Algorithms (Lecture 1)
2013-05-05 23:05
459 查看
This is the note for introduction of Algorithms, based on the MIT open class. The lecture 1 focus on how to measured the performance of program, and two sort algorithms has been mentioned, which is insertion sort and merging sort.
Here is the c program I wrote.I wish it could be a nice start, and whole open classes could been finished in 2013 finnally.
insertion sort
View Code
Here is the c program I wrote.I wish it could be a nice start, and whole open classes could been finished in 2013 finnally.
insertion sort
View Code
/* * from : the beginning of the array * to : the end of the array * len : the length of input array */ void merging_sort(int from, int to){ int i,j,p = 0; if (from < to) { int mid = (from + to)/2; //recursively sort merging_sort(from, mid); merging_sort(mid + 1, to); //merge i = from; j = mid + 1; p = from; while ((i <= mid) || (j <= to)) { if (i > mid) { g_output[p] = g_input[j]; j++; p++; } else if (j > to) { g_output[p] = g_input[i]; i++; p++; }else{ if (g_input[i] < g_input[j]) { g_output[p] = g_input[i]; i++; p++; } else { g_output[p] = g_input[j]; j++; p++; } } }//end of while for (int t = from; t <= to; t++) { g_input[t] = g_output[t]; } } return; }
相关文章推荐
- note of introduction of Algorithms(Lecture 3 - Part1)
- note of introduction of Algorithms(Lecture 2)
- Lecture 1: Introduction, complexity of algorithms, asymptotic growth of functions.
- Lecture Note - 北大 - 算法设计与分析 Design and Analysis of Algorithms - Wanling Qu
- Ex5.1-3 of Introduction to Algorithms
- Jordan Lecture Note-1: Introduction
- introduction of algorithms----insertion sort
- introductionOfInvestment:Lecture 1
- Introduction to The Design and Analysis of Algorithms (1)
- Lecture 1 Analysis of Algorithms
- Jordan Lecture Note-1: Introduction
- Ex 9.3-8 of Introduction to algorithms
- Ex 9.3-8 of Introduction to algorithms
- Ex5.1-2 of introduction to algorithms
- Design and Analysis of Algorithms_Introduction
- Introduction: Analysis of Algorithms, Insertion Sort, Merge Sort
- Ex5.1-2 of introduction to algorithms
- exercises2.1-4 of introduction to Algorithms
- [翻译]斯坦福CS20SI:基于Tensorflow的深度学习研究课程笔记,Lecture note 1: Introduction to TensorFlow
- Ex 10.4-3 of introduction to algorithms