Here's a classic example of inverting a binary tree (swap left and right children at every node): Original: 4 / \ 2 7 / \ / \ 1 3 6 9 Inverted: 4 / \ 7 2 / \ / \ 9 6 3 1 The algorithm is recursive: at ...
Many computer science textbooks carefully explain the steps of individual algorithms. However, it is surprisingly rare to find a book that allows you to see why those steps take that form, or even ...
Generally, Heaps can be of two types: Max-Heap: In a Max-Heap the key present at the root node must be greatest among the keys present at all of it’s children. The same property must be recursively ...