Is it just me or is there an issue with the solution provided for Question 2 Assignment 1.
The recursive function getNoMails returns the incorrect value. As far as I can see the issue lies with the findChildren function because it doesn't just return the current objects child objects but also the child object's child objects and so on and so.
So there is actually no need to have a recursive function???
It should be possible to count the total number of mails in a mail folder and in a mail. The
total number of mails in a mail folder includes all its mails including its sub mail folders. Of
course, the total number of mails in a mail is 1.
So if you have nested folders a(1), contains b(2), contains c(3) where the number in brackets indicates the number of mails, i.e. leaf nodes in that folder,
Then the counts would be as follows:
* a = 1 + 2 + 3 = 6
* b = 2 + 3 = 5
* c = 3
The problem is in all the examples they use findChildren recursively, but it already returns all the child items recursively which produces incorrect results.
So with crowns example above it will return 6 + 5 + 3 = 14 for a and not 6