You must not use any of the following: dictionaries or dictionary methods try-except break and continue statements recursion map / filter any type of sorting function for second_largest int:II II...


You must
not
use any of the following:





  • dictionaries or dictionary methods


  • try-except


  • break and continue
    statements


  • recursion


  • map / filter


  • any type of sorting function
    for second_largest


def second_largest(lst: List[int]) -> int:<br>II II II<br>Given a list <lst> of integers, return the second largest item in the list<br>without modifying <lst>. You cannot use any of python's builtin sorting<br>functions. Do not attempt to sort the list yourself either.<br>As a sanity check, you can ensure that your function returns what<br>
and return the nth largest number in the list? Can you do this without sorting the list? pass "/>
Extracted text: def second_largest(lst: List[int]) -> int: II II II Given a list of integers, return the second largest item in the list without modifying . You cannot use any of python's builtin sorting functions. Do not attempt to sort the list yourself either. As a sanity check, you can ensure that your function returns what "return sorted (lst)[-2]" would. (DO NOT COPY THIS) For example, an input [1, 2, 3] should return an output of 2, since 2 is the second largest integer in the list. Note that when we say second largest, we do not mean second largest distinct element. That means that [1, 2, 4, 4] should return 4, not 2. Precondition: the input list has at least 2 elements. Something extra to think about (not graded): is it possible to write this function with an extra argument and return the nth largest number in the list? Can you do this without sorting the list? pass
LAB RESTRICTIONS, PLEASE READ:<br>Do not add any imports, the ones that you need will be given to you.<br>You may not use any dictionaries or dictionary methods.<br>Do not use try-except statements, you should be able to anticipate<br>or prevent any errors from happening at all!<br>from typing import Any, List<br>

Extracted text: LAB RESTRICTIONS, PLEASE READ: Do not add any imports, the ones that you need will be given to you. You may not use any dictionaries or dictionary methods. Do not use try-except statements, you should be able to anticipate or prevent any errors from happening at all! from typing import Any, List
Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here