[{"data":1,"prerenderedAt":238},["ShallowReactive",2],{"term-t\u002Ftree":3,"related-t\u002Ftree":222},{"id":4,"title":5,"acronym":6,"body":7,"category":203,"description":204,"difficulty":205,"extension":206,"letter":207,"meta":208,"navigation":142,"path":209,"related":210,"seo":216,"sitemap":217,"stem":220,"subcategory":6,"__hash__":221},"terms\u002Fterms\u002Ft\u002Ftree.md","Tree",null,{"type":8,"value":9,"toc":197},"minimark",[10,15,19,23,26,30,186,190,193],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 — The Vibe Check",[16,17,18],"p",{},"A tree is a data structure shaped like an upside-down tree — one root at the top, branches going down, and leaves at the very bottom. Each item (node) can have children. The DOM in your browser is a tree. File systems are trees. Family trees are trees. They are great for hierarchical data.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"A tree is a hierarchical data structure consisting of nodes connected by edges, with one root node at the top and child nodes branching below. Trees are acyclic (no loops). Important tree types include binary trees (max 2 children), binary search trees (BST, ordered for O(log n) search), AVL\u002Fred-black trees (self-balancing), tries (prefix trees), and heaps. The DOM, file systems, and ASTs are all tree structures.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-javascript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F Binary Search Tree node:\nclass TreeNode {\n  constructor(value) {\n    this.value = value;\n    this.left = null;\n    this.right = null;\n  }\n}\n\n\u002F\u002F BST property: left \u003C node \u003C right\n\u002F\u002F       8\n\u002F\u002F      \u002F \\\n\u002F\u002F     3   10\n\u002F\u002F    \u002F \\    \\\n\u002F\u002F   1   6    14\n\u002F\u002F Search is O(log n) in a balanced tree\n","javascript","",[38,39,40,49,64,82,100,113,125,131,137,144,150,156,162,168,174,180],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,48],{"class":47},"sHwdD","\u002F\u002F Binary Search Tree node:\n",[41,50,52,56,60],{"class":43,"line":51},2,[41,53,55],{"class":54},"spNyl","class",[41,57,59],{"class":58},"sBMFI"," TreeNode",[41,61,63],{"class":62},"sMK4o"," {\n",[41,65,67,70,73,77,80],{"class":43,"line":66},3,[41,68,69],{"class":54},"  constructor",[41,71,72],{"class":62},"(",[41,74,76],{"class":75},"sHdIc","value",[41,78,79],{"class":62},")",[41,81,63],{"class":62},[41,83,85,88,91,94,97],{"class":43,"line":84},4,[41,86,87],{"class":62},"    this.",[41,89,76],{"class":90},"sTEyZ",[41,92,93],{"class":62}," =",[41,95,96],{"class":90}," value",[41,98,99],{"class":62},";\n",[41,101,103,105,108,110],{"class":43,"line":102},5,[41,104,87],{"class":62},[41,106,107],{"class":90},"left",[41,109,93],{"class":62},[41,111,112],{"class":62}," null;\n",[41,114,116,118,121,123],{"class":43,"line":115},6,[41,117,87],{"class":62},[41,119,120],{"class":90},"right",[41,122,93],{"class":62},[41,124,112],{"class":62},[41,126,128],{"class":43,"line":127},7,[41,129,130],{"class":62},"  }\n",[41,132,134],{"class":43,"line":133},8,[41,135,136],{"class":62},"}\n",[41,138,140],{"class":43,"line":139},9,[41,141,143],{"emptyLinePlaceholder":142},true,"\n",[41,145,147],{"class":43,"line":146},10,[41,148,149],{"class":47},"\u002F\u002F BST property: left \u003C node \u003C right\n",[41,151,153],{"class":43,"line":152},11,[41,154,155],{"class":47},"\u002F\u002F       8\n",[41,157,159],{"class":43,"line":158},12,[41,160,161],{"class":47},"\u002F\u002F      \u002F \\\n",[41,163,165],{"class":43,"line":164},13,[41,166,167],{"class":47},"\u002F\u002F     3   10\n",[41,169,171],{"class":43,"line":170},14,[41,172,173],{"class":47},"\u002F\u002F    \u002F \\    \\\n",[41,175,177],{"class":43,"line":176},15,[41,178,179],{"class":47},"\u002F\u002F   1   6    14\n",[41,181,183],{"class":43,"line":182},16,[41,184,185],{"class":47},"\u002F\u002F Search is O(log n) in a balanced tree\n",[11,187,189],{"id":188},"when-youll-hear-this","When You'll Hear This",[16,191,192],{},"\"The file system is a tree — use recursion to traverse it.\" \u002F \"A BST gives you O(log n) search if it stays balanced.\"",[194,195,196],"style",{},"html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":51,"depth":51,"links":198},[199,200,201,202],{"id":13,"depth":51,"text":14},{"id":21,"depth":51,"text":22},{"id":28,"depth":51,"text":29},{"id":188,"depth":51,"text":189},"general","A tree is a data structure shaped like an upside-down tree — one root at the top, branches going down, and leaves at the very bottom.","intermediate","md","t",{},"\u002Fterms\u002Ft\u002Ftree",[211,212,213,214,215],"Data Structure","Graph","Recursion","Binary Search","DOM",{"title":5,"description":204},{"changefreq":218,"priority":219},"weekly",0.7,"terms\u002Ft\u002Ftree","KIrc-F1rWRWtVokCT5UlLriTA_RZly0Fvmcfvvedfl0",[223,227,232,235],{"title":211,"path":224,"acronym":6,"category":203,"difficulty":225,"description":226},"\u002Fterms\u002Fd\u002Fdata-structure","beginner","A data structure is a way of organizing information in your code so it is easy to use and fast to access.",{"title":215,"path":228,"acronym":229,"category":230,"difficulty":225,"description":231},"\u002Fterms\u002Fd\u002Fdom","Document Object Model","frontend","The DOM is a live map of your webpage that JavaScript can read and edit. When the browser loads your HTML it turns it into a big tree of objects.",{"title":212,"path":233,"acronym":6,"category":203,"difficulty":205,"description":234},"\u002Fterms\u002Fg\u002Fgraph","A graph is like a network of dots connected by lines. Each dot is a node and each line is an edge.",{"title":213,"path":236,"acronym":6,"category":203,"difficulty":205,"description":237},"\u002Fterms\u002Fr\u002Frecursion","Recursion is when a function calls itself to solve a smaller version of the same problem, like a set of Russian nesting dolls.",1776518319907]