• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Timing Performance of a Sequential Search

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm new to Java. My mission is to implement a sequential search and time the performance with an array size=10^i, i=1,2,3,4,5,6. The command line has to take 2 arguments: size and number of searches. My code is below. Any suggestions in making this mess actually work?
Thanks...



[added code tags - Ilja]
[ April 04, 2005: Message edited by: Ilja Preuss ]
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what isn't working? Does the above code compile? If not, what are the errors? If it does compile, how does the behavior differ from what you expect?

If you can post some details about the exact problem, we will be more than happy to help. Also, this will help you analyze the problem for yourself so you might not need our help as much.

As a hint, check to see if your program create a different size array each time.

Layne
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Neil,

Welcome to JavaRanch!

To what Layne writes, I'll add the tidbit that Java doesn't have an exponent operator. To raise a number to a power, you can use the static pow() method in the java.lang.Math class:

size = (int) Math.pow(10, i);
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic