Skip to content

Commit

Permalink
Fix Python imports and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtrah committed Nov 23, 2020
1 parent fc43ce8 commit 6f839da
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 23 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
*.code-workspace

# Local History for Visual Studio Code
.history/
.history/

# Python cache
__pycache__
5 changes: 2 additions & 3 deletions Python/Datastrukturer/HashTable.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Python.Datastrukturer.LinkedList as LL
import LinkedList as LL
import random
import math
class HashTable:
Expand Down Expand Up @@ -44,9 +44,8 @@ def __str__(self):




for i in range(3000): # reliability testing
ht = HashTable();
ht = HashTable()
for j in range(1000):
a = LL.Node(random.randint(0,100))
ht.hash_insert(a)
Expand Down
3 changes: 2 additions & 1 deletion Python/Datastrukturer/Heap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from Python.Datastrukturer.HeapList import HeapList as HL
from HeapList import HeapList as HL

import random

def exchange(A, idx_A, idx_B):
Expand Down
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Python/Graphs/BFS.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# if there are disjoint nodes or if there is no path to some nodes, it won't visit them
# This is unlike DFS, which will visit all nodes, but won't necessarily find the shortest path
import queue
import Algoritmer.Graphs.Vertex as Vertex
import Vertex as Vertex

# G = A list of lists. G[0] contains for example [1,4,6] meaning that node 0 goes to nodes 1, 4 and 6.
def BFS(G, start):
Expand Down
Binary file removed Python/Graphs/__pycache__/Vertex.cpython-37.pyc
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
Hvorfor er det en nedre grense for kompleksiteten til sammenligningsbaserte algoritmer?
# Hvorfor er det en nedre grense for kompleksiteten til sammenligningsbaserte algoritmer?

Forestill deg et sammenligningstre, slik som treet på side 192 i boka. Den maksimale høyden til dette treet er 3,
og det er 6 løvnoder. Dette sammenligningstreet sammenligner tallene i en liste med 3 tall.
Det er 3!=6 ulike permutasjoner av inputet, så det minste antallet løvnoder er 6.

Så n = 3
h = 3
antall løvnoder = 6
Så n = 3
h = 3
antall løvnoder = 6

Det maksimale antallet løvnoder vi kan ha, er 2^h = 2^3 = 8
Det minste antallet løvnoder er n! = 6

Vi vil finne høyden til treet, fordi høyden gir oss antallet sammenligninger vi må gjøre for å sortere listen.
(Hvert nivå er en sammenligning).
Dette kan vi finne ved å løse
2^h >= n!
lg2^h >= lg(n!)
h*lg2 >= n lg(n)
h >= n lg(n)

https://www.youtube.com/watch?v=WffUZk1pgXE&ab_channel=BackToBackSWE
Dette kan vi finne ved å løse
2^h >= n!
lg2^h >= lg(n!)
h*lg2 >= n lg(n)
h >= n lg(n)

<https://www.youtube.com/watch?v=WffUZk1pgXE&ab_channel=BackToBackSWE>
7 changes: 0 additions & 7 deletions Python/Sortering/heapsort.py

This file was deleted.

0 comments on commit 6f839da

Please sign in to comment.