In Progress

Simple Java Project

Write the class Recursion that contains the static methods isGrandpa,

getLargest, binarySearch, and sort. All must use recursion.

I. The method

public static boolean isGrandpa(String in)

returns true if the string in is Grandpa string and false

otherwise.

We define the Grandpa strings as follows:

1. ab is a Grandpa string.

2. bca is a Grandpa string.

3. If S is a Grandpa string, so is SaS.

4. If U and V are Grandpa strings, so is UbV.

Here a, b, c are constants and S,U,V are variables. In these rules,

the same letter represents the same string. So, if S = ab,

rule 3 tells us that abaab is a Grandpa string.

In rule 4, U and V represent Grandpa strings, but they may be different.

For example, the strings below are Grandpa strings.

2.1. ab

2.2. bca

2.3. bcaabca from 2.2 by rule 3

2.4. bcabab from 2.2 and 2.1 by rule 4

2.5. bcababbbcaabca from 2.4 and 2.3 by rule 4

II. The method

public static <T extends Comparable< ? super T>>

T getLargest(T [] a, int low, int high)

returns the largest item in the array slice a[low:high].

Throw an illegal argument exception if low > high.

The tree of the recursive calls must have minimal height.

Do not assume that a is sorted.

III. The method

public static <T extends Comparable< ? super T>>

int find(T [] a, T x, int low, int high)

returns an index where x occurs in the array a, or -1 if

x is not in a. Assume that a is sorted in increasing order.

Use the binary search method.

IV. The method

public static <T extends Comparable< ? super T>>

void sort(T [] a)

sorts the array a in increasing order by comparing pairs of items

in a. You can do it with 7 lines of code, including the method head,

or with 8 lines if you test if a is empty.

By a line of code I mean the header of a loop (for, while, do),

an if condition, an else, a return, an assignment, a method call,

a print, an until (condition), a break, a continue, and so on.

I do not count { and }. Do not write a merge sort or a quick sort.

You loose points if the program is too long.

Do not use tail recursion.

I've included the necessary driver to test the program.

Skills: Java

See more: grandpa string java, grandpa string, write program binary search, find java, use binary search tree, tree index, tree binary search, sorted binary tree, sort array, simple recursion example, simple recursion, simple binary tree, simple binary code, simple binary, search string array, search binary tree, search binary, recursive tree method, recursive program example, recursive binary search, recursion tree method example, recursion tree method, recursion tree example, quick sorts, points line

About the Employer:
( 9 reviews ) Immokalee, United States

Project ID: #1292914

Awarded to:

monumichael

Hi. Experience java developer here. Already done this project Regards Michael

$30 USD in 0 days
(14 Reviews)
4.2

5 freelancers are bidding on average $34 for this job

deadhunt

Please check PMB.

$50 USD in 1 day
(34 Reviews)
4.7
ranjitsinha

Ready to do it. Thanks.

$30 USD in 1 day
(78 Reviews)
4.6
vantuanvn

Hello sir, Please check my pm for details

$30 USD in 0 days
(2 Reviews)
2.0
jerrycse

Hi I can do it right now.

$30 USD in 0 days
(0 Reviews)
0.0