Part 1: Operations

  1. The time of executing the innermost loop equals the final value of corresponding counters.

    1. counter = 40

    2. counter = 40

    3. counter = 70

    4. counter = 32 counter2 = 8

    5. counter = N*N

    6. counter = 3N

    7. counter = N*(N-1)

    1. O(1)

    2. O(1)

    3. O(1)

    4. O(1)

    5. O(N^2)

    6. O(N)

    7. O(N^2)

  2. For N < 81000, A is faster. For N > 81000, B is faster. As N grows larger, B is better.

Part 2: Sorting

    1. 573, 839, 102, 550, 593, 996, 678, 111, 264, 266

      102, 839, 573, 550, 593, 996, 678, 111, 264, 266

      102, 111, 573, 550, 593, 996, 678, 839, 264, 266

      102, 111, 264, 550, 593, 996, 678, 839, 573, 266

      102, 111, 264, 266, 593, 996, 678, 839, 573, 550

      102, 111, 264, 266, 550, 996, 678, 839, 573, 593

      102, 111, 264, 266, 550, 573, 678, 839, 996, 593

      102, 111, 264, 266, 550, 573, 593, 839, 996, 678

      102, 111, 264, 266, 550, 573, 593, 678, 996, 839

      102, 111, 264, 266, 550, 573, 593, 678, 839, 996

      102, 111, 264, 266, 550, 573, 593, 678, 839, 996

    2. 95, 36, 683, 92784, 73856, 3811, 392, 38, 258, 399

      36, 95, 683, 92784, 73856, 3811, 392, 38, 258, 399

      36, 38, 683, 92784, 73856, 3811, 392, 95, 258, 399

      36, 38, 95, 92784, 73856, 3811, 392, 683, 258, 399

      36, 38, 95, 258, 73856, 3811, 392, 683, 92784, 399

      36, 38, 95, 258, 392, 3811, 73856, 683, 92784, 399

      36, 38, 95, 258, 392, 399, 73856, 683, 92784, 3811

      36, 38, 95, 258, 392, 399, 683, 73856, 92784, 3811

      36, 38, 95, 258, 392, 399, 683, 3811, 92784, 73856

      36, 38, 95, 258, 392, 399, 683, 3811, 73856, 92784

      36, 38, 95, 258, 392, 399, 683, 3811, 73856, 92784

    3. 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100

      100, 900, 800, 700, 600, 500, 400, 300, 200, 1000

      100, 200, 800, 700, 600, 500, 400, 300, 900, 1000

      100, 200, 300, 700, 600, 500, 400, 800, 900, 1000

      100, 200, 300, 400, 600, 500, 700, 800, 900, 1000

      100, 200, 300, 400, 500, 600, 700, 800, 900, 1000

      100, 200, 300, 400, 500, 600, 700, 800, 900, 1000

      100, 200, 300, 400, 500, 600, 700, 800, 900, 1000

      100, 200, 300, 400, 500, 600, 700, 800, 900, 1000

      100, 200, 300, 400, 500, 600, 700, 800, 900, 1000

      100, 200, 300, 400, 500, 600, 700, 800, 900, 1000

  1. Outerloop # Inner loop iterations
    1 10
    2 9
    3 8
    4 7
    5 6
    6 5
    7 4
    8 3
    9 2
    10 1

    1. 573, 839, 102, 550, 593, 996, 678, 111, 264, 266

      573, 839, 102, 550, 593, 996, 678, 111, 264, 266

      102, 573, 839, 550, 593, 996, 678, 111, 264, 266

      102, 550, 573, 839, 593, 996, 678, 111, 264, 266

      102, 550, 573, 593, 839, 996, 678, 111, 264, 266

      102, 550, 573, 593, 839, 996, 678, 111, 264, 266

      102, 550, 573, 593, 678, 839, 996, 111, 264, 266

      102, 111, 550, 573, 593, 678, 839, 996, 264, 266

      102, 111, 264, 550, 573, 593, 678, 839, 996, 266

      102, 111, 264, 266, 550, 573, 593, 678, 839, 996

    2. 95, 36, 683, 92784, 73856, 3811, 392, 38, 258, 399

      36, 95, 683, 92784, 73856, 3811, 392, 38, 258, 399

      36, 95, 683, 92784, 73856, 3811, 392, 38, 258, 399

      36, 95, 683, 92784, 73856, 3811, 392, 38, 258, 399

      36, 95, 683, 73856, 92784, 3811, 392, 38, 258, 399

      36, 95, 683, 3811, 73856, 92784, 392, 38, 258, 399

      36, 95, 392, 683, 3811, 73856, 92784, 38, 258, 399

      36, 38, 95, 392, 683, 3811, 73856, 92784, 258, 399

      36, 38, 95, 258, 392, 683, 3811, 73856, 92784, 399

      36, 38, 95, 258, 392, 399, 683, 3811, 73856, 92784

    3. 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100

      900, 1000, 800, 700, 600, 500, 400, 300, 200, 100

      800, 900, 1000, 700, 600, 500, 400, 300, 200, 100

      700, 800, 900, 1000, 600, 500, 400, 300, 200, 100

      600, 700, 800, 900, 1000, 500, 400, 300, 200, 100

      500, 600, 700, 800, 900, 1000, 400, 300, 200, 100

      400, 500, 600, 700, 800, 900, 1000, 300, 200, 100

      300, 400, 500, 600, 700, 800, 900, 1000, 200, 100

      200, 300, 400, 500, 600, 700, 800, 900, 1000, 100

      100, 200, 300, 400, 500, 600, 700, 800, 900, 1000

  2. Charles, Harriot, Ian, Janice, Doug, Alice, Ethan, George, Bob, Frank