Question 1 - Answer 1
Question 2 - Answer 2
Question 3 - Answer 3
More duplicates of this pattern from the same user:
Iterator for binary tree - pre, in, and post order iterators
Isomorphic trees verification
Return the next right node
Print all nodes that are at distance k from a leaf node
Create a binary tree, code review request
Morris inorder traversal
Print left view of the tree
Get the levels of a binary tree
https://codereview.stackexchange.com/questions/32007/join-levels-of-binary-tree
Serializing/deserializing binary tree in most space-efficient way (Yeah, this one too. It doesn't look like it at first but on closer inspection it does)
Join/ connect all levels of Binary tree without any aux storage
Preorder traversal of binary tree to produce formatted string
Inorder traversal of a tree without recursion or stack
Least common ancestor in binary tree (Has check for null, but not empty array)
Detect a complete binary tree
Reverse values of alternate nodes of the tree
Find all nodes in tree, without a sibling
Check if all leaves are at same level
Search an element/item in an n-ary tree (uses array, but my answer is still valid)
Given a Perfect Binary Tree, reverse the alternate level nodes of the binary tree
Transform a Binary Search Tree into a Greater Sum Tree
Detect if a tree is complete binary tree
If a question duplicates the code...
class BinaryTrees<T> {
private TreesNode<T> root;
public BinaryTrees(List<T> items) {
create(items);
}
private void create (List<T> items) {
root = new TreesNode<T>(items.get(0));
(...)
and
class BinaryTree<T> {
private Node<T> root;
public BinaryTree(Node<T> root) {
this.root = root;
}
public BinaryTree(List<T> items) {
create(items);
}
private void create (List<? extends T> items) {
root = new Node<T>(items.get(0));
(...)
with answer
Bug:
IndexOutOfBoundsException
on empty list inBinaryTree(s).create(List<(? extends )T> items)
. You don't have a comment stating you need to input a list containing at least something. Consider returningIllegalArgumentException
and adding a comment.
(Note: I have referred to the proper names and function signatures in both answers. My answer is not generic.)
Am I allowed to post a duplicate answer? I can come up with a couple of arguments for yes and for no...
Yes, because each question stands on its own.
Yes, because I might not have noticed the duplicate.
- What if I did? How are you going to verify this?
No, because the answer is to the benefit of the asker, so duplicating your answer won't help.
- If I add one point that is not duplicated, should I remove my duplicated points? If anyone brings up these (valid) points, should their answer get deleted as a duplicate? How are they supposed to know?
No, because if you duplicate your answer then editing it requires us to change it in both posts.
Which of these reasons is valid, and why?
Additionally... does it make for a good answer?
If this is allowed, I intend to post my answer on each and every of these questions if the points haven't been made yet.
Update: I have posted answers on the questions where answerers didn't mention this issue yet.