Singular Value Decomposition

Linear Algebra

Difficulty: 1 | Problem written by Mr. Umair

Educational Resource: https://towardsdatascience.com/understanding-singular-value-decomposition-and-its-application-in-data-science-388a54be95d

Problem reported in interviews at


Given a 2D NumPy array, your function will perform Singular Value Decomposition (SVD):

\( {\displaystyle \mathbf {M} =\mathbf {U\Sigma V^{*}} }\)  

Your function will return three values U, s (sigma), and V in a list with 3 elements.


Sample Input:
<class 'list'>
arr: [array([8, 8, 3, 7, 7, 0, 4]), array([2, 5, 2, 2, 2, 1, 0])]

Expected Output:
<class 'list'>
[array([[-0.93747507, -0.34805244], [-0.34805244, 0.93747507]]), array([16.86457596, 2.93020094]), array([[-0.48598349, -0.54789772, -0.2080414 , -0.43039507, -0.43039507, -0.02063808, -0.22235366], [-0.31037781, 0.64942845, 0.2835276 , -0.19159673, -0.19159673, 0.31993542, -0.47512432]])]

This is a premium problem, to view more details of this problem please sign up for MLPro Premium. MLPro premium offers access to actual machine learning and data science interview questions and coding challenges commonly asked at tech companies all over the world

MLPro Premium also allows you to access all our high quality MCQs which are not available on the free tier.

Not able to solve a problem? MLPro premium brings you access to solutions for all problems available on MLPro

Get access to Premium only exclusive educational content available to only Premium users.

Have an issue, the MLPro support team is available 24X7 to Premium users.

This is a premium feature.
To access this and other such features, click on upgrade below.

Log in to post a comment


Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)