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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:16:49+00:00 2026-05-25T20:16:49+00:00

In Book Intro to algorithm — by CLRS mentioned in Sec-9.1 that Simultaneous Maximum

  • 0

In Book “Intro to algorithm — by CLRS” mentioned in Sec-9.1 that Simultaneous Maximum & minimum finding can be done in the running time 3*floor(n/2). Same as for lower-bound also.

I have written the following algorithm (taking help from CLRS) whose lower-bound is 2*floor(n/2). [ This is wrong — thanks to Ricky Bobby ]

I m using the variables: 'max' & 'min' to denote maximum & minimum elements, 'i' as indexing variable.

Simultaneous_Maximum_&_Minimum (A, n)  // Array A[1...n]
{
  1. If n is even, compare the first two elements and assign the larger to max and
      smaller to min. Set StartIndex = 3.

  2. If n is odd, set both max & min to the first element. Set StartIndex = 2.

  3. for (i = StartIndex; i <= n; i = i+2 ) {  // Processing elements in pair

         if (max < A[i]) {          // Compare max with A[i]
               if (A[i] < A[i+1])   // Compare max with A[i+1]
                     max = A[i+1];  // we sure that A[i] or A[i+1] can't be min

               else {                 // When max less than A[i] but A[i] not less than A[i+1]
                     max = A[i];        // Set A[i] as max
                     if (min > A[i+1])  // Possible that A[i+1] can be min
                          min = A[i+1]; // if yes, set A[i+1] as min
               }
         }

            // When max is not less than A[i]
         else if (min > A[i]) {        // Compare min with A[i]
                     if (A[i] > A[i+1])  // Compare min with A[i+1]
                           min = A[i+1]; // we sure that A[i] or A[i+1] can't be max

                     else {             // When min is greater than A[i] but A[i] not greater than A[i+1]
                           min = A[i];       // Set A[i] as min
                           if (max < A[i+1]) // Possible that A[i+1] can be max
                                max = A[i+1] // if yes, set A[i+1] as max
                     }
                }                    
         }

         else {  // max > A[i] and min < A[i] -- so A[i] can't be max or min

              if (max < A[i+1])
                  max = A[i+1]

              if (min > A[i+1])
                  min = A[i+1] 
         }
     }
}

Thanks to Ricky Bobby for pointing out my mistakes — we can’t done find simultaneous maximum & minimum in 2*floor(n/2) running time.

  • 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-25T20:16:50+00:00Added an answer on May 25, 2026 at 8:16 pm

    Tell me if i’m wrong, but you’re not look at the case : max>A[i]>min

    if max>A[i]>min :
       if A[i+1] > max 
           max =A[i+1]
       if A[i+1] <min 
           min = A[i+1]
    

    So your algorithm is wrong in general case.

    In decreasing order or increasing order it might works, but it’s pretty useless, since for a sorted list you can find min and max with this espression :

    (min,max) = (A[0],A[n]).sort()
    

    so in O(get(A[0]) + get(A[n]))

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

Sidebar

Related Questions

I've been dipping into SitePoint book concerning CSS. The thing that struck me about
The book that I purchased to help with my SSIS understanding seems to have
I have a map in groovy that looks like the following... def book =
In the book Musical Applications of Microprocessors, the author gives the following algorithm to
I have this question in my text book: Suppose that we have a set
I recent read again the beautiful intro to recursion in the 'simply scheme' book
I'm taking an intro class on database management systems, and had a question that
Is there a book about Ruby On Rails for someone that has little or
I have the following structure: Views: Home Articles Partial Views: Book Classes Intro Faq
I am reading about NP completeness from the algorithm design book of tardos, In

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.