Big liar data Structure--algorithm

Source: Internet
Author: User

algorithm: An algorithm is a description of the solution steps for a particular problem, represented as a finite sequence of instructions in a computer, and each instruction represents one or more operations.

Why is the data structure and algorithm said together?
Think of Romeo and Juliet, Butterfly and Lovers, missing one you will always find it strange.

Five basic features of the algorithm:

  • Input: There are 0 or more inputs;
  • Output: 1 or more outputs;
  • Have the poor sex: The step is limited, cannot infinite cycle goes down;
  • Certainty: There is definite meaning, can not appear two semantics;
  • Feasibility: Each step can be completed in a limited number of times.

Requirements for algorithmic design:

  • Correctness: can correctly reflect the problem, get the correct answer to the problem;
  • Readability: Easy to read, understand and communicate;
  • Robustness: Even if the input is not legal, the algorithm can be processed, rather than the exception or abort;
  • Time is efficient and storage is low: Like the people in life want to spend the least time, do the biggest thing.

The method of measuring the efficiency of the algorithm:

  1. Afterwards statistic method: Use the test good program and the data, use the computer to test the running time judgment algorithm's merits and demerits. This method has great shortcomings, must be designed in advance procedures, the risk of large, time is likely to rely on computer hardware configuration, algorithm testing data selection difficulties, such as the size of the data volume will affect the run time.
  2. Pre-analysis and estimation method: estimate before programming. Depends on the following factors: the algorithm adopted the strategy, the method (the root of the algorithm is good or bad), the Code quality (software) generated by the compilation, the input scale of the problem, the speed of machine instruction execution (hardware condition).

Algorithm time Complexity deduction method:

  1. Replaces all the addition constants in the run time with row number 1, for example, the time complexity of f (n) =1,f (n) =5 is O (1), also known as Constant street;
  2. In the modified run Count function, only the highest order items are retained;
  3. If the highest order exists and is not 1, the constant multiplied by the item is removed.
    The result is the Big O-order.

Big liar data Structure--algorithm

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.