5. (15 pts) Find the maximum and minimum elements in a list Given a list A, the
ID: 3873607 • Letter: 5
Question
5. (15 pts) Find the maximum and minimum elements in a list Given a list A, the max function in Python's standard library computes the largest element in A: max(A). Similarly, min(A) returns the smallest element in A. Write your own max and min functions. Hint Initialize a variable max elem by the first element in the list, then visit all the remaining elements (A[1:]), compare each element to max_elem, and if greater, set max_elem equal to that element. Use a similar technique to compute the minimum element. 6. (30 pts) Simulate nested loops by handExplanation / Answer
1 Let A be an array and we are finding maximum and minimum of elements in array A. code is as below
for minimum:-
2. maximum function code:-
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.