Create codespell.yml (#1698)

* fixup! Format Python code with psf/black push

* Create codespell.yml

* fixup! Format Python code with psf/black push
This commit is contained in:
Christian Clauss
2020-01-18 13:24:33 +01:00
committed by GitHub
parent c01d178798
commit bfcb95b297
78 changed files with 206 additions and 188 deletions

View File

@@ -15,7 +15,7 @@ class Node:
if self.left is None and self.right is None:
return str(self.value)
return pformat({"%s" % (self.value): (self.left, self.right)}, indent=1,)
return pformat({"%s" % (self.value): (self.left, self.right)}, indent=1)
class BinarySearchTree:

View File

@@ -11,7 +11,7 @@ def swap(a, b):
return a, b
# creating sparse table which saves each nodes 2^ith parent
# creating sparse table which saves each nodes 2^i-th parent
def creatSparse(max_node, parent):
j = 1
while (1 << j) < max_node:

View File

@@ -41,7 +41,7 @@ def binomial_coefficient(n: int, k: int) -> int:
def catalan_number(node_count: int) -> int:
"""
We can find Catalan number many ways but here we use Binomial Coefficent because it
We can find Catalan number many ways but here we use Binomial Coefficient because it
does the job in O(n)
return the Catalan number of n using 2nCn/(n+1).

View File

@@ -12,7 +12,7 @@ class RedBlackTree:
less strict, so it will perform faster for writing/deleting nodes
and slower for reading in the average case, though, because they're
both balanced binary search trees, both will get the same asymptotic
perfomance.
performance.
To read more about them, https://en.wikipedia.org/wiki/Redblack_tree
Unless otherwise specified, all asymptotic runtimes are specified in
terms of the size of the tree.
@@ -37,7 +37,7 @@ class RedBlackTree:
def rotate_left(self):
"""Rotate the subtree rooted at this node to the left and
returns the new root to this subtree.
Perfoming one rotation can be done in O(1).
Performing one rotation can be done in O(1).
"""
parent = self.parent
right = self.right
@@ -656,7 +656,7 @@ def test_tree_traversal():
def test_tree_chaining():
"""Tests the three different tree chaning functions."""
"""Tests the three different tree chaining functions."""
tree = RedBlackTree(0)
tree = tree.insert(-16).insert(16).insert(8).insert(24).insert(20).insert(22)
if list(tree.inorder_traverse()) != [-16, 0, 8, 16, 20, 22, 24]:

View File

@@ -21,7 +21,7 @@ class Node:
return f"'{self.value}: {self.prior:.5}'"
else:
return pformat(
{f"{self.value}: {self.prior:.5}": (self.left, self.right)}, indent=1,
{f"{self.value}: {self.prior:.5}": (self.left, self.right)}, indent=1
)
def __str__(self):
@@ -161,7 +161,7 @@ def main():
"""After each command, program prints treap"""
root = None
print(
"enter numbers to creat a tree, + value to add value into treap, - value to erase all nodes with value. 'q' to quit. "
"enter numbers to create a tree, + value to add value into treap, - value to erase all nodes with value. 'q' to quit. "
)
args = input()

View File

@@ -49,7 +49,7 @@ class BinomialHeap:
r"""
Min-oriented priority queue implemented with the Binomial Heap data
structure implemented with the BinomialHeap class. It supports:
- Insert element in a heap with n elemnts: Guaranteed logn, amoratized 1
- Insert element in a heap with n elements: Guaranteed logn, amoratized 1
- Merge (meld) heaps of size m and n: O(logn + logm)
- Delete Min: O(logn)
- Peek (return min without deleting it): O(1)

View File

@@ -23,6 +23,7 @@ class Heap(object):
[1, 5, 7, 9, 11, 15, 25, 100, 103, 107, 201]
>>>
"""
def __init__(self):
self.h = []
self.curr_size = 0
@@ -107,28 +108,28 @@ def main():
[2, 5, 3, 0, 2, 3, 0, 3],
[6, 1, 2, 7, 9, 3, 4, 5, 10, 8],
[103, 9, 1, 7, 11, 15, 25, 201, 209, 107, 5],
[-45, -2, -5]
[-45, -2, -5],
]:
print('source unsorted list: %s' % unsorted)
print("source unsorted list: %s" % unsorted)
h = Heap()
h.build_heap(unsorted)
print('after build heap: ', end=' ')
print("after build heap: ", end=" ")
h.display()
print('max value: %s' % h.get_max())
print('delete max value: ', end=' ')
print("max value: %s" % h.get_max())
print("delete max value: ", end=" ")
h.display()
h.insert(100)
print('after insert new value 100: ', end=' ')
print("after insert new value 100: ", end=" ")
h.display()
h.heap_sort()
print('heap sort: ', end=' ')
print("heap sort: ", end=" ")
h.display()
print()
if __name__ == '__main__':
if __name__ == "__main__":
main()

View File

@@ -3,7 +3,7 @@ Implementing Deque using DoublyLinkedList ...
Operations:
1. insertion in the front -> O(1)
2. insertion in the end -> O(1)
3. remove fron the front -> O(1)
3. remove from the front -> O(1)
4. remove from the end -> O(1)
"""

View File

@@ -3,7 +3,7 @@
- This is an example of a double ended, doubly linked list.
- Each link references the next link and the previous one.
- A Doubly Linked List (DLL) contains an extra pointer, typically called previous pointer, together with next pointer and data which are there in singly linked list.
- Advantages over SLL - IT can be traversed in both forward and backward direction.,Delete operation is more efficent"""
- Advantages over SLL - IT can be traversed in both forward and backward direction.,Delete operation is more efficient"""
class LinkedList: # making main class named linked list

View File

@@ -79,7 +79,7 @@ class LinkedList:
# END represents end of the LinkedList
return string_repr + "END"
# Indexing Support. Used to get a node at particaular position
# Indexing Support. Used to get a node at particular position
def __getitem__(self, index):
current = self.head

View File

@@ -14,7 +14,7 @@ class LinkedList:
def print_list(self):
temp = self.head
while temp is not None:
print(temp.data, end=' ')
print(temp.data, end=" ")
temp = temp.next
print()

View File

@@ -54,7 +54,7 @@ def Solve(Postfix):
Stack.append(
str(Opr[x](int(A), int(B)))
) # evaluate the 2 values poped from stack & push result to stack
) # evaluate the 2 values popped from stack & push result to stack
print(
x.rjust(8),
("push(" + A + x + B + ")").ljust(12),

View File

@@ -21,7 +21,7 @@ def calculateSpan(price, S):
# Calculate span values for rest of the elements
for i in range(1, n):
# Pop elements from stack whlie stack is not
# Pop elements from stack while stack is not
# empty and top of stack is smaller than price[i]
while len(st) > 0 and price[st[0]] <= price[i]:
st.pop()