[SOLVED] CS Java public class Odd {

$25

File Name: CS_Java_public_class_Odd_{.zip
File Size: 244.92 KB

5/5 - (1 vote)

public class Odd {

public boolean isOdd(Node r) {
/* Input: Root r of a tree
Output: true if all internal nodes of the tree have odd degree; false otherwise

You can use the following methods from class Node:
numChildren() returns the number of children of a node.
isLeaf(): returns true if a node is a leaf and returns false otherwise

To translate the following pseudocode

for each child u of r do { }

use the following java code:

Node[] children = r.getChildren();
for (Node u : children) { }
*/

}

}

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS Java public class Odd {
$25