• 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

Putting Ints into an Object array.

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm writing a program to compare the effiecency between heapsort and bubblesort. We were givin the code for both of the sorts and have to use them. The only problem is the code contains Object arrays and I'm not sure how to put integers (we have to make the arrays for testing) into the Object array coding. I created the integer arrays by using a simple for loop with a random number generator which works fine. Any help to tell me how to put ints into Object arrays would be appreciated. Here is the heapsort algorithm we were given that we have to use:



Here is how I am creating my random integer array:

 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Integer objects would fit the bill...
 
Adam Ellsworth
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, just figured that out, hehe. But now the algorithm he gave us isnt doin much

here's the code he gave us. I'm sure i'm doing something wrong opposed to his code being wrong.

 
Jeff Bosch
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest starting with adding some debug print statements so you can compare what you think the program should be doing at several points compared to what the program really is doing at those points. For example, where the code is assigning a value, for example:


You could add a print statement to see what really is being assigned to temp:


[ February 09, 2005: Message edited by: Jeff Bosch ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic