Empleador activo
Coding question - given a binary tree, write code to count the sum off all siblings.
Anónimo
int totalNumberOfNodes(Node root) { if(root == null) return 0; return 1 + totalNumberOfNodes(root.left) + totalNumberOfNodes(root.right); }
private int siblingCounter = 0; public int countSiblings(BinaryNode node) { if(node.element == null) { return siblingCounter; } else { siblingCounter++; if(node.right() != null) { countSiblings(BinaryNode right); } if(node.left() != null) { countSiblings(BinaryNode left); } } return siblingCounter; }
Not sure if this works... value == null) return $sum; $sum = $sum + $tree->value; countSiblings($tree->left,$sum); countSiblings($tree->right,$sum); } ?>
Sigue a tus empresas favoritas para estar al tanto de las últimas oportunidades y disponer de información desde adentro.
Recibe recomendaciones y actualizaciones personalizadas al iniciar tu búsqueda.