iOS Development Basics notes-algorithms < three >

Source: Internet
Author: User

Complexity of the algorithm

The complexity of the algorithm is divided into time complexity and space complexity. Its function: Time complexity refers to the computational effort required to execute the algorithm, while space complexity refers to the memory space required to execute the algorithm. (The complexity of the algorithm is reflected in the amount of resources required to run the algorithm, the most important thing in computer resources is time and space (that is, register) resources, so complexity is divided into time and space complexity).

Sorting algorithm:

1. Bubble sort

2. Select sort

Each time a minimum (or maximum) element is selected from the data element to be sorted, it is stored at the beginning of the sequence until all the data elements to be sorted are exhausted. Select Sort is an unstable sort method

3. Quick Sort

Start by selecting one of the data (usually the first number of the array) as the key data, and then putting all the smaller numbers in front of it, all the larger numbers are placed behind it, this process is called a quick sort. It is important to note that fast sorting is not a stable sorting algorithm, that is, the relative position of multiple identical values may change at the end of the algorithm.

4. Insert Sort

Each step inserts a record to be sorted by the size of its key value into the appropriate position in the previously sorted file until all is inserted. The time complexity is O (n^2).

iOS Development Basics notes-algorithms < three >

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.