JSFiddle - React, Tailwind, and code Playground
by Diana Lemen
JavaScript
const llist = {
val: 1,
left: {
val: 2,
left: {
val: 3,
},
rigth: {
val: 4,
}
},
rigth: {
val: 5,
rigth: {
val: 6
}
}
}
class Node {
constructor(val, next = null) {
this.val = val;
this.next = next;
}
}
class LList {
constructor(val, next = null) {
this.head = null;
this.tail = null;
}
}
function traverse(node) {
if(node.left) traverse(node.left);
if(node.rigth) traverse(node.rigth);
}
traverse(llist);