• 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

Searching Linked List

 
Greenhorn
Posts: 22
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok here I have a code that generates 1 million random values then converts them to a string then hashcode. I then insert into a linked list and then I want to run through each hash and find it in the linked list timing each run then averaging out the time at the end.

It works great for smaller amounts of numbers it is searching for (fine under 50 thousand searches for the for loop starting at line 24 LinkedListTest.java) but when I try to do the full million searches it gives me "a Exception in thread "main" java.lang.StackOverflowError" at line 158 in List.java. Maybe im getting tired but I cannot figure out why.





 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

paul spriesterbach wrote:Ok here I have a code that generates 1 million random values then converts them to a string then hashcode. I then insert into a linked list and then I want to run through each hash and find it in the linked list timing each run then averaging out the time at the end.

It works great for smaller amounts of numbers it is searching for (fine under 50 thousand searches for the for loop starting at line 24 LinkedListTest.java) but when I try to do the full million searches it gives me "a Exception in thread "main" java.lang.StackOverflowError" at line 158 in List.java. Maybe im getting tired but I cannot figure out why.



The most common cause of a stack overflow is a recursive algorithm that made too many recursive calls.... which is likely the case here, as the search method is indeed recursive.

Henry
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic