logo CodeStepByStep logo

Mystery1

Language/Type: VB List List mystery collections

Write the final contents of each list after being manipulated by the function below:

Public Sub Mystery1(a As List(Of Integer))
    For i As Integer = a.Count - 1 To 0 Step -1
        If a(i) < a(i - 1) 
            Dim n As Integer = a(i) 
            a.RemoveAt(i) 
            a.Insert(0, n) 
        End If
    Next
End Sub
{2, 6, 1, 8}
{10, 30, 40, 20, 60, 50}
{-4, 16, 9, 1, 64, 25, 36, 4, 49}

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.