mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
GitHub Action formats our code with psf/black (#1569)
* GitHub Action formats our code with psf/black @poyea Your review please. * fixup! Format Python code with psf/black push
This commit is contained in:
@@ -22,7 +22,7 @@ def display(tree): # In Order traversal of the tree
|
||||
|
||||
|
||||
def depth_of_tree(
|
||||
tree
|
||||
tree,
|
||||
): # This is the recursive function to find the depth of binary tree.
|
||||
if tree is None:
|
||||
return 0
|
||||
@@ -36,7 +36,7 @@ def depth_of_tree(
|
||||
|
||||
|
||||
def is_full_binary_tree(
|
||||
tree
|
||||
tree,
|
||||
): # This functions returns that is it full binary tree or not?
|
||||
if tree is None:
|
||||
return True
|
||||
|
||||
@@ -172,7 +172,6 @@ def main():
|
||||
args = input()
|
||||
|
||||
print("good by!")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -77,9 +77,10 @@ class MinHeap:
|
||||
|
||||
if smallest != idx:
|
||||
array[idx], array[smallest] = array[smallest], array[idx]
|
||||
self.idx_of_element[array[idx]], self.idx_of_element[
|
||||
array[smallest]
|
||||
] = (
|
||||
(
|
||||
self.idx_of_element[array[idx]],
|
||||
self.idx_of_element[array[smallest]],
|
||||
) = (
|
||||
self.idx_of_element[array[smallest]],
|
||||
self.idx_of_element[array[idx]],
|
||||
)
|
||||
|
||||
@@ -23,9 +23,7 @@ class LinkedList: # making main class named linked list
|
||||
def deleteHead(self):
|
||||
temp = self.head
|
||||
self.head = self.head.next # oldHead <--> 2ndElement(head)
|
||||
self.head.previous = (
|
||||
None
|
||||
) # oldHead --> 2ndElement(head) nothing pointing at it so the old head will be removed
|
||||
self.head.previous = None # oldHead --> 2ndElement(head) nothing pointing at it so the old head will be removed
|
||||
if self.head is None:
|
||||
self.tail = None # if empty linked list
|
||||
return temp
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Recursive Prorgam to create a Linked List from a sequence and
|
||||
# print a string representation of it.
|
||||
|
||||
|
||||
class Node:
|
||||
def __init__(self, data=None):
|
||||
self.data = data
|
||||
@@ -17,7 +18,6 @@ class Node:
|
||||
return string_rep
|
||||
|
||||
|
||||
|
||||
def make_linked_list(elements_list):
|
||||
"""Creates a Linked List from the elements of the given sequence
|
||||
(list/tuple) and returns the head of the Linked List."""
|
||||
@@ -36,8 +36,7 @@ def make_linked_list(elements_list):
|
||||
return head
|
||||
|
||||
|
||||
|
||||
list_data = [1,3,5,32,44,12,43]
|
||||
list_data = [1, 3, 5, 32, 44, 12, 43]
|
||||
print(f"List: {list_data}")
|
||||
print("Creating Linked List from List.")
|
||||
linked_list = make_linked_list(list_data)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# Program to print the elements of a linked list in reverse
|
||||
|
||||
|
||||
class Node:
|
||||
def __init__(self, data=None):
|
||||
self.data = data
|
||||
@@ -16,7 +17,6 @@ class Node:
|
||||
return string_rep
|
||||
|
||||
|
||||
|
||||
def make_linked_list(elements_list):
|
||||
"""Creates a Linked List from the elements of the given sequence
|
||||
(list/tuple) and returns the head of the Linked List."""
|
||||
@@ -34,6 +34,7 @@ def make_linked_list(elements_list):
|
||||
current = current.next
|
||||
return head
|
||||
|
||||
|
||||
def print_reverse(head_node):
|
||||
"""Prints the elements of the given Linked List in reverse order"""
|
||||
|
||||
@@ -46,8 +47,7 @@ def print_reverse(head_node):
|
||||
print(head_node.data)
|
||||
|
||||
|
||||
|
||||
list_data = [14,52,14,12,43]
|
||||
list_data = [14, 52, 14, 12, 43]
|
||||
linked_list = make_linked_list(list_data)
|
||||
print("Linked List:")
|
||||
print(linked_list)
|
||||
|
||||
Reference in New Issue
Block a user