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 7581401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:11:37+00:00 2026-05-30T18:11:37+00:00

I have a quick sort algorithm and a counter that I increment every time

  • 0

I have a quick sort algorithm and a counter that I increment every time a compare or swap is performed. Here are my results for random integer arrays of different sizes –

Array size --- number of operations

10000 --- 238393

20000 --- 511260

40000 --- 1120512

80000 --- 2370145

Edit:

I have removed the incorrect question I was asking in this post. What I am actually asking is –

What Im trying to find out is ‘do these results stack up with the theoretical complexity of quicksort (O(N*log(N)))?

  • 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-30T18:11:39+00:00Added an answer on May 30, 2026 at 6:11 pm

    Though you cannot get the asymptotic bound of your method by only experimenting, sometimes you can evaluate its behavior by drawing a graph of the complexities similar to your function, and looking at the behavior.

    You can do it with drawing a graph of some functions y = f(n) such that f(10000) ~= g(10000) [where g is your function], and check the behavior difference.

    In your example, we get the following graphs:

    graph

    We can clearly see that:

    1. The behavior of your results is sub quadric
    2. The behavior is above linear.
    3. It is very close to logarithmic behavior, but just a bit "higher".

    From this, we can deduce that your algorithms is probably O(n^2) [not strict! remember, big O is not a strict bound], and also could be O(nlogn), if we deduce the difference from the O(nlogn) function is a noise.

    Notes:

    1. This method proves nothing about the algorithm, and particularly
      doesn’t give you any worst case [or even average case] bound.
    2. This method is usually used to evaluate two algorithms, and not some pre defined functions, to check which is better for which inputs.

    EDIT:

    I drew all the graphs as y1(x) = f(x), y2(x) = g(x) , … because I found it easier to explain this way, but usually when you compare two algorithms [as you often actually use this method], the function is y(x) = f(x) / g(x), and you check if y(x) is staying close to 1, growing, shrinking?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written down the following program that uses the quicksort algorithm to sort
I have a quick question about fetching results from a weakly typed cursor and
I am trying to implement Quick Sort algorithm. Following code works for unique elements
I have a simple f# quick sort function defined as: let rec qsort(xs:List<int>) =
I have to implement a multi threaded Merge Sort and Quick sort in Java
From time to time have I come across manually implemented sort and/or search algorithms,
I am solving UVa site problems, I have a problem that I must sort
I have an array of N numbers which are same.I am applying Quick sort
The Heap Sort sorting algorithm seems to have a worst case complexity of O(nlogn),
This is a weired problem, I have implemented simple quick sort as follows.. static

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.