how to make basic Tree data structure
10 次查看(过去 30 天)
显示 更早的评论
I need an explanation how node.child node.parent can be implemented as moving to next item in tree?
I want a code that defined in class structure for tree data structure
it will be like this in python
class Node():
def __init__(self, parent=None, position=None, child):
self.parent = parent
self.position = position
self.child = child
parent and child holds another node structure
0 个评论
回答(1 个)
Sulaymon Eshkabilov
2023-11-3
If understood correctly your question, the structure variable can be built in the following way, e.g.:
Child1 = magic(3);
Child2 = randi(3,2,3);
Child3 = 'Today';
Home = 'City Street zip #';
Parent1.Child1 = Child1;
Parent1.Child2 = Child2;
Parent2.Child3 = Child3;
Family.Parent1 = Parent1;
Family.Parent2 = Parent2;
Family.Home = Home
disp(Parent1)
disp(Parent2)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!