Data Structure Learning notes (I) Basic concepts and analysis algorithms and basic concepts of Algorithms

Source: Internet
Author: User

Data Structure Learning notes (I) Basic concepts and analysis algorithms and basic concepts of Algorithms

The efficiency of the solution is related:
Data Organization (bookshelves)
Space Utilization (recursion and non-recursion)
Algorithm used to solve the problem

 

What is an algorithm: a data object must be associated with a series of operations added to it, and the method used to complete these operations is an algorithm.

 

Algorithm features:
A finite Instruction Set (poor)
Sometimes some input may not exist (input)
Generate output)
Stop after certain steps (poor)
The following conditions must be met for each instruction:
There are well-defined goals that cannot be ambiguous. (Deterministic)
Within the scope that the computer can process.
The description does not depend on any computer language and is specific to the implementation means.

 

Algorithm evaluation:

Space complexity S (n): The program written according to the algorithm occupies the length of the storage unit during execution (too large, program interrupted)
Time Complexity T (n): the length of the execution time of a program written according to the algorithm. (The result is not returned. Calculate the number of multiplication and division, or select an original operation that is a basic operation for the study. addition and subtraction are not counted)

 

Why are all n functions: because both evaluations are related to the scale of the problem.

 

Tworst (n) Worst time complexity> = average Tavg (n) Complexity generally uses average complexity, because the worst time complexity is easier to calculate
A large O indicates that f (n) is the upper bound of T (n). A large Ω indicates that f (n) is the lower bound of T (n ).

 

Tips for complex analysis:
If the complexity of the two algorithms is T1 (n) = O (f1 (n) and T2 (n) = O (f2 (n ),
T1 (n) + T2 (n) = max (O (f1 (n), O (f2 (n )));
T1 (n) * T2 (n) = O (f1 (n) * O (f2 (n ));
If T (n) is a k-order polynomial of n, T (n) = O (k power of n) (max)
The time complexity of the for Loop = the number of cycles multiplied by the complexity of the Code
If-else time complexity = max (if condition complexity, complexity of two branches)

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.