Comp3521   Assignment 1 – Binary-Search Solved

25.00 $

Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment


5/5 - (1 vote)

Submit source code and running instructions to EAS[1]. Submit the textual component as a block comment at the top of your code. Do it in Java. Do not use java’s search methods! Place textual responses for 2 and 3 in block comments in your code.

Grade: 5%

  1. You have the following array 1,5,17,22,33,37, known to be sorted. Write a program that demonstrates a Θ(log(n)) time or better (in the average case) algorithm to determine if the value 5 is in that array.
    • Make sure your program allows as input on the command-line a comma-separated (free of spaces) list of integers (the above being just an example).
    • As output to stdout, each step along the way, on a single line, indicate what value you checked, followed by the symbol <, > or =. e.g. The last line for this example would be “5=” (without the quotes)
    • If the searched for value is not found, the last line should simply be a “!” (without the quotes)
  2. In clear, natural language, give the name of your algorithm and explain in a generalized step-wise manner how it can be applied to an arbitrary array when searching for an arbitrary value.
    • This textual response should be no more than 5 lines / 50 words.
  3. In clear, natural language, describe how you would change your algorithm to search over Strings instead of integers.
    • This textual response should be no more than 4 lines / 40 words.