Java binary search help
Go to solution
Solved by auraofjason,
A double is a floating point number (like 1.1234) while an int is just a whole number (like 1).
You can keep mid and SIZE as doubles, but when you iterate with them you can cast them into ints like: (int)mid. So for example in this line instead of: if (a[mid]>x), you can do: if (a[(int)mid]>x).
-
Featured Topics
-
Topics
-
7
-
doctorshyler ·
Posted in Graphics Cards3 -
1
-
7
-
2
-
0
-
1
-
9
-
ChaseB ·
Posted in General Discussion5 -
0
-
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now