aspose file tools
The moose likes Beginning Java and the fly likes [Solved] bubbleSorting + binary searching from methods . Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "[Solved] bubbleSorting + binary searching from methods ." Watch "[Solved] bubbleSorting + binary searching from methods ." New topic
Author

[Solved] bubbleSorting + binary searching from methods .

Omar Perez
Ranch Hand

Joined: Jul 08, 2011
Posts: 35
Thank you all folks for all the solutions and proposals, really appreciated.

This the code (done in three classes).

First the bubble sort code an Algorithm for sorting values, in this from min to max;


The bubble code was for a binary search, this is the code for binary search (iterative way);



No you guys are in charge of working the main class. Thank you all for your collaboration.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3053
    
    1

Hi Omar,

I haven't looked at your code very carefully, but it looks like you're doing something dangerous on line 43: maybe you should use the == operator instead of the = operator.
Omar Perez
Ranch Hand

Joined: Jul 08, 2011
Posts: 35
Stephan van Hulst wrote:Hi Omar,

I haven't looked at your code very carefully, but it looks like you're doing something dangerous on line 43: maybe you should use the == operator instead of the = operator.


fixed, I got the exception fixed, now having issues with method not returning all values sorted.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

I do argue you to see Bubble_sort, then your program
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9955
    
    6

it is returning one number because you are telling it to:

return array[9];

says "return the element of the array at index position 9" and NOT "return an array with 9 elements".


Never ascribe to malice that which can be adequately explained by stupidity.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 5893
    
    6

Omar Perez wrote:
Stephan van Hulst wrote:Hi Omar,

I haven't looked at your code very carefully, but it looks like you're doing something dangerous on line 43: maybe you should use the == operator instead of the = operator.


fixed, I got the exception fixed, now having issues with method not returning all values sorted.


Better yet get rid of the == altogether.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [Solved] bubbleSorting + binary searching from methods .
 
Similar Threads
incompatable types.
String Input and Bubble Sort
How to print value and the number of times it appear in a array?
Searching an array - output problems - Please help!!
Data in java please somebody help.