Finished the Pseudo Code Syntax.
This commit is contained in:
parent
cec04a4544
commit
75fd07d3e9
@ -24,7 +24,29 @@ Algorithm Design Block
|
|||||||
Step 13: Return the results of the two equal disjoint sets that were found.
|
Step 13: Return the results of the two equal disjoint sets that were found.
|
||||||
|
|
||||||
Pseudocode Syntax:
|
Pseudocode Syntax:
|
||||||
|
count <- input
|
||||||
|
elements <- input
|
||||||
|
first_set, second_set <- empty
|
||||||
|
|
||||||
|
sum <- 0
|
||||||
|
for each number in elements:
|
||||||
|
sum <- sum + number
|
||||||
|
|
||||||
|
if sum % 2 is 0:
|
||||||
|
subsets <- generate_subsets(elements)
|
||||||
|
for each subset in subsets:
|
||||||
|
current_sum <- 0
|
||||||
|
for each value in subset:
|
||||||
|
current_sum <- current_sum + value
|
||||||
|
if sum / 2 is current_sum:
|
||||||
|
first_set <- subset
|
||||||
|
|
||||||
|
if first_set is not empty:
|
||||||
|
second_set <- elements - first_set
|
||||||
|
else
|
||||||
|
return "no equal disjoint subsets"
|
||||||
|
|
||||||
|
return first_set, second_set
|
||||||
|
|
||||||
Big-O Analysis: (Based on Implementation)
|
Big-O Analysis: (Based on Implementation)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user