Answer the question
In order to leave comments, you need to log in
Created 4096 tree branches from for → for → for ... loops, etc. How can I find them now?
Need some advice, thanks everyone.
I master python, I study the possibilities.
I wanted to quickly create a binary tree, I decided with a for loop:
for wood_1 in range(1, 3):
for wood_2 in range(1, 3):
#и так 12 раз...
for wood_12 in range(1, 3):
allwood = [wood_1, wood_2, ....., wood_12]
print(allwood)
Answer the question
In order to leave comments, you need to log in
Find out for yourself what a b-tree is and what it eats with,
as well as what nodes and edges are (this is what graphs and trees consist of),
how to create a graph (tree) and traverse it.
Believe me, this is much more interesting than torturing the processor with 12 nested loops.
Well, the topic is probably like this:
import networkx as nx
G = nx.balanced_tree(2,12)
print (G.edges()) # выведет все дуги дерева
print (G.nodes()) # выведет все узлы дерева
Subtract 1 from the values so that instead of 1 and 2 it becomes 0 and 1, and congratulations, you invented the binary system and wrote down consecutive numbers from 0 to 2^12 - 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question