Skip to content

Tree.es6 Remove. Add sibling node to BFS queue#6

Open
tenthirtyone wants to merge 1 commit intobenoitvallon:masterfrom
tenthirtyone:ISSUE#5
Open

Tree.es6 Remove. Add sibling node to BFS queue#6
tenthirtyone wants to merge 1 commit intobenoitvallon:masterfrom
tenthirtyone:ISSUE#5

Conversation

@tenthirtyone
Copy link

@tenthirtyone tenthirtyone commented Dec 30, 2016

Splice changes array.length and shifts remaining elements 1 place.

Test:
const tree = new Tree();
tree.add('ceo');
tree.add('cto1', 'ceo');
tree.add('cto2', 'ceo');
tree.add('cto3', 'ceo');
tree.add('dev1', 'cto1');
tree.add('dev2', 'cto1');
tree.add('dev3', 'cto1');
tree.add('dev2', 'dev3');
tree.add('dev1', 'cto2');
tree.add('dev2', 'cto2');
tree.add('dev3', 'cto2');
tree.add('dev1', 'cto3');
tree.add('dev2', 'cto3');
tree.add('dev3', 'cto3');
tree.printByLevel();
tree.remove('dev2');
tree.printByLevel();

Current: dev2 lingers as a child of dev3. mentor/mentee relationship.

Change: dev2 is removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant