Skip to content

Instantly share code, notes, and snippets.

@jmsevold
Last active March 20, 2016 19:29
Show Gist options
  • Save jmsevold/4bf320c67a97dd06d0c2 to your computer and use it in GitHub Desktop.
Save jmsevold/4bf320c67a97dd06d0c2 to your computer and use it in GitHub Desktop.
class Queue {
constructor() {
this.items = [];
}
enq(obj) {
this.items.push(obj);
}
deq() {
return this.items.shift();
}
isEmpty() {
return this.items.length === 0;
}
}
class Node{
constructor(value,children=[]){
this.value = value;
this.children = children;
}
}
var node5 = new Node(5);
var node4 = new Node(4);
var node3 = new Node(3, [node4, node5]);
var node2 = new Node(2);
var node1 = new Node(1, [node2, node3]);
/*
1
/ \
2 3
/ \
4 5
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment