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

  • SEARCH
  • Home
  • 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 9267865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:39:34+00:00 2026-06-18T14:39:34+00:00

In quick sort we can choose a pivot value in different ways. Randomly choose

  • 0

In quick sort we can choose a pivot value in different ways. Randomly choose a pivot value is one of that. It says that when we choose the pivot value randomly , it minimize tha chance of having O(n^2). Can anyone explain how does it happen? Are there any disadvantages?

  • 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-06-18T14:39:35+00:00Added an answer on June 18, 2026 at 2:39 pm

    Both random and non-random pick produce an algorithm whose expected run time is Theta(n*log(n)), if the expected value is averaged over all possible inputs (permutations).

    In practice not all input permutations are equally probable. In particular you often get sorted or nearly sorted arrays when pick-first gives Theta(n^2) complexity. On top of that if your picking algorithm is deterministic, an attacker can craft a nasty permutation to make your algorithm quadratic, thus achieving denial of service.

    Picking random element as the pivot guards against these non-random cases.

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

Sidebar

Related Questions

As we can choose median of 3 element partitioning to implement quick sort. Likewise
This is code that I came across implementing the quick sort algorithm. Can you
I've been assigned to implement a quick sort with a random pivot point (because
If possible, how can I improve the following quick sort(performance wise). Any suggestions? void
I have an application that performs a quick sort. It was working fine till
Possible Duplicate: Quick Sort with random pivot in Java The below written code of
Can anyone point out why this implementation of quick sort is not working, i
I'm working on a quick sort algorithm in C#, but I'm facing a strange
Is there a way to do very quick sort in perl? Like I have
I implemented a simple quick sort (code below) to count the average and worst

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.