Jul 9, 2021Tree: Level Order TraversalVisit every node of the tree from top level (root) to the bottom level. For example, for this tree: The output will be: 1, 2, 3, 4, 5, 6, 7 Thinking: If we know the nodes from the upper level, it’s easy to reach the nodes at the lower level. …Data Structures1 min readData Structures1 min read

Jul 9, 2021Binary SearchWhen solving a search problem, we should think of binary search whenever the data set is sorted in some way. Even if the dataset is not sorted, we should still think of binary search if the data is sortable. …Binary Search2 min readBinary Search2 min read

Jul 9, 2021Binary Tree Traversal — Non RecursiveThis article talks about recursive solutions of binary tree traversal. Preorder Thinking: Start from the root, visit the parent node before going into any sub-tree. If the parent has only left child, go to the left. If the parent has only right child, go to the right. If the parent…Data Structures4 min readData Structures4 min read

Jul 9, 2021Binary Tree Traversal — RecursiveBinary Tree is a special tree structure where every node has no more than two children. Example: Preorder Visit the parent node as the first. Visit the parent node Visit the left tree Visit the right tree Note: it’s visiting the left tree & right tree, not just the left…Data Structures1 min readData Structures1 min read