Write a Python function: def second (A) which takes as input an array A of integers and returns the second smallest element of A. If A has less than two elements, the function should return None. The...


Write a Python function:<br>def second (A)<br>which takes as input an array A of integers and returns the second smallest element of A.<br>If A has less than two elements, the function should return None. The array A should not<br>be changed. You can assume all elements of A are different.<br>, your solution should be efficient and run in linear time.<br>For example, second ([1,-5,3,4]) should return 1. On the other hand, second([1])<br>should return None.<br>

Extracted text: Write a Python function: def second (A) which takes as input an array A of integers and returns the second smallest element of A. If A has less than two elements, the function should return None. The array A should not be changed. You can assume all elements of A are different. , your solution should be efficient and run in linear time. For example, second ([1,-5,3,4]) should return 1. On the other hand, second([1]) should return None.

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here