submissions:assesment:52960:assement2
MPP - Assignment 2 (15%)
Tasks
For each of the following write a functional, recursive, function in Python to accomplish the task. Marks will be award for correct solutions and for comments explaining how the function works.
- Sum of an array Given an array of numbers return it’s sum (all the numbers added together).
- Product of an array Given an array of numbers return it’s product (all the numbers multiplied together).
- Remove all odd numbers Given an array of numbers return an array with all the odd numbers removed.
- Remove all even numbers Given an array of numbers return an array with all the even numbers removed.
- Replace a given character with ’*’ Given a string, and a character to replace, return a string where each occurance of the character is replaced with ’*’.
- Find index in array for item. Given an array, and an element to search for return the index of the element in the array or -1 if the element is not present in the array.
- Sum of Digits Given a whole, number such as 23, return the sum of the digits in the number i.e. 2 + 3 = 5. For this would be useful to convert the number to a string then break it apart into digits.
- Print an array Given an array of integers prints all the elements one per line. This is a little bit different as there is no need for a ’return’ statement just to print and recurse.
- Find the minimum element in an array of integers. You can carry some extra information through method arguments such as minimum value.
- Verify the parentheses Given a string, return true if it is a nesting of zero or more pairs of parenthesis, like “(())” or “((()))”.
- https://www.geeksforgeeks.org/sum-of-even-elements-of-an-array-using-recursion/ - basic framework, more work required.
- https://www.geeksforgeeks.org/sum-of-even-elements-of-an-array-using-recursion/ - basic framework, more work required
submissions/assesment/52960/assement2.txt · Last modified: 2020/06/20 14:39 by 127.0.0.1