Modifier and Type | Field and Description |
---|---|
TreeNode |
left
It specifies the left child.
|
TreeNode |
leftNeighbor
It specifies the left neighbor.
|
TreeNode |
parent
It specifies the parent of this node.
|
TreeNode |
right
It specifies the right child.
|
TreeNode |
rightNeighbor
It specifies the right neighbor.
|
Constructor and Description |
---|
TreeNode()
The constructor used by tree leaves.
|
TreeNode(TreeNode left,
TreeNode right)
It constructs a node of the item tree.
|
Modifier and Type | Method and Description |
---|---|
int |
getPSum()
It does not recompute sum of profits.
|
int |
getWMax()
It does not recompute the maximum of weights.
|
int |
getWSum()
It does not recompute sum of weights.
|
boolean |
isLeaf() |
String |
nodeToString()
It generates description of the node only.
|
void |
recomputeDown(Tree tree)
This function recomputes the attributes of this node after
recomputing the left and right subtree.
|
void |
recomputeUp(Tree tree)
This function is used to recompute the attributes of all nodes
on the way to root from this node.
|
void |
setLeftNeighbor(TreeNode leftNeighbor)
It sets the left neighbor of this tree node.
|
void |
setRightNeighbor(TreeNode rightNeighbor)
It sets the right neighbor of this tree node.
|
String |
toString() |
public TreeNode parent
public final TreeNode left
public final TreeNode right
public TreeNode leftNeighbor
public TreeNode rightNeighbor
public void setLeftNeighbor(TreeNode leftNeighbor)
leftNeighbor
- left neighbor of this node.public void setRightNeighbor(TreeNode rightNeighbor)
rightNeighbor
- right neighbor of this node.public boolean isLeaf()
public int getWMax()
public int getWSum()
public int getPSum()
public void recomputeUp(Tree tree)
tree
- only added to be in agreement with the function template
for leaf which need information about tree it belongs to.public void recomputeDown(Tree tree)
tree
- It is required by leaves so tree atributes like alreadyUsedCapacity are properly updated.public String nodeToString()
Copyright © 2022. All rights reserved.