Module Module1 ' This program counts the number of print statements ' executed for a list of a given size ' This gives a measure of how many print statements are executed ' The number of times the loops are executed is more significant ' than the number of statements in each loop Sub bigO(ByVal aList) Dim numberOfPrints As Integer = 0 Dim outsideLoopCount As Integer Dim insideLoopCount As Integer ' Maximum index of item in list ' One pass for every item in the list outsideLoopCount = aList.count - 1 For i = 0 To outsideLoopCount Console.WriteLine(String.Format("In outer loop: {0}", aList(i))) numberOfPrints = numberOfPrints + 1 ' Use integer division which disgards remainder, so no exception possible insideLoopCount = outsideLoopCount \ 2 For j = 0 To insideLoopCount Console.WriteLine(String.Format(" In inner loop: {0}", aList(j))) numberOfPrints = numberOfPrints + 1 Next Next Console.WriteLine(String.Format("Number of print statements executed in loops: {0}", numberOfPrints)) numberOfPrints = numberOfPrints + 1 ' This is the addition for the last line being printed numberOfPrints = numberOfPrints + 1 Console.WriteLine(String.Format("Full total including last two print {0}", numberOfPrints)) End Sub Sub Main() Dim eat As String Dim listOfItems As New List(Of Integer) From {1, 2, 3, 4, 5, 6} bigO(listOfItems) Console.WriteLine(String.Format("Length of list: {0}", listOfItems.Count)) Console.WriteLine("Any key to continue") eat = Console.ReadLine() End Sub End Module