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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:00:52+00:00 2026-06-08T13:00:52+00:00

If there is a test, where a delta needs to be added to a

  • 0

If there is a test, where a delta needs to be added to a particular value, the delta can be tested in this sequence: 1, 2, 3, … 15, 16.

But to test with finer and finer granularity, delta can be this sequence: 1, 16, 8, 4, 12, … (that is, we try 1, and 16, which are two extreme cases, and then we try 8, which is a middle number, and then 4, which is middle of 1 and 8, and then 12, which is middle of 8 and 16).

How can this sequence be generated elegantly without duplicates?

Right now I have this in Ruby 1.9.3:

$deltas = []

def getMidPoint(a, b)
  return if (a - b).abs <= 1

  midPoint = ((a + b) / 2).to_i
  puts "a = #{a}, b = #{b}, midPoint = #{midPoint}"

  $deltas << midPoint
  getMidPoint(a, midPoint)
  getMidPoint(midPoint, b)
end

$deltas << 1
$deltas << 16
getMidPoint(1, 16)

p $deltas

but the result is:

[1, 16, 8, 4, 2, 3, 6, 5, 7, 12, 10, 9, 11, 14, 13, 15]

I can actually add a “level” to the number (stored as a tuple): so for 8, it is level 2, and for 12, it is also level 2 (the level is the recursion level), and then at the end, I can collect the numbers with level 1, and then level 2, etc, to get the final array, and it should work, but is there a better solution?

  • 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-08T13:00:53+00:00Added an answer on June 8, 2026 at 1:00 pm

    The problem with your algorithm is that it will runthrough the entire “left side” before going to the “right side”, because the getMidPoint(a, midPoint) will cause many recursions before getMidPoint(midPoint, b) executes.

    One possible solution is to use a queue. Enqueue the calls instead of calling both functions directly and always call the first element in the queue.

    So in the first step you would output 8 and have the queue <1,8>, <8,16> and you would call <1,8>, outputing 4. Next you would have <8,16><1,4><4,8> and you would call <8,16> and output 12 and have the queue <1,4><4,8><8,12><12,16> and so on.

    I think it is a better approximation to your needs.

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

Sidebar

Related Questions

Is there any test framework or software that can automatically go through a site
How does one test an architecture? Are there test-related things that can be done
Is there any test macro that can be used to see if the code
Is there a way I can test if there are any other activities in
Is there a Test Stripper (as defined in xUnit Test Patterns ) available that
Where can I test HTML 5 functionality today - is there any test build
Greetings, Is there was test or a predicate I can use in prolog to
Is there a test suite out there that checks whether a Fortran compiler fully
Is there any test-data generation framework out there, specially for Python? To make it
In my test-system there is no problem searching for items within specific sites, using

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.