Solved LeetCode program · 109 of 1,000
#0109 · Convert Sorted List to Binary Search Tree
Original English source
Keep a shared numbers holding -10, -3, 0, 5, and 9. Keep a shared values as an empty list of whole numbers. Keep a shared lefts as an empty list of whole numbers. Keep a shared rights as an empty list of whole numbers. Keep a shared index of 0. Keep a shared parent of -1. Keep a shared side of 0.
To shape from low (a whole number) with high (a whole number). If low is more than high, return. The middle is the midpoint of low and high. The root is item middle of numbers. The slot is index. Add 1 to index. Place root into values. Place -1 into lefts. Place -1 into rights. The anchor is parent. If anchor is at least 0 and side is 0, set item anchor of lefts to slot. If anchor is at least 0 and side is 1, set item anchor of rights to slot. Set parent to slot. Set side to 0. Shape from low with middle minus 1. Set parent to slot. Set side to 1. Shape from middle plus 1 with high.
Shape from 0 with 4. For each value in values, show value.
Expected stdout
0 -10 -3 5 9