File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Timing Performance of a Sequential Search Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Timing Performance of a Sequential Search" Watch "Timing Performance of a Sequential Search" New topic
Author

Timing Performance of a Sequential Search

Neil Forrest
Greenhorn

Joined: Apr 03, 2005
Posts: 13
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

Joined: Dec 06, 2001
Posts: 3061
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


Java API Documentation
The Java Tutorial
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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);


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Timing Performance of a Sequential Search