## Get the Height of a Node in a Binary Tree

Objective: Given a binary tree, find the height of a given node in the tree. Input: A Binary Tree and a node Output: Height of a given node in the tree. Example: Approach:

@tutorialhorizon

Objective: Given a binary tree, find the height of a given node in the tree. Input: A Binary Tree and a node Output: Height of a given node in the tree. Example: Approach:

Objective: Given a binary tree, find the height of it Input: A Binary Tree Output: Height of a binary tree Example: Approach:

This post is the extension of – Two numbers represented by a linked list, Number Stored in REVERSE order Objective: Two numbers represented by a linked listwhere each node contains single digit. The digits...

We have similar post – Two numbers represented by a linked list, Number Stored in FORWARD order Objective: Two numbers represented by a linked list where each node contains single digit. The digits are...

Objective: Write a program to Reverse the binary representation of a number Example: Input : 30 Output : 15 Explanation: binary representation of 30 is : 11110 reverse of binary representation : 01111 decimal...

This post is the extension of our earlier post Reverse a linked list. Here We have provided the better recursive solution in which we start reversing the list from the end. Objective: Reverse the...

Objective: Given a linked list, swap every kth node in that. If at the end of the list remaining nodes are less than k, leave them untouched. Input: A linked list, A number k....

Objective: Write a program to Delete a Node in the Middle of a linked list, Given only access to that Node Example: Original List : ->1->2->8->3->7->0->4 After Deleting the mid node (say 7) :...

Objective: Given a linked list and integer ‘n’, write an algorithm to find the nth node from the end in the Linked List. Example: Original List : ->1->2->8->3->7->0->4 Output : 3rd Element from the...

Objective: Write a program to remove the duplicates from an unsorted linked list Example: Input Linked List : 1->2->2->4->3->3->2 Output : 1->2->4->3 Input: An unsorted linked list Output: Linked list with no duplicates. Approach:...

Objective: Write an algorithm to check if one string is Rotation of another string. This question has been asked in the Amazon interview. Example: Input Strings : ‘sumitjain’ and ‘tjainsumi’ Output : true Input...

Objective: Write an algorithm to compress the given string by using the count of repeated characters and if new compressed string length is not smaller than the original string then return the original string....

Objective: Write an algorithm to replace all spaces in a given string with ‘%20’. You can consider that string has enough space at the end of the string to hold the extra characters. Input:...

Objective: Given Two Strings, check whether one string is permutation of other Input: Two Strings Output: True or false based on whether strings are permutation of other or not. Example: “sumit” and “tiums” are...

Objective: Given Two linked list, check whether both list intersect each other, if yes then find the starting node of the intersection. Intersection point means end of one linked list is linked with some...

%d bloggers like this: