1- Write a Java method (element_frequency) that determines how many times an element x is repeated in an array.
Example:
Let a is an integer array where a = { 1, 4 ,3,2,6,3,2,7,5,2,3}
The method element_frequency (a,2) will return value 3 where the element 2 is repeated three times in the array a.
2- Write a Java method (find_pattern) that determines if certain pattern b is existed in an array.
Example :
Let a is an integer array where a = { 1, 4 ,3,2,6,3,2,7,5,2,3}, and let pattern b is an integer array where b={ 6,3,2}
The method find_pattern (a,b) will return true where the pattern b is existed in the array a.
If pattern c is an integer array where c={ 9,3,2} then the method find_pattern (a,c) will return false where the pattern c is not existed in the array a.
3- Write a Java application for simple ticket reservation in the train. The seats in the train are classified into three categories, first class, business class, and economy class. Consider that the train capacity is 30 seats (5 seats for first class, 5 seats for business class, and 20 for economy class). The passenger can only choose among available seats. Your application will print out the boarding ticket that contains the name of the passenger, seat number, and the class of the trip.
4- Using recursion, write Java method reverse_array.
5- Using recursion, find the value of f(9) given:
f(0)=1, f(1)=3
f(n) = 3f(n-1)*f(n-2)+1, where n is Natural number
WhatsApp us