March 2019
Intermediate to advanced
336 pages
9h 9m
English
The main method in the TreeSet class creates a TreeSet with TreeNodes. The following snippet creates a TreeSet and invokes the String method:
// main methodfunc main() { var treeset *TreeSet = &TreeSet{} treeset.bst = &BinarySearchTree{} var node1 TreeNode = TreeNode{8,8, nil,nil} var node2 TreeNode = TreeNode{3,3,nil, nil} var node3 TreeNode = TreeNode{10,10,nil,nil} var node4 TreeNode = TreeNode{1,1,nil,nil} var node5 TreeNode = TreeNode{6,6,nil,nil} treeset.InsertTreeNode(node1,node2,node3, node4, node5) treeset.String()}
Run the following commands to execute the treeset.go and binarysearchtree.go files:
$ go build treeset.go binarysearchtree.go$ ./treeset
The output is as follows:
The next section talks about the synchronized ...
Read now
Unlock full access