subject

Uluthando needs your help to plant some trees. He can give you three parameters of the land: - width of the land w
- length of the land l
- gap between the trees g
You have to create an algorithm to return the number of trees which can be planted on the edges of the given land in a symmetrical layout shown below (unsymmetrical gap = x, tree = o, gap = -):

w=3, l=3, g=1
plantTrees(w, l, g) ➞ 4

o - o
- -
o - o

// Uluthando can plant 4 trees.
w=3, l=3, g=3
plantTrees(w, l, g) ➞ 2

o - -
- -
- - o

// Uluthando can plant 2 trees.
If the layout is not symmetrical, you have to return 0:

w=3, l=3, g=2
plantTrees(w, l, g) ➞ 0

o - -
x o
x x x

// Planting 2 trees mean the gap of two trees will be greater than 2.

o - -
x o
o - -

// Planting 3 trees mean the gap of two trees will be less than 2.
Another Example for better understanding:

w=3, l=3, g=0
plantTrees(w, l, g) ➞ 8

o o o
o o
o o o

// Uluthando can plant 8 trees.
(10 Points)

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:30
How can a user open a blank presentation? 1.on the file menu, click new, and then click recent templates 2.on the file menu, click new, and then click blank presentation 3. on the view menu, click templates, and then click recent templates 4. on the view menu, click samples, and then click blank presentation
Answers: 1
question
Computers and Technology, 24.06.2019 10:30
This device directs network traffic. bridge hub nic repeater router switch
Answers: 3
question
Computers and Technology, 24.06.2019 13:20
3. ranga ramasesh is the operations manager for a firm that is trying to decide which one of four countries it should research for possible outsourcing providers. the first step is to select a country based on cultural risk factors, which are critical to eventual business success with the provider. ranga has reviewed outsourcing provider directories and found that the four countries in the table that follows have an ample number of providers from which they can choose. to aid in the country selection step, he has enlisted the aid of a cultural expert, john wang, who has provided ratings of the various criteria in the table. the resulting ratings are on a 1 to 10 scale, where 1 is a low risk and 10 is a high risk. john has also determined six criteria weightins: trust, with a weight of 0.3; quality, with 0.2; religious, with 0.1; individualism, with 0.2; time, with 0.1; and uncertainity, with 0.1. using the factor-rating method, which country should ranga select? why? (2 points)
Answers: 3
question
Computers and Technology, 24.06.2019 14:00
Fast answer i need for apex ! smartphones should be banned from the classroom in public schools so that students cannot cheat on test so easily? which is an example of a counter argument to the thesis above? a.the classroom is a place for learning not for making phone calls b. smartphones are useful learning tools in the modern classroom c.banning smartphones will not students pay attention to teachers any better d. banning smartphones would decreased incidents of theft
Answers: 2
You know the right answer?
Uluthando needs your help to plant some trees. He can give you three parameters of the land: - widt...
Questions
Questions on the website: 13722361