Princeton University algorithm course algorithm part I week 3 sorting algorithm complexity sorting complexity

Source: Internet
Author: User

Computational Complexity: used to study the algorithm efficiency framework for solving specific problems x

Model of computation: allowed operations (allowable operations)

Cost Model: Operation counts)

Upper Bound (Upper Bound): maximum cost

Lower Bound (Lower Bound): Minimum Cost

Optimal Algorithm: The most probable cost algorithm (algorithm with best possible cost guarantee for X)

 

Example: Sorting

Computing Model: Decision Tree)

The height of the decision tree determines the time consumed.

Cost Model: Compares)

Upper Bound: The merge order is nlgn.

Lower Bound: nlgn

Optimal Algorithm: Merge Sorting (the upper time bound of mergesort reaches the lower time bound of the sorting algorithm, but mergesort consumes too much memory)

 

Factors Affecting sorting complexity

  • Start order of input
    • If the input is more ordered, we may not need to compare the nlgn times (in the case of sequential order, insert sort only needs to compare N-1 times)
  • Repeated Element
    • If the input contains repeated elements, we may not need to compare the nlgn times (3-way quicksort ))
  • Digital properties of keys: We can use digital/feature comparison (digit/character compares) instead of key compares to compare numbers and strings.

Princeton University algorithm course algorithm part I week 3 sorting algorithm complexity sorting complexity

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.