Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Timing Performance of a Sequential Search

 
Neil Forrest
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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 ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • 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
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic