Loading…
Loading…
Topic
Articles and problems tagged Trees.
Over time a disk collects files with the same name in different folders. Walk every directory, insert each file name into a binary search tree, and report a duplicate the moment a name is found already in the tree. Includes a runnable version and a real directory walk with nftw().
Eight solved problems on linked lists and binary trees: concatenate two lists, erase a list, count, compare, copy and append with recursion, traverse a tree in inorder with your own stack instead of recursion, and mirror a tree. Each solution is complete, runnable and explained line by line.
Traverse a binary tree in inorder with no recursion and no stack, by turning the NULL links of the leaves into threads to the inorder successor and predecessor. Build a threaded binary search tree with a head node, and insert and delete nodes while keeping every thread correct.
Remove a value from a binary search tree without breaking its ordering: the four cases (not found, leaf, one child, two children), the inorder successor trick, and a version built on a pointer to the father's link that also deletes the root correctly, where the classic version crashes.
Meet the tree, a non-linear data structure: binary tree terminology (root, leaf, level, depth, strictly binary, complete), the three traversals inorder, preorder and postorder, and a binary search tree in C that sorts numbers by inserting them and reading them back in order.