• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with finding the lowest value in an array using a linear search  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am attempting to find the element that holds the lowest time ( i have used System.currentMillisTime ) in the array using a linear search and to then print the times held by the array in lowest to highest order . While i understand how to do a linear search using user input as the key i am not to sure how to do it by initializing a search key in the program to the lowest number and have little experience in using a search in a program that is not a simply linear search. i have attempted to code this, as seen below, but i know i am definitely wrong and i have tried another of different ways even Array.sort and then a binary search .
Any suggestion would be greatly appreciated.




 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gail belfast wrote:I am attempting to find the element that holds the lowest time ( i have used System.currentMillisTime ) in the array using a linear search and to then print the times held by the array in lowest to highest order . While i understand how to do a linear search using user input as the key i am not to sure how to do it by initializing a search key in the program to the lowest number and have little experience in using a search in a program that is not a simply linear search. i have attempted to code this, as seen below, but i know i am definitely wrong and i have tried another of different ways even Array.sort and then a binary search .
Any suggestion would be greatly appreciated.

1. If you know how to do it using user input, then you know how to do it using input (or a variable) from the program.

2. StopCoding (←click) and think about what you're doing.

Suppose I handed you a shuffled deck of cards with numbers on them, how would you hand me the lowest numbered card in that deck? What would you have to do? - write out every step.

Programming is not magic, it requires you to understand the problem; and that doesn't come from code, it comes from your brain.

Winston
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!