mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
Optimized recursive_bubble_sort (#2410)
* optimized recursive_bubble_sort * Fixed doctest error due whitespace * reduce loop times for optimization * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -19,13 +19,13 @@ def generate_sum_of_subsets_soln(nums, max_sum):
|
||||
|
||||
def create_state_space_tree(nums, max_sum, num_index, path, result, remaining_nums_sum):
|
||||
"""
|
||||
Creates a state space tree to iterate through each branch using DFS.
|
||||
It terminates the branching of a node when any of the two conditions
|
||||
given below satisfy.
|
||||
This algorithm follows depth-fist-search and backtracks when the node is not
|
||||
branchable.
|
||||
Creates a state space tree to iterate through each branch using DFS.
|
||||
It terminates the branching of a node when any of the two conditions
|
||||
given below satisfy.
|
||||
This algorithm follows depth-fist-search and backtracks when the node is not
|
||||
branchable.
|
||||
|
||||
"""
|
||||
"""
|
||||
if sum(path) > max_sum or (remaining_nums_sum + sum(path)) < max_sum:
|
||||
return
|
||||
if sum(path) == max_sum:
|
||||
|
Reference in New Issue
Block a user