Created
March 25, 2021 17:44
-
-
Save JuanSeBestia/896c64ee9f82224f075debc0247a2e30 to your computer and use it in GitHub Desktop.
Structures.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hoja { | |
constructor(left = null, right = null, root = null) { | |
this.left = left; | |
this.right = right; | |
this.root = root; | |
} | |
} | |
var root = new Hoja(); | |
root.left = new Hoja(null, null, root); | |
root.right = new Hoja(new Hoja(null, null, root), new Hoja(null, null, root)); | |
var current = root; | |
while(current.left || current.root){ | |
console.log(current) | |
if(current.root){ | |
current = current.root | |
}else{ | |
current = current.left | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment