Showing posts with label Trees. Show all posts
Showing posts with label Trees. Show all posts

Thursday, January 14, 2016

Swap Nodes [Algo] - Hacker Rank Solution

A binary tree is a tree which is characterized by any one of the following properties:
  • It can be an empty (null).
  • It contains a root node and two subtrees, left subtree and right subtree. These subtrees are also binary tree.

Binary Search Tree : Lowest Common Ancestor - Hacker Rank Solution

You are given pointer to the root of the binary search tree and two values v1 and v2. You need to return the lowest common ancestor (LCA) of v1 and v2 in the binary search tree. You only need to complete the function.

Tree: Huffman Decoding - Hacker Rank Solution

Huffman coding assigns variable length codewords to fixed length input characters based on their frequencies. More frequent characters are assigned shorter codewords and less frequent characters are

Binary Search Tree : Insertion - Hacker Rank Solution

You are given a pointer to the root of a binary search tree and a value to be inserted into the tree. Insert this value into its appropriate position in the binary search tree and return the root of the updated binary tree. You just have to complete the function.

Tree: Height of a binary tree - Hacker Rank Solution

The height of a binary tree is the number of nodes on the largest path from root to any leaf. You are given a pointer to the root of a binary tree. Return the height of the tree.

Tree: Inorder Traversal - Hacker Rank Solution

You are given a pointer to the root of a binary tree; print the values in in-order traversal.
You only have to complete the function.

Tree: Postorder Traversal - Hacker Rank Solution

You are given a pointer to the root of a binary tree; print the values in post-order traversal.
You only have to complete the function.

Tree: Preorder Traversal - Hacker Rank Solution

You are given a pointer to the root of a binary tree; print the values in preorder traversal.
You only have to complete the function.
Powered by Blogger.