I have searched the internet very carefully but it seems impossible to get som simple answers regarding trees that is not binary trees and that will not interact with the DOM. I start with some code that i found so that it will be easier to understand what i really would like to understand.
funcion Node (data){
this.data = data;
this.parent = null;
this.children = [];}
function Tree (data){
var node = new Node (data);
this._root = node;}
var tree = new Tree ('one');
tree._root.children.push (new Node('two'));
tree._root.children[0].parent = tree;
tree._root.children.push (new Node('three'));
tree._root.children[0].parent = tree;
tree._root.children.push (new Node('four'));
tree._root.children[0].parent = tree;
So - This code will create a Tree with the topnode = 'one' and three children called 'two', 'three' and 'four'.
If i now - directly in the code on the line following the last line in the code above want to delete the tree childrens, what would that code look like ? I simply cant fint the keyword for doing that. Is is "deleteChild" or "delete Node" or remove Node - or something else ?
As i understand from the code this tree is using a single string to store user data - in this case 'one' and 'two' and so on. If i would instead like to use a string array with three values for example 'Chris', 72, 'Orange' - how would that code look like in the above eample ?
Where can I myself find fact regarding all the keywords and commands that you use when you are working with n-ary trees ? Would be very very grateful for links !
Kind Regards