Question: ( 1 0 points ) Write an algorithm in pseudocode that takes as input a number M and a nonempty list a 1 a 2
points Write an algorithm in pseudocode that takes as input a number M and a nonempty list a a an of numbers, and adds up all the numbers in the list up to but not including the rst number in the list larger than M If every element of the list is less than M it should return the sum of the entire list. If the rst element of the list is greater than M then it should return Example : if M and the list is then it should return since We stop adding up the list when we get to the since Remember we do not add the Just all the numbers before the Example : M and list is It should return since and Here is a precise de nition. The input is a number M and a nonempty list a a an If every element of the list is less than M it should return the sum of the entire list. If the rst element of the list is greater than M then it should return Otherwise suppose ai is the rst element of the the list such that ai M In this case it should return aaaai Example : M and the list is It should return since Example : M and the list is It should return since the rst element is larger than
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
