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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:58:04+00:00 2026-06-17T00:58:04+00:00

I have an Array (linear field) with pre sorted numbers [1, 2, 3, 4,

  • 0

I have an Array (linear field)
with pre sorted numbers

 [1, 2, 3, 4, 5, 6],

but these arra y is shift to the right (k times),

now its

[5,6,1,2,3,4], k = 2

But I don´t know k. Only the array A.

Now I need an Algorithm to find the max in A (with runtime O(logn))

I think its something with binary search, can anyone help me??

  • 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-17T00:58:05+00:00Added an answer on June 17, 2026 at 12:58 am

    The question can be re-stated in terms of finding the “point of discontinuity”, i.e the index of the 6, 1 spot in the array. You can do it iteratively using an approach similar to that of a binary search, like this:

    Take an array A and two indexes, low and high, initially set to 0 and A.Length-1. The spot of discontinuity is between low and high.

    Divide (low, high) in half. Call the midpoint mid. Compare A[low] to A[mid] and A[mid] to A[high]. If only one pair is ordered correctly, adjust the endpoint: if it’s the low-mid pair that’s ordered, assign low = mid, otherwise assign high = mid. If both intervals are ordered, the answer is A[high].

    This runs in O(LogN) because each step reduces the size of the problem in half.

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

Sidebar

Related Questions

I have an array of sorted numbers: pts = [ 0, 4, 25, 51,
I have a randomly ordered C array of integer numbers. Each of these numbers
I have Fortran-based 3D column-major order array flattened into linear memory. What formula/algorithm can
I have myself a linear grid of Vector2s stored in a Vector2[,] array, and
I've got an array of n elements. Those elements are numbers. What I have
We have two unsorted arrays and each array has a length of n. These
I have an array of numbers , say nums[n] . I have to find
Using ActionScript 3, suppose I have an array of numbers, lets say: 1, 2,
d3js experts I have these array var dados = [ [Brasil, 20], [Canada, 31],
I have a linear byte array whose values I want to set as pixels

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.