mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
Pyupgrade to Python 3.9 (#4718)
* Pyupgrade to Python 3.9 * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -3,10 +3,10 @@ Python program for Bitonic Sort.
|
||||
|
||||
Note that this program works only when size of input is a power of 2.
|
||||
"""
|
||||
from typing import List
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def comp_and_swap(array: List[int], index1: int, index2: int, direction: int) -> None:
|
||||
def comp_and_swap(array: list[int], index1: int, index2: int, direction: int) -> None:
|
||||
"""Compare the value at given index1 and index2 of the array and swap them as per
|
||||
the given direction.
|
||||
|
||||
@ -37,7 +37,7 @@ def comp_and_swap(array: List[int], index1: int, index2: int, direction: int) ->
|
||||
array[index1], array[index2] = array[index2], array[index1]
|
||||
|
||||
|
||||
def bitonic_merge(array: List[int], low: int, length: int, direction: int) -> None:
|
||||
def bitonic_merge(array: list[int], low: int, length: int, direction: int) -> None:
|
||||
"""
|
||||
It recursively sorts a bitonic sequence in ascending order, if direction = 1, and in
|
||||
descending if direction = 0.
|
||||
@ -61,7 +61,7 @@ def bitonic_merge(array: List[int], low: int, length: int, direction: int) -> No
|
||||
bitonic_merge(array, low + middle, middle, direction)
|
||||
|
||||
|
||||
def bitonic_sort(array: List[int], low: int, length: int, direction: int) -> None:
|
||||
def bitonic_sort(array: list[int], low: int, length: int, direction: int) -> None:
|
||||
"""
|
||||
This function first produces a bitonic sequence by recursively sorting its two
|
||||
halves in opposite sorting orders, and then calls bitonic_merge to make them in the
|
||||
|
Reference in New Issue
Block a user