Course Merge Sorting-2011.10.27
The efficiency of Bubble sort is still low. The measurement efficiency includes space occupation and CPU cycles. The sorting condition is measured by the worst condition, such as reverse order. Merge Sort is highly efficient.
Merge Sort (Merge Sorting) is described in detail. It is easy to implement using the recursion (recursion) method. The algorithm is as follows:
Sore (){
If (n <2)
Return
Else
Sore () left half
Sore () Right Half
Merge () combines the left and right semi-ordered sorting
}
Use Time: T (n) = T (n/2) + T (n/2) + n; if n> 1; T (n) = 0, if (n = 1), the total efficiency is O (NLogN ).
Lesson 1 pointer-2011.10.28
Design, it is very important to have a good user experience, not just correct work.
This section describes pointers. For example, int X a = & B; int temp = * a; (pointer a refers to content, that is, B ).
For memory, from top (low address) to bottom (high address), first static allocation, gobal and static data, static allocation at the beginning of the program; under is the dynamic allocation of space in the operation, known as heap, is the control allocated in C through malloc or Java through new. Finally, stack is allocated from the bottom up. It is automatically allocated during running. It is used for the storage space of functions or methods. When a function is called, a space is allocated to it on the stack, store related local parameters. Since the heap is from top to bottom, the stack is from bottom to top. If there is no space, overflow will occur and a Core segment error will occur in C. In general, the C language uses stacks to store the function return address/Stack callback base address, complete function parameter transfer, and store function local variables.
If the program needs to dynamically allocate memory during running, Heap can be used.
Related Links: My articles related to programming ideas