[pre-commit.ci] pre-commit autoupdate (#11322)

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.2)
- [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.9.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.8.0...v1.9.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
pre-commit-ci[bot] 2024-03-13 07:52:41 +01:00 committed by GitHub
parent 5f95d6f805
commit bc8df6de31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
297 changed files with 488 additions and 285 deletions

View File

@ -16,7 +16,7 @@ repos:
- id: auto-walrus
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
rev: v0.3.2
hooks:
- id: ruff
- id: ruff-format
@ -47,7 +47,7 @@ repos:
- id: validate-pyproject
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.9.0
hooks:
- id: mypy
args:

View File

@ -1,9 +1,10 @@
"""
In this problem, we want to determine all possible combinations of k
numbers out of 1 ... n. We use backtracking to solve this problem.
In this problem, we want to determine all possible combinations of k
numbers out of 1 ... n. We use backtracking to solve this problem.
Time complexity: O(C(n,k)) which is O(n choose k) = O((n!/(k! * (n - k)!))),
Time complexity: O(C(n,k)) which is O(n choose k) = O((n!/(k! * (n - k)!))),
"""
from __future__ import annotations
from itertools import combinations

View File

@ -1,10 +1,11 @@
"""
In this problem, we want to determine all possible permutations
of the given sequence. We use backtracking to solve this problem.
In this problem, we want to determine all possible permutations
of the given sequence. We use backtracking to solve this problem.
Time complexity: O(n! * n),
where n denotes the length of the given sequence.
Time complexity: O(n! * n),
where n denotes the length of the given sequence.
"""
from __future__ import annotations

View File

@ -5,6 +5,7 @@ of the given sequence. We use backtracking to solve this problem.
Time complexity: O(2^n),
where n denotes the length of the given sequence.
"""
from __future__ import annotations
from typing import Any

View File

@ -1,9 +1,9 @@
"""
Graph Coloring also called "m coloring problem"
consists of coloring a given graph with at most m colors
such that no adjacent vertices are assigned the same color
Graph Coloring also called "m coloring problem"
consists of coloring a given graph with at most m colors
such that no adjacent vertices are assigned the same color
Wikipedia: https://en.wikipedia.org/wiki/Graph_coloring
Wikipedia: https://en.wikipedia.org/wiki/Graph_coloring
"""

View File

@ -1,10 +1,10 @@
"""
A Hamiltonian cycle (Hamiltonian circuit) is a graph cycle
through a graph that visits each node exactly once.
Determining whether such paths and cycles exist in graphs
is the 'Hamiltonian path problem', which is NP-complete.
A Hamiltonian cycle (Hamiltonian circuit) is a graph cycle
through a graph that visits each node exactly once.
Determining whether such paths and cycles exist in graphs
is the 'Hamiltonian path problem', which is NP-complete.
Wikipedia: https://en.wikipedia.org/wiki/Hamiltonian_path
Wikipedia: https://en.wikipedia.org/wiki/Hamiltonian_path
"""

View File

@ -7,6 +7,7 @@ if move is of maximizer return true else false
leaves of game tree is stored in scores[]
height is maximum height of Game tree
"""
from __future__ import annotations
import math

View File

@ -1,12 +1,13 @@
"""
The nqueens problem is of placing N queens on a N * N
chess board such that no queen can attack any other queens placed
on that chess board.
This means that one queen cannot have any other queen on its horizontal, vertical and
diagonal lines.
The nqueens problem is of placing N queens on a N * N
chess board such that no queen can attack any other queens placed
on that chess board.
This means that one queen cannot have any other queen on its horizontal, vertical and
diagonal lines.
"""
from __future__ import annotations
solution = []

View File

@ -75,6 +75,7 @@ Applying these two formulas we can check if a queen in some position is being at
for another one or vice versa.
"""
from __future__ import annotations

View File

@ -9,6 +9,7 @@ function on the next column to see if it returns True. if yes, we
have solved the puzzle. else, we backtrack and place another number
in that cell and repeat this process.
"""
from __future__ import annotations
Matrix = list[list[int]]

View File

@ -1,11 +1,12 @@
"""
The sum-of-subsetsproblem states that a set of non-negative integers, and a
value M, determine all possible subsets of the given set whose summation sum
equal to given M.
The sum-of-subsetsproblem states that a set of non-negative integers, and a
value M, determine all possible subsets of the given set whose summation sum
equal to given M.
Summation of the chosen numbers must be equal to given number M and one number
can be used only once.
Summation of the chosen numbers must be equal to given number M and one number
can be used only once.
"""
from __future__ import annotations

View File

@ -12,6 +12,7 @@ Following is the truth table of a NOR Gate:
Code provided by Akshaj Vishwanathan
https://www.geeksforgeeks.org/logic-gates-in-python
"""
from collections.abc import Callable

View File

@ -2,6 +2,7 @@
Conway's Game of Life implemented in Python.
https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
"""
from __future__ import annotations
from PIL import Image

View File

@ -26,7 +26,8 @@ Game-Of-Life Rules:
4.
Any dead cell with exactly three live neighbours be-
comes a live cell, as if by reproduction.
"""
"""
import random
import sys

View File

@ -24,6 +24,7 @@ Examples for doctest:
>>> simulate(construct_highway(5, 2, -2), 3, 0, 2)
[[0, -1, 0, -1, 0], [0, -1, 0, -1, -1], [0, -1, -1, 1, -1], [-1, 1, -1, 0, -1]]
"""
from random import randint, random

View File

@ -5,6 +5,7 @@ corresponding to the character's position in the alphabet.
https://www.dcode.fr/letter-number-cipher
http://bestcodes.weebly.com/a1z26.html
"""
from __future__ import annotations

View File

@ -1,4 +1,5 @@
""" https://en.wikipedia.org/wiki/Atbash """
"""https://en.wikipedia.org/wiki/Atbash"""
import string

View File

@ -3,6 +3,7 @@ Base32 encoding and decoding
https://en.wikipedia.org/wiki/Base32
"""
B32_CHARSET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"

View File

@ -14,6 +14,7 @@ Module includes:
Created by TrapinchO
"""
from __future__ import annotations
RotorPositionT = tuple[int, int, int]

View File

@ -8,6 +8,7 @@ making it more secure than substitution ciphers.
http://practicalcryptography.com/ciphers/fractionated-morse-cipher/
"""
import string
MORSE_CODE_DICT = {

View File

@ -35,6 +35,7 @@ https://www.youtube.com/watch?v=kfmNeskzs2o
https://www.youtube.com/watch?v=4RhLNDqcjpA
"""
import string
import numpy

View File

@ -7,6 +7,7 @@ determine the order of character rearrangement.
For more info: https://www.nku.edu/~christensen/1402%20permutation%20ciphers.pdf
"""
import random

View File

@ -1,4 +1,4 @@
""" https://en.wikipedia.org/wiki/Rail_fence_cipher """
"""https://en.wikipedia.org/wiki/Rail_fence_cipher"""
def encrypt(input_string: str, key: int) -> str:

View File

@ -7,6 +7,7 @@ Source: on page 3 of https://crypto.stanford.edu/~dabo/papers/RSA-survey.pdf
More readable source: https://www.di-mgt.com.au/rsa_factorize_n.html
large number can take minutes to factor, therefore are not included in doctest.
"""
from __future__ import annotations
import math

View File

@ -1,21 +1,22 @@
"""
author: Christian Bender
date: 21.12.2017
class: XORCipher
author: Christian Bender
date: 21.12.2017
class: XORCipher
This class implements the XOR-cipher algorithm and provides
some useful methods for encrypting and decrypting strings and
files.
This class implements the XOR-cipher algorithm and provides
some useful methods for encrypting and decrypting strings and
files.
Overview about methods
Overview about methods
- encrypt : list of char
- decrypt : list of char
- encrypt_string : str
- decrypt_string : str
- encrypt_file : boolean
- decrypt_file : boolean
- encrypt : list of char
- decrypt : list of char
- encrypt_string : str
- decrypt_string : str
- encrypt_file : boolean
- decrypt_file : boolean
"""
from __future__ import annotations

View File

@ -10,6 +10,7 @@ without needing to store any additional data except the position of the first
original character. The BWT is thus a "free" method of improving the efficiency
of text compression algorithms, costing only some extra computation.
"""
from __future__ import annotations
from typing import TypedDict

View File

@ -1,6 +1,6 @@
"""
One of the several implementations of LempelZivWelch compression algorithm
https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch
One of the several implementations of LempelZivWelch compression algorithm
https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch
"""
import math

View File

@ -1,6 +1,6 @@
"""
One of the several implementations of LempelZivWelch decompression algorithm
https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch
One of the several implementations of LempelZivWelch decompression algorithm
https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch
"""
import math

View File

@ -28,7 +28,6 @@ Sources:
en.wikipedia.org/wiki/LZ77_and_LZ78
"""
from dataclasses import dataclass
__version__ = "0.1"

View File

@ -2,6 +2,7 @@
https://en.wikipedia.org/wiki/Image_texture
https://en.wikipedia.org/wiki/Co-occurrence_matrix#Application_to_image_analysis
"""
import imageio.v2 as imageio
import numpy as np

View File

@ -1,12 +1,12 @@
"""
The Horn-Schunck method estimates the optical flow for every single pixel of
a sequence of images.
It works by assuming brightness constancy between two consecutive frames
and smoothness in the optical flow.
The Horn-Schunck method estimates the optical flow for every single pixel of
a sequence of images.
It works by assuming brightness constancy between two consecutive frames
and smoothness in the optical flow.
Useful resources:
Wikipedia: https://en.wikipedia.org/wiki/Horn%E2%80%93Schunck_method
Paper: http://image.diku.dk/imagecanon/material/HornSchunckOptical_Flow.pdf
Useful resources:
Wikipedia: https://en.wikipedia.org/wiki/Horn%E2%80%93Schunck_method
Paper: http://image.diku.dk/imagecanon/material/HornSchunckOptical_Flow.pdf
"""
from typing import SupportsIndex

View File

@ -1,4 +1,4 @@
""" Convert Base 10 (Decimal) Values to Hexadecimal Representations """
"""Convert Base 10 (Decimal) Values to Hexadecimal Representations"""
# set decimal value for each hexadecimal digit
values = {

View File

@ -1,6 +1,7 @@
"""
Convert International System of Units (SI) and Binary prefixes
"""
from __future__ import annotations
from enum import Enum

View File

@ -1,4 +1,4 @@
""" Convert between different units of temperature """
"""Convert between different units of temperature"""
def celsius_to_fahrenheit(celsius: float, ndigits: int = 2) -> float:

View File

@ -6,6 +6,7 @@ elements whose sum is equal to req_sum.
https://practice.geeksforgeeks.org/problems/count-pairs-with-given-sum5022/0
"""
from itertools import combinations

View File

@ -1,15 +1,16 @@
"""
Sparse table is a data structure that allows answering range queries on
a static number list, i.e. the elements do not change throughout all the queries.
Sparse table is a data structure that allows answering range queries on
a static number list, i.e. the elements do not change throughout all the queries.
The implementation below will solve the problem of Range Minimum Query:
Finding the minimum value of a subset [L..R] of a static number list.
The implementation below will solve the problem of Range Minimum Query:
Finding the minimum value of a subset [L..R] of a static number list.
Overall time complexity: O(nlogn)
Overall space complexity: O(nlogn)
Overall time complexity: O(nlogn)
Overall space complexity: O(nlogn)
Wikipedia link: https://en.wikipedia.org/wiki/Range_minimum_query
Wikipedia link: https://en.wikipedia.org/wiki/Range_minimum_query
"""
from math import log2

View File

@ -3,6 +3,7 @@ Please do not modify this file! It is published at https://norvig.com/sudoku.ht
only minimal changes to work with modern versions of Python. If you have improvements,
please make them in a separate file.
"""
import random
import time

View File

@ -5,6 +5,7 @@ python3 -m doctest -v avl_tree.py
For testing run:
python avl_tree.py
"""
from __future__ import annotations
import math

View File

@ -88,6 +88,7 @@ True
>>> not t
True
"""
from __future__ import annotations
from collections.abc import Iterable, Iterator

View File

@ -7,6 +7,7 @@ python -m unittest binary_search_tree_recursive.py
To run an example:
python binary_search_tree_recursive.py
"""
from __future__ import annotations
import unittest

View File

@ -8,7 +8,6 @@ Python implementation:
frames that could be in memory is `n`
"""
from __future__ import annotations
from collections.abc import Iterator

View File

@ -2,6 +2,7 @@
The diameter/width of a tree is defined as the number of nodes on the longest path
between two end nodes.
"""
from __future__ import annotations
from dataclasses import dataclass

View File

@ -10,6 +10,7 @@ https://www.geeksforgeeks.org/flatten-a-binary-tree-into-linked-list
Author: Arunkumar A
Date: 04/09/2023
"""
from __future__ import annotations

View File

@ -9,6 +9,7 @@ https://bit.ly/46uB0a2
Author : Arunkumar
Date : 14th October 2023
"""
from __future__ import annotations
from collections.abc import Iterator

View File

@ -13,6 +13,7 @@ If n is the number of nodes in the tree then:
Runtime: O(n)
Space: O(1)
"""
from __future__ import annotations
from collections.abc import Iterator

View File

@ -3,6 +3,7 @@ Is a binary tree a sum tree where the value of every non-leaf node is equal to t
of the values of its left and right subtrees?
https://www.geeksforgeeks.org/check-if-a-given-binary-tree-is-sumtree
"""
from __future__ import annotations
from collections.abc import Iterator

View File

@ -5,6 +5,7 @@ The rule for merging is that if two nodes overlap, then put the value sum of
both nodes to the new value of the merged node. Otherwise, the NOT null node
will be used as the node of new tree.
"""
from __future__ import annotations

View File

@ -3,6 +3,7 @@ Given the root of a binary tree, mirror the tree, and return its root.
Leetcode problem reference: https://leetcode.com/problems/mirror-binary-tree/
"""
from __future__ import annotations
from collections.abc import Iterator

View File

@ -35,6 +35,7 @@ https://www.geeksforgeeks.org/segment-tree-efficient-implementation/
>>> st.query(0, 2)
[1, 2, 3]
"""
from __future__ import annotations
from collections.abc import Callable

View File

@ -6,6 +6,7 @@ We will use the formula: t(n) = SUMMATION(i = 1 to n)t(i-1)t(n-i)
Further details at Wikipedia: https://en.wikipedia.org/wiki/Catalan_number
"""
"""
Our Contribution:
Basically we Create the 2 function:

View File

@ -2,6 +2,7 @@
psf/black : true
ruff : passed
"""
from __future__ import annotations
from collections.abc import Iterator

View File

@ -3,6 +3,7 @@ Segment_tree creates a segment tree with a given array and function,
allowing queries to be done later in log(N) time
function takes 2 values and returns a same type value
"""
from collections.abc import Sequence
from queue import Queue

View File

@ -4,6 +4,7 @@ Given the root of a binary tree, check whether it is a mirror of itself
Leetcode reference: https://leetcode.com/problems/symmetric-tree/
"""
from __future__ import annotations
from dataclasses import dataclass

View File

@ -7,6 +7,7 @@ such as the with segment trees or fenwick trees. You can read more about them he
2. https://www.youtube.com/watch?v=4aSv9PcecDw&t=811s
3. https://www.youtube.com/watch?v=CybAgVF-MMc&t=1178s
"""
from __future__ import annotations
test_array = [2, 1, 4, 5, 6, 0, 8, 9, 1, 2, 0, 6, 4, 2, 0, 6, 5, 3, 2, 7]

View File

@ -1,6 +1,6 @@
"""
Disjoint set.
Reference: https://en.wikipedia.org/wiki/Disjoint-set_data_structure
Disjoint set.
Reference: https://en.wikipedia.org/wiki/Disjoint-set_data_structure
"""

View File

@ -58,6 +58,7 @@ The probability decreases with the number of bits in the bitarray.
>>> bloom.bitstring
'01100101'
"""
from hashlib import md5, sha256
HASH_FUNCTIONS = (sha256, md5)

View File

@ -11,6 +11,7 @@ Where hash1() and hash2() are hash functions and TABLE_SIZE is size of hash tabl
Reference: https://en.wikipedia.org/wiki/Double_hashing
"""
from .hash_table import HashTable
from .number_theory.prime_numbers import is_prime, next_prime

View File

@ -7,6 +7,7 @@ Another hash map implementation, with a good explanation.
Modern Dictionaries by Raymond Hettinger
https://www.youtube.com/watch?v=p33CVV29OG8
"""
from collections.abc import Iterator, MutableMapping
from dataclasses import dataclass
from typing import Generic, TypeVar

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
module to operations with prime numbers
module to operations with prime numbers
"""
import math

View File

@ -5,6 +5,7 @@ Nodes contain data and also may link to other nodes:
head node gives us access of the complete list
- Last node: points to null
"""
from __future__ import annotations
from typing import Any

View File

@ -1,6 +1,7 @@
"""
Algorithm that merges two sorted linked lists into one sorted linked list.
"""
from __future__ import annotations
from collections.abc import Iterable, Iterator

View File

@ -2,6 +2,7 @@
Based on "Skip Lists: A Probabilistic Alternative to Balanced Trees" by William Pugh
https://epaperpress.com/sortsearch/download/skiplist.pdf
"""
from __future__ import annotations
from random import random

View File

@ -1,6 +1,7 @@
"""
Implementation of double ended queue.
"""
from __future__ import annotations
from collections.abc import Iterable

View File

@ -1,4 +1,5 @@
""" A Queue using a linked list like structure """
"""A Queue using a linked list like structure"""
from __future__ import annotations
from collections.abc import Iterator

View File

@ -1,4 +1,5 @@
"""Queue represented by a pseudo stack (represented by a list with pop and append)"""
from typing import Any

View File

@ -29,6 +29,7 @@ RULE 5: When the entire infix expression has been scanned, the value left on
NOTE: It only works with whole numbers.
"""
__author__ = "Alexander Joslin"
import operator as op

View File

@ -1,4 +1,5 @@
""" A Stack using a linked list like structure """
"""A Stack using a linked list like structure"""
from __future__ import annotations
from collections.abc import Iterator

View File

@ -1,6 +1,7 @@
"""
Implemented an algorithm using opencv to convert a colored image into its negative
Implemented an algorithm using opencv to convert a colored image into its negative
"""
from cv2 import destroyAllWindows, imread, imshow, waitKey

View File

@ -1,6 +1,7 @@
"""
Implementation Burke's algorithm (dithering)
"""
import numpy as np
from cv2 import destroyAllWindows, imread, imshow, waitKey

View File

@ -9,6 +9,7 @@ Inputs:
Output:
img:A 2d zero padded image with values in between 0 and 1
"""
import math
import sys

View File

@ -1,6 +1,7 @@
"""
Implementation of gaussian filter algorithm
"""
from itertools import product
from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey

View File

@ -1,6 +1,7 @@
"""
Implementation of median filter algorithm
"""
from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import divide, int8, multiply, ravel, sort, zeros_like

View File

@ -3,6 +3,7 @@ Created on Fri Sep 28 15:22:29 2018
@author: Binish125
"""
import copy
import os

View File

@ -1,4 +1,5 @@
""" Multiple image resizing techniques """
"""Multiple image resizing techniques"""
import numpy as np
from cv2 import destroyAllWindows, imread, imshow, waitKey

View File

@ -1,6 +1,7 @@
"""
Implemented an algorithm using opencv to tone an image with sepia technique
Implemented an algorithm using opencv to tone an image with sepia technique
"""
from cv2 import destroyAllWindows, imread, imshow, waitKey

View File

@ -1,6 +1,7 @@
"""
PyTest's for Digital Image Processing
"""
import numpy as np
from cv2 import COLOR_BGR2GRAY, cvtColor, imread
from numpy import array, uint8

View File

@ -12,6 +12,7 @@ There are other several other algorithms for the convex hull problem
which have not been implemented here, yet.
"""
from __future__ import annotations
from collections.abc import Iterable

View File

@ -8,6 +8,7 @@ This is a divide and conquer algorithm that can find a solution in O(n) time.
For more information of this algorithm:
https://web.stanford.edu/class/archive/cs/cs161/cs161.1138/lectures/08/Small08.pdf
"""
from __future__ import annotations
from random import choice

View File

@ -6,6 +6,7 @@ maximum sum within a given array of numbers. For example, given the array
This divide-and-conquer algorithm finds the maximum subarray in O(n log n) time.
"""
from __future__ import annotations
import time

View File

@ -7,6 +7,7 @@ to find the maximum of the array.
(From Kleinberg and Tardos. Algorithm Design.
Addison Wesley 2006: Chapter 5 Solved Exercise 1)
"""
from __future__ import annotations

View File

@ -2,6 +2,7 @@
Program to list all the ways a target string can be
constructed from the given list of substrings
"""
from __future__ import annotations

View File

@ -8,6 +8,7 @@ We have N tasks and M people. Each person in M can do only certain of these task
a person can do only one task and a task is performed only by one person.
Find the total no of ways in which the tasks can be distributed.
"""
from collections import defaultdict

View File

@ -4,6 +4,7 @@
This program calculates the nth Fibonacci number in O(log(n)).
It's possible to calculate F(1_000_000) in less than a second.
"""
from __future__ import annotations
import sys

View File

@ -5,6 +5,7 @@ You are given a bitmask m and you want to efficiently iterate through all of
its submasks. The mask s is submask of m if only bits that were included in
bitmask are set
"""
from __future__ import annotations

View File

@ -10,6 +10,7 @@ return it.
Example: [10, 22, 9, 33, 21, 50, 41, 60, 80] as input will return
[10, 22, 33, 41, 60, 80] as output
"""
from __future__ import annotations

View File

@ -38,6 +38,7 @@ Example input:
arr = [40, 20, 30, 10, 30]
output: 26000
"""
from collections.abc import Iterator
from contextlib import contextmanager
from functools import cache

View File

@ -9,6 +9,7 @@ subarray sum problem in O(n) time and O(1) space.
Reference: https://en.wikipedia.org/wiki/Maximum_subarray_problem
"""
from collections.abc import Sequence

View File

@ -14,6 +14,7 @@ represented as τ (tau). By using this RC-timeconstant we can find the voltage
time 't' from the initiation of charging a capacitor with the help of the exponential
function containing RC. Both at charging and discharging of a capacitor.
"""
from math import exp # value of exp = 2.718281828459…

View File

@ -25,6 +25,7 @@ when inductor is connected across 'AC' potential source. It starts to store the
in its 'magnetic field'.with the help 'RL-time-constant' we can find current at any time
in inductor while it is charging.
"""
from math import exp # value of exp = 2.718281828459…

View File

@ -58,6 +58,7 @@ Sources :
https://learn.parallax.com/support/reference/resistor-color-codes
https://byjus.com/physics/resistor-colour-codes/
"""
valid_colors: list = [
"Black",
"Brown",

View File

@ -1,12 +1,12 @@
"""
Calculate the exponential moving average (EMA) on the series of stock prices.
Wikipedia Reference: https://en.wikipedia.org/wiki/Exponential_smoothing
https://www.investopedia.com/terms/e/ema.asp#toc-what-is-an-exponential
-moving-average-ema
Calculate the exponential moving average (EMA) on the series of stock prices.
Wikipedia Reference: https://en.wikipedia.org/wiki/Exponential_smoothing
https://www.investopedia.com/terms/e/ema.asp#toc-what-is-an-exponential
-moving-average-ema
Exponential moving average is used in finance to analyze changes stock prices.
EMA is used in conjunction with Simple moving average (SMA), EMA reacts to the
changes in the value quicker than SMA, which is one of the advantages of using EMA.
Exponential moving average is used in finance to analyze changes stock prices.
EMA is used in conjunction with Simple moving average (SMA), EMA reacts to the
changes in the value quicker than SMA, which is one of the advantages of using EMA.
"""
from collections.abc import Iterator

View File

@ -6,6 +6,7 @@ and identify trends.
Reference: https://en.wikipedia.org/wiki/Moving_average
"""
from collections.abc import Sequence

View File

@ -20,7 +20,6 @@ Requirements (pip):
- numpy
"""
from __future__ import annotations
import matplotlib.pyplot as plt # type: ignore

View File

@ -15,7 +15,6 @@ the boundary of the Mandelbrot set a fractal curve.
(see also https://en.wikipedia.org/wiki/Plotting_algorithms_for_the_Mandelbrot_set )
"""
import colorsys
from PIL import Image # type: ignore

View File

@ -22,6 +22,7 @@ Credits:
This code was written by editing the code from
https://www.riannetrujillo.com/blog/python-fractal/
"""
import sys
import turtle

View File

@ -10,7 +10,6 @@ Reference: shorturl.at/exHM7
# Author: Swayam Singh (https://github.com/practice404)
from queue import PriorityQueue
from typing import Any

View File

@ -1,6 +1,7 @@
"""
https://en.wikipedia.org/wiki/Bidirectional_search
"""
from __future__ import annotations
import time

View File

@ -1,6 +1,7 @@
"""
https://en.wikipedia.org/wiki/Bidirectional_search
"""
from __future__ import annotations
import time

View File

@ -1,29 +1,30 @@
"""Borůvka's algorithm.
Determines the minimum spanning tree (MST) of a graph using the Borůvka's algorithm.
Borůvka's algorithm is a greedy algorithm for finding a minimum spanning tree in a
connected graph, or a minimum spanning forest if a graph that is not connected.
Determines the minimum spanning tree (MST) of a graph using the Borůvka's algorithm.
Borůvka's algorithm is a greedy algorithm for finding a minimum spanning tree in a
connected graph, or a minimum spanning forest if a graph that is not connected.
The time complexity of this algorithm is O(ELogV), where E represents the number
of edges, while V represents the number of nodes.
O(number_of_edges Log number_of_nodes)
The time complexity of this algorithm is O(ELogV), where E represents the number
of edges, while V represents the number of nodes.
O(number_of_edges Log number_of_nodes)
The space complexity of this algorithm is O(V + E), since we have to keep a couple
of lists whose sizes are equal to the number of nodes, as well as keep all the
edges of a graph inside of the data structure itself.
The space complexity of this algorithm is O(V + E), since we have to keep a couple
of lists whose sizes are equal to the number of nodes, as well as keep all the
edges of a graph inside of the data structure itself.
Borůvka's algorithm gives us pretty much the same result as other MST Algorithms -
they all find the minimum spanning tree, and the time complexity is approximately
the same.
Borůvka's algorithm gives us pretty much the same result as other MST Algorithms -
they all find the minimum spanning tree, and the time complexity is approximately
the same.
One advantage that Borůvka's algorithm has compared to the alternatives is that it
doesn't need to presort the edges or maintain a priority queue in order to find the
minimum spanning tree.
Even though that doesn't help its complexity, since it still passes the edges logE
times, it is a bit simpler to code.
One advantage that Borůvka's algorithm has compared to the alternatives is that it
doesn't need to presort the edges or maintain a priority queue in order to find the
minimum spanning tree.
Even though that doesn't help its complexity, since it still passes the edges logE
times, it is a bit simpler to code.
Details: https://en.wikipedia.org/wiki/Bor%C5%AFvka%27s_algorithm
Details: https://en.wikipedia.org/wiki/Bor%C5%AFvka%27s_algorithm
"""
from __future__ import annotations
from typing import Any

View File

@ -1,6 +1,7 @@
#!/usr/bin/python
""" Author: OMKAR PATHAK """
"""Author: OMKAR PATHAK"""
from __future__ import annotations
from queue import Queue

Some files were not shown because too many files have changed in this diff Show More