The problem of sorting time complexity of "algorithm" string array

Source: Internet
Author: User
Title: There is a string array that sorts each string in the array alphabetically, followed by a dictionary order of the entire string array. Time complexity of the entire operation? Analysis:
  • 1. Assume that the longest string length is s, and that there are n strings in the array

  • 2. Sort each string: O (slogs)

  • 3. Order each string in the array alphabetically: O (N*slogs)

  • 4. Sort the entire string array in dictionary order: O (S*NLOGN)

Comprehensive:

Overall time complexity o = O (nslogs) + O (snlogn) = O (nslogs+sNlogn) =o (ns(logn+logs))

The problem of sorting time complexity of "algorithm" string array

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.