Practice problems for the labs March 3-8.
Note: This is a set of problems that will help you in preparing for the lab next week. However, the lab assignment are not going to be identical to these problems.
- Write a procedure that takes a list and returns the first half of the list. If the list has an odd number (say 2k+1) of elements, the list reurned should have k elements.
- Write a procedure that takes in a list L and a number x and returns the
number of occurrences of x in L. Do not use any Maple commands not covered in class.
- Write a procedure that takes in a list and finds the minimum element in it. Do not use the min command in Maple.
- Write a procedure that takes a list L and an integer n and returns another list that is formed by deleting all elements in L that are less than or equal to n.
The other elements should not be modified or rearranged.
Do not use any Maple commands not covered in class.
- Write a procedure that takes a list L[1..n] and returns a list M[1..n] such that M[i] = sum(L[1..i]). Do not use any commands not co vered in class.
- Write a procedure that takes a list L[1..n] of positive or nrgative integers, and returns the index i such that L[1..i] has the largest sum of all lists L[1..j], 1 <=j<=n. Do not use any commands not covered in class.
- It can be shown that the value of exp(x) is given by the sum of an infinite series
whose nth term is x^n/n!, and n=0,1,.... Write a procedure that takes as input a real number x and an integer i and returns the sum of the series for the first i+1 terms (i.e. n=0..i).