1 1 vote CONSIDER the following Python snippet:data = [1, 2, 3, 4, 5] result = list(map(lambda x: x**2 if x % 2 == 0 else x**3, data))WHAT is the final value of the list $\verb|result|$, and what is the asymptotic time complexity of this entire operation in terms of $N$ (the number of elements in $\verb|data|$)? $[1,4,27,16,125], \mathrm{O}\left(\mathrm{N}^2\right)$ $[1,4,27,16,125], \mathrm{O}(\mathrm{N})$ $[1,8,9,64,25], \mathrm{O}(\mathrm{N} \log \mathrm{N})$ $[1,4,9,16,25], \mathrm{O}(\mathrm{N})$ Programming in Python goclasses python-&-dsa goclasses-da-dpp goclasses-da-dpp-day-72 goclasses-python-&-dsa-practice-questions + – GO Classes 267 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
2 2 votes LIST CALCULATION: The 'map' function applies the 'lambda' function to every element in 'data' $([1,2,3,4,5]).$$\mathrm{x}=1$ : Odd $\rightarrow 1^3=1$ $\mathrm{x}=2$ : Even $\rightarrow 2^2=4$ $\mathrm{x}=3$ : Odd $\rightarrow 3^3=27$ $\mathrm{x}=4$ : Even $\rightarrow 4^2=16$ $\mathrm{x}=5$ : Odd $\rightarrow 5^3=125$ The resulting list is $[1,4,27,16,125]$.The overall time complexity is determined by the number of iterations multiplied by the complexity of the operation inside the loop: $N \times \mathrm{O}(1)=\mathrm{O}(N)$. This is linear time complexity. GO Classes answered Dec 22, 2025 GO Classes comment Share Follow 0 reply Please log in or register to add a comment.