Basic concepts of Data Structure c language and basic concepts of Data Structure c
Algorithm: A set of command sequences that complete specific tasks
Input, output, deterministic, finite, and valid.
Recursion: The function calls itself, or the function calls other functions, and this function calls the main function (indirect recursion ).
1) construct the boundary condition for recursive call termination
2) Implement recursive calls so that each recursive call can approximate the final solution.
Example:Binary Search Recursion
int binsearch(int list[],int searchnum,int left,int right){ int middle; if(lest<=right) { middle=(left+right)/2; switch(COMPARE(list[middle]),searchnum){ case -1:return binsearch(list,searchnum,middle+1,right); case 0:return middle; case 1:return binsearch(list,searchnum,left,middle+1);} } return -1;}
Typical Recursion: Factorial, binary coefficient, Horna rule, Fibonacci series, Aekerman function, Hanoi Tower, etc.
Data Type: Is the sum of an object set and a group of operations on these objects.
ABSTRACT Data Type: It is a data type. The specifications of operations on its data objects and objects are independent of the storage representation of objects and the implementation of operations on objects.
Algorithm performance analysis:
Performance Analysis: Time, space
Spatial complexity: Number of buckets required for execution from the beginning to completion.
S (P) = c + Sp (I)
C: fixed space requirements, independent of program input, output quantity, and size.
Sp (I): Variable storage space required by program P on instance I.
Time Complexity: The computing time required by the program from execution to completion.
Determined by the number of execution steps required for the function compiled by the program. There are three types of steps: the best, the worst, and the average.
Use a large OSN:
O (1): constant order
O (n): Linear order
O (logn): Log Level
O ( N2 ): Square level
O ( N3 ): Cubic level
O ( 2n ): Exponential
O (1)