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 javas search methods! Place textual responses for 2 and 3 in block comments in your code.
Grade: 5%
- 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)
- 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.
- 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.
1
[1] https://fis.encs.concordia.ca/eas/
Reviews
There are no reviews yet.