Tag Archives: insert

Longest palindrom by deleting/inserting elements

Given a string. Find minimum number of insertion (or deletions) required to make it a palindrom. For example, S=”abacba” can be transformed into the longest palindrom P1=”abacaba” just by inserting 1 char. Observe that as long as mirror positions has the same character we have a potential palindrome between the mirror positions (inclusive). Note that, […]

Binary Search Tree (BST) insert, delete, successor, predecessor, traversal, unique trees

From wiki, A binary search tree is a rooted binary tree, whose internal nodes each store a key (and optionally, an associated value) and each have two distinguished sub-trees, commonly denoted left and right. The tree additionally satisfies the binary search tree property, which states that the key in each node must be greater than all […]