Advertisement
Guest User

binary search

a guest
May 22nd, 2019
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. /*
  2. The binarySearch method performs a binary search
  3. on a random access binary file of short values.
  4. randomAccessFile file pointer to search.
  5. first - The first element in the search range.
  6. last - The last element in the search range.
  7. value - The value to search for.
  8. Return The subscript of the value if found, otherwise -1.
  9. */
  10. // imports
  11. /**
  12. *
  13. * author
  14. * date
  15. *
  16. */
  17. public class BinaryRecursiveSearch {
  18. public static long binarySearch(
  19. RandomAccessFile randomAccessFile, long first, long last,
  20. short value, int callNumber) throws IOException {
  21. // Mid point of search
  22. // Test for the base case where the
  23. // value is not found.
  24. // Calculate the middle position.
  25. // change notation
  26. // convert from byte poisition to two byte short access
  27. // go to that position
  28. // Get that data
  29. // Search for the value.
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement