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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:33:28+00:00 2026-05-13T11:33:28+00:00

My professor gave us an assignment to test the difference in runtimes and search

  • 0

My professor gave us an assignment to test the difference in runtimes and search sizes using linear & binary algorithms, and the data is to be graphed.

I have the search methods put the runtime & array sizes as Points in an ArrayList, which is then sent to the GraphResults class for plotting. I need to convert those data points into xy coordinates before. The search size is the x-axis and the runtime is the y axis

As the search sizes are fixed as a multiple of 128 and there are only 8 sizes, I used switch for calculating the x value, but am looking for a more efficient way to convert the runtimes into coordinates.

Right now, I’m using nested conditionals with 5 like this:

if (y<=1000) {
    if (y<= 500) { 
        if (y<= 250) {
            newy= yaxis-32; }//equals to 250ms category
        else {
            newy= yaxis-(32*2); }//500ms category
   } 
else if (y<=750) {
    newy= yaxis-(32*3);} //750ms category
else {
    newy= yaxis-(32*4);} //1000ms category
} //end of the 1000ms tests

Right now, the numbers that are over 5000ms require 7 tests. Is there a more efficient way to assign a number based on a number size?

  • 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-13T11:33:28+00:00Added an answer on May 13, 2026 at 11:33 am

    As you are trying to determine the range of your measurement, you can divide the amount by the range size, followed by calculating the number you want to show in the graph.

    Btw, in your code, you made a logic error, if the value is y <= 1000 the first condition evaluates to true, and the second for y <= 750 will never be evaluated.

    Also it seems that the higher the value range, the lower your graph point. Is that as intended? (1000 -> ymax – 128 while 1 -> ymax – 32)

    As an aside, if you want to compare values to uneven ranges, you can also do something like an array lookup (pseudo code):

    int[] ranges = new int { 50, 500, 5000, 50000 };
    
    for (int n = 0; n < ranges.length && value > ranges[n]; n++) {
    }
    
    int range = n;
    int newy = yaxis - range * 32;
    

    Note that the out-of-range index acts as the range found for a value that is bigger than the biggest value in your array.

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

Sidebar

Related Questions

In preparation for the data structures midterm, the professor gave us last year's test,
Our professor gave us this assignment, where we have a .txt file with the
My professor gave my class an assignment today based on object oriented programming in
My professor recently gave my class an assignment and I need help finding the
I am doing an assignment for an information systems class and the professor decided
I'm working on some imaging applications from a book my professor gave me. The
My professor gave an example located on slide 3 of this pdf : can
I'm a student of computer science in Germany. My professor gave use the following
Our professor required us to check if a word is a palindrome by using
My professor is teaching us Scala using Horstmann's book Scala for the impatient, and

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.