Introduction to MIT algorithms (1)-Introduction to Algorithms

Source: Internet
Author: User

I decided to take a few big parts. Today, I started to study in open classes. One is to consolidate my understanding of algorithms, and the other is to share my learning experience.

The algorithm class at Princeton University seems to have been completed. There are only handouts, and there seems to be no video. Next I will take an introduction to algorithms at MIT.

  I am a lazy child. I hope you can supervise me. No supervision, I can't continue, er, haha. Thank you.

  Why learning algorithms?

(1) What is more important than performance? Correctness, conciseness, maintainability, cost, functionality, modularity, security, scalability, and user experience.

(2) If algorithms and performance are not important, why? Why learning? Performance and experience are associated. Real-time performance is the foundation of other products. performance is like currency. You use java to replace c, and the performance is reduced by three times for the advantages of other aspects, such as objectization, exception mechanism.

  Sorting Problems

  (1) Insert Sort)

  

Insert Sort Analysis: 

The running time depends on input, such as the number of inputs and input sorting. The number of moves and comparisons can be used to measure the time complexity.

Maximum time (the worst case is a commitment, a guarantee): the input is in reverse order.

  

Comparison times: (n + 2) (n-1)/2

Number of moves: (n + 4) (n-1)/2

Average time (Expected Value of Time): n + input distribution, for example, even distribution.

  

Minimum Time (preferably): Enter the forward order.

Times: n-1

Number of moves: 0

Is insertion sorting fast? When n is very small, it is very fast. When n is very large, it will be very slow, usually n <= 8.

  (2) Merge Sort)

Merge two sorted sequences into one. The Merge Sorting Algorithm depends on the merge operation.

  Merge Sort Analysis:

In reality, when n> 30, Merge Sorting will beat insertion sorting.

The number of comparison operations is between and.

The number of assignments is.

  

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.