Professional Documents
Culture Documents
Lab 03
Lab 03
LAB: 03
General notes:
● Each exercise is a separate project and should be saved in a
different folder. The name of the folder is the exercise number.
● Write your name, ID, and PC number as a comment on the main
class.
● Zip your folders into one folder and upload your answer to the
blackboard before the end of the class. Late submission is
considered absent.
Recursion
Exercise 1:
Output:
The given array: [43,54,87,12,6,93]
Minimum value in array is : 6
Exercise 2:
Reverse String
Write a method with name ReversString which reverse a string using recursion.
(This done by starting from the last character in the string then recursively print each
character until all the characters in the string are exhausted).
Example : String "Data" becomes "atad"
Binary Search
Exercise 1:
given a sorted array of n elements, search for given key element using binary
search algorithm.
Output sample:
The given array: [4,6,12,16,22]
Element 16 is found at index 3
Exercise 2:
Write a Java program which finds the number of occurrences of an
element x in a sorted array A using binary search.
A. Write a class Student which contains the following data and methods
Data:
• Name (string)
• ID (integer)
• Level (integer)
• GPA (double)
Methods:
• Get and set for each data item
• Print all students