Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7585341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:09:08+00:00 2026-05-30T19:09:08+00:00

What is the best, worst and average case running times of an algorithm?

  • 0

What is the best, worst and average case running times of an algorithm?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:09:10+00:00Added an answer on May 30, 2026 at 7:09 pm

    In the simplest terms, for a problem where the input size is n:

    • Best case = fastest time to complete, with optimal inputs chosen.
      For example, the best case for a sorting algorithm would be data that’s already sorted.

    • Worst case = slowest time to complete, with pessimal inputs chosen.
      For example, the worst case for a sorting algorithm might be data that’s sorted in reverse order (but it depends on the particular algorithm).

    • Average case = arithmetic mean. Run the algorithm many times, using many different inputs of size n that come from some distribution that generates these inputs (in the simplest case, all the possible inputs are equally likely), compute the total running time (by adding the individual times), and divide by the number of trials. You may also need to normalize the results based on the size of the input sets.

    Complexity and running time are often expressed in “Big O notation,” which is used to describe the approximate amount of time an algorithm requires to complete, based the size of its input. Rob Bell wrote an excellent overview with very clear examples.

    The most commonly used Big O descriptions are

    • O(1) always terminates in about the same amount of time, regardless of the input size.
    • O(logN) takes a fixed additional amount of time each time the input size doubles.
    • O(N) takes twice as long to finish if the input size doubles.
    • O(N2) takes four times as long if the input size doubles.
    • O(2N) increases exponentially as the input size increases.

    You can see from the table below that the difference is small for small input sizes, but it can become tremendous as the input size increases even a little bit.

    Input Size              Time to Complete
                   O(1)  O(logN)   O(N)   O(N2)   O(2N)
         1           1       1      1       1       1
         2           1       2      2       4       4
         4           1       3      4      16      16
         8           1       4      8      64     256
        16           1       5     16     254   65536
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible for an algorithm/program to have the same worst-case and best-case time?
We have best case, average case and worst case time complexities. So someone asks
is there any nice GNU way how to measure average (worst case, best case)
A common theme I'm seeing in my courses are worst/best case performances for trees,
I recently came across this question What is the BEST-WORST case time to add
How do we find out the average and the worst case time complexity of
As a developer, I've learned that I usually gain a better understanding of best/worst
What are the best and worst emacs key bindings in development software? Ever since
I have a system that combines the best and worst of Java and PHP.
I want to create a route like //Widgets/PerformanceTable/['best' or 'worst' to sort by performance

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.