1. typo fix {playfair_cipher.py, AVL.py}

2. Corrected Logic {AVL.py, 104-107}
3. Removed unnecessary semicolons {BellmanFord.py, Dijkstra.py}
This commit is contained in:
ashu01 2017-12-31 14:30:31 +05:30
parent a033150426
commit 4fb978cf58
4 changed files with 21 additions and 21 deletions

View File

@ -13,8 +13,8 @@ def chunker(seq, size):
def prepare_input(dirty):
"""
Prepare the plaintext by uppcasing it
and seperating repeated letters with X's
Prepare the plaintext by up-casing it
and separating repeated letters with X's
"""
dirty = ''.join([c.upper() for c in dirty if c in string.ascii_letters])
@ -38,7 +38,7 @@ def prepare_input(dirty):
def generate_table(key):
# I and J are used interchangably to allow
# I and J are used interchangeably to allow
# us to use a 5x5 table (25 letters)
alphabet = "ABCDEFGHIKLMNOPQRSTUVWXYZ"
# we're using a list instead of a '2d' array because it makes the math

View File

@ -1,6 +1,6 @@
'''
A AVL tree
'''
"""
An AVL tree
"""
from __future__ import print_function
@ -101,10 +101,10 @@ class AVL:
if height_left > height_right:
left_child = n.left
if left_child is not None:
h_right = (right_child.right.height
if (right_child.right is not None) else 0)
h_left = (right_child.left.height
if (right_child.left is not None) else 0)
h_right = (left_child.right.height
if (left_child.right is not None) else 0)
h_left = (left_child.left.height
if (left_child.left is not None) else 0)
if (h_left > h_right):
self.rotate_left(n)
break

View File

@ -7,11 +7,11 @@ def printDist(dist, V):
print(i,"\t",int(dist[i]),end = "\t")
else:
print(i,"\t","INF",end="\t")
print();
print()
def BellmanFord(graph, V, E, src):
mdist=[float('inf') for i in range(V)]
mdist[src] = 0.0;
mdist[src] = 0.0
for i in range(V-1):
for j in range(V):
@ -35,13 +35,13 @@ def BellmanFord(graph, V, E, src):
#MAIN
V = int(input("Enter number of vertices: "));
E = int(input("Enter number of edges: "));
V = int(input("Enter number of vertices: "))
E = int(input("Enter number of edges: "))
graph = [dict() for j in range(E)]
for i in range(V):
graph[i][i] = 0.0;
graph[i][i] = 0.0
for i in range(E):
print("\nEdge ",i+1)

View File

@ -7,7 +7,7 @@ def printDist(dist, V):
print(i,"\t",int(dist[i]),end = "\t")
else:
print(i,"\t","INF",end="\t")
print();
print()
def minDist(mdist, vset, V):
minVal = float('inf')
@ -25,7 +25,7 @@ def Dijkstra(graph, V, src):
for i in range(V-1):
u = minDist(mdist, vset, V)
vset[u] = True;
vset[u] = True
for v in range(V):
if (not vset[v]) and graph[u][v]!=float('inf') and mdist[u] + graph[u][v] < mdist[v]:
@ -38,20 +38,20 @@ def Dijkstra(graph, V, src):
#MAIN
V = int(input("Enter number of vertices: "));
E = int(input("Enter number of edges: "));
V = int(input("Enter number of vertices: "))
E = int(input("Enter number of edges: "))
graph = [[float('inf') for i in range(V)] for j in range(V)]
for i in range(V):
graph[i][i] = 0.0;
graph[i][i] = 0.0
for i in range(E):
print("\nEdge ",i+1)
src = int(input("Enter source:"))
dst = int(input("Enter destination:"))
weight = float(input("Enter weight:"))
graph[src][dst] = weight;
graph[src][dst] = weight
gsrc = int(input("\nEnter shortest path source:"))
Dijkstra(graph, V, gsrc)