Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Search algorithm

 
Gennady Shapiro
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the marking criteria of this assignment is the search algorithm. Since our DB is not relation and our records are not indexed in any way what kind of search can we do except a simple linear search??
I mean every record has to be tested for matching values every time, which give us O(n) time. I don't really see how this can be improved.
Anyone?
 
Eru Stone
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also already thought about that. Maybe an index could be created in Memory as soon as it is needed. Of course this gives us a memory consumption of O(n). But since we are not allowed to alter the DB, this would be the only possibility to speed it up!?
But having an index in memory means also to take care of it's contents during inserts, updates and deletes....
 
Ian B Anderson
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to add another thought, in Sun's requirements they state that:
"a simple design that can be readily understood by junior programmers would be preferred over a complex design even if that design is more efficient."
Maybe just a sequential search would be better.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!