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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:24:04+00:00 2026-06-18T12:24:04+00:00

Continued from my last two questions, Range Minimum Query approach (from tree to restricted

  • 0

Continued from my last two questions, “Range Minimum Query approach (from tree to restricted RMQ)” and “Range Minimum Query approach (Last steps)“

I followed this tutorial on TopCoder, and the approach is introduced in the last section.

Now assuming I have everything done, and I am ready for query. According to the tutorial, this is what I should do:

i and j are in the same block, so we use the value computed in P and T

For example, if there’s a block like this:

000111

The minimum value lies of course in the third 0, but if i and j are like 4 and 6, the third 0 won’t lie in the queried criteria. Is my understanding wrong?

i and j are in different blocks, so we compute three values: the
minimum from i to the end of i’s block using P and T, the minimum of
all blocks between i’s and j’s block using precomputed queries on A’
and the minimum from the begining of j’s block to j, again using T and
P; finally return the position where the overall minimum is using the
three values you just computed.

Why compute the minimum from i to end of i’s block and the minimum of start of j’s block to j? Don’t the answer of both lies outside of i…j? Also, how to do that if it’s not entirely a fit just like the last question.

  • 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-18T12:24:06+00:00Added an answer on June 18, 2026 at 12:24 pm

    The minimum value lies of course in the third 0, but if i and j are like 4 and 6, the third 0 won’t lie in the queried criteria. Is my understanding wrong?

    The idea is to precompute the RMQ for all pairs of indices in every possible block. As a result, regardless of what indices you query within that block, you should always be able, in O(1) time, to read off the RMQ of the two values within the block. In the case you listed in your question, the fact that indices 4 and 6 don’t contain the block minimum is true but irrelevant. You’ll already have the RMQ precomputed for indices 4 and 6.

    Why compute the minimum from i to end of i’s block and the minimum of start of j’s block to j? Don’t the answer of both lies outside of i…j? Also, how to do that if it’s not entirely a fit just like the last question.

    Consider this picture:

    +------+------+------+------+------+------+
    | ?i?? | ???? | ???? | ???? | ??j? | ???? |
    +------+------+------+------+------+------+
       ^                            ^
       i                            j
    

    If you want to solve RMQ(i, j), then the minimum could be in one of three places:

    • In the same block as i, at an index from the position of i within its block to the end of its block,
    • In the same block as j, at an index from 0 to the position of j within its block, or
    • Somewhere in one of the middle three blocks.

    The algorithm works by using the precomputed tables to solve the problem in the first two cases, then using the other algorithm to solve it for the third case. The minimum of these three should be your answer.

    Hope this helps! This is by no means an easy algorithm, so please feel free to ask more questions here if you need help!

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

Sidebar

Related Questions

Continued from the last question here: Log method name in Obj-C . I just
This is a continued question from: Android: How to interact with the default Contacts
I've been trying for the last two days to get this to work with
This continues from a previous question . I tried the suggested fix to check
I have been researching this for a while but got no convinced answer. From
I've spent two days on this and I still can't find the cause of
I am using eclipse 3.6 Helios version.I am working on it from last three
I am trying to make two lines appear in a graph according to this
From PDB (Pdb) help l l(ist) [first [,last]] List source code for the current
I had an fql query in my code that up until last week (or

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.