Introduction to Algorithms third Edition exercise 7.3

Source: Internet
Author: User
7.3-1

In order to make the worst case randomization, we are concerned about the expected running time of the algorithm. 7.3-2

In the worst case, each time random gets the index of the largest or smallest element in the Subarray, each partition will have two sub-arrays of 0 and n−1 0 and n-1, so each layer node will only call the random, so T (n) =t (n−1) +θ (1) =θ (n) t (n) = T (n-1) +\theta (1) =\theta (n)
In the best case, every time random gets exactly the subscript of the element centered in the sub-array, each partition appears ⌊n/2⌋\lfloor N/2\rfloor and ⌊n/2⌋−1 \lfloor N/2 \rfloor-1 Two sub-arrays, so T (n) =2t (N/2) +θ (1) =θ (n) T (n) =2t (N/2) +\theta (1) =\theta (n)

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.