top of page
PROGRAMMING CHALLENGES
Recursive Sum to Iterative
Difficulty:
2 Medium
2.5 Recursion
Topic:
Convert the following recursive pseudocode that sums the numbers in an array into an iterative version.
Recursion often replaces loops with function calls. Consider how you can use a for or while loop to sum the array elements iteratively.
FUNCTION sumArray(array, n) IF n == 0 RETURN 0 ELSE RETURN array[n-1] + sumArray(array, n-1) ENDFUNCTION
Need help with your programming skills?
If you need more help than just independent practise, then we're here for you. Book a 1:1 with us and we will be able to guide you to becoming a proficient programmer who can tackle any of the challenges an exam board can throw at you.
1 hr
40 British pounds1 hr
50 British pounds
bottom of page