Riešenie 1. cvičenia

  1. bubble_sort O(n**2)

  1. bubble_sort vo for-cykle O(n**2)

  1. test1 O(n) a test2 O(log n)

  1. meranie času

    • pre test1:

      for i in range(10):
          n = 10000 * 2 ** i
          tim = time.time()
          for i in range(100):
              test1(n)
          print(n, round(time.time() - tim, 3))
      
    • pre test2:

      for i in range(10):
          n = 10000 * 2 ** i
          tim = time.time()
          for i in range(10000):
              test2(n)
          print(n, round(time.time() - tim, 3))
      
  2. meranie času

    • pre sorted:

      for i in range(10):
          n = 10000 * 2 ** i
          pole = [random.randrange(100000) for i in range(n)]
          tim = time.time()
          sorted(pole)
          print(n, round(time.time() - tim, 3))
      
  3. test3 O(n log n log n) a test4 O(nlog n)




© Copyright 2018-2019, Andrej Blaho.
Naposledy aktualizované 14. feb. 2019.
Vytvorené pomocou Sphinx 1.8.4.

Creative Commons License This work is licensed under a Creative Commons Attribution 4.0 International License.