Skip to content

Commit 266808a

Browse files
committed
update readme
1 parent 1deda1a commit 266808a

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

README.md

+12-16
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ Implentation of a general tree in **Go Programming Language**. A general tree is
77
**Types:**
88

99
```go
10-
type Node struct
10+
type Node struct
1111
Value interface{}
1212
Children []*Node
1313
}
1414

15-
type GeneralTree struct
15+
type GeneralTree struct
1616
Root *Node
1717
}
1818
```
@@ -21,14 +21,10 @@ type GeneralTree struct
2121

2222
```go
2323
// Create a new general tree
24-
func NewGeneralTree() *GeneralTree
25-
return &GeneralTree{}
26-
}
24+
func NewGeneralTree() *GeneralTree
2725

2826
// Create a new node
29-
func NewNode() *Node
30-
return &Node{}
31-
}
27+
func NewNode() *Node
3228
```
3329

3430
**Methods:**
@@ -41,24 +37,24 @@ func (t *GeneralTree) AddNode(value interface{})
4137
func (t *GeneralTree) AddNodeToParent(value int, parent *Node)
4238

4339
// Get the root node of the tree
44-
func (t *GeneralTree) GetRoot() *Node
40+
func (t *GeneralTree) GetRoot() *Node
4541

4642
// Get the children of a node
47-
func (t *GeneralTree) GetChildren(node *Node) []*Node
43+
func (t *GeneralTree) GetChildren(node *Node) []*Node
4844

4945
// Get the value of a node
50-
func (t *GeneralTree) GetValue(node *Node) interface{}
46+
func (t *GeneralTree) GetValue(node *Node) interface{}
5147

5248
// Set the value of a node
5349
func (t *GeneralTree) SetValue(node *Node, value interface{})
5450

5551
// Get the number of nodes in the tree
56-
func (t *GeneralTree) GetSize() int
57-
func (t *GeneralTree) getSize(node *Node) int
52+
func (t *GeneralTree) GetSize() int
53+
func (t *GeneralTree) getSize(node *Node) int
5854

5955
// Get the height of the tree
60-
func (t *GeneralTree) getHeight() int
61-
func (t *Node) GetHeight(node *Node) int
56+
func (t *GeneralTree) getHeight() int
57+
func (t *Node) GetHeight(node *Node) int
6258

6359
// Print the tree
6460
func (t *GeneralTree) PrintTree()
@@ -118,7 +114,7 @@ func main()
118114
// Get the children of the root node
119115
child := tree.GetChildren(tree.Root)
120116
fmt.Println("Children of the root node: ", tree.GetChildren(tree.Root))
121-
for _, c := range child
117+
for _, c := range child
122118
fmt.Println("\tChildren of the root node: ", c.Value)
123119
}
124120

0 commit comments

Comments
 (0)