Feedback on two Data Structures courses

Hi there,

I just wanted to submit a feedback in relation to JavaScript Algorithms and Data Structures module.

I found two steps from two courses in " Learn Functional Programming by Building a Spreadsheet " and " Learn Advanced Array Methods by Building a Statistics Calculator " referencing how to calculate median of numbers list, with what I think in one occurrence incorrect method being used and please let me know if I misunderstood anything.

In step 28, line 8 it uses Math.floor and following course, in step 26 line 11 uses Math.ceil. From what I know, to calculate median in odd condition, you would need to round up in order to get the middle number, i.e. Math.floor usage seems to be incorrect and had to be Math.ceil to get the correct median value?

I know it’s beta course but not sure if I spotted any typos and hopefully my feedback comes helpful.

With thanks for all your efforts and work to put up this module.

Zakaria.

I had trouble finding which step of which project you mean, but I think I did.

so, let’s consider a case:
in an array of 7 numbers the indeces would be
0, 1, 2, 3, 4, 5, 6
So the middle element is at index 3. To get 3 you need to do Math.floor(array.length / 2) as half of 7 is 3.5


For the the spradsheet project, notice that the value that is rounded up comes from length / 2 - 1
in that case it would be 3.5 - 1 so 2.5, which then is rounded up to 3.
So even if it’s a more roundabout way, it’s still correct

1 Like

Yes, you did find the correct steps, but now I understood why floor was used as oppose ceil, I just didn’t take into account the minus 1 in the spreadsheet project.

Anyways, it turns out this is one of my invalid feedbacks, I do apologise if it caused any inconvenience, and you can delete my post or tweak title to maybe something like “Enquiry”.

Thanks for clarifying this point.

if you wish to change the title of this feel free to do so

1 Like