## Euclidean algorithm – Greatest Common Divisor(GCD)

The greatest common divisor (GCD) of two or more integers, when at least one of them is not zero, is the largest positive integer that divides the numbers without a remainder. For example, the...

@tutorialhorizon

The greatest common divisor (GCD) of two or more integers, when at least one of them is not zero, is the largest positive integer that divides the numbers without a remainder. For example, the...

Objective: Given a Linked List and x and y. Delete x number of nodes after y nodes from the start. Example: ->10->20->30->40->50->60->70->80->90->100->110->120 Deleted 4 Nodes after 5 Nodes ->10->20->30->40->50->100->110->120 Approach: We need two pointers....

Objective: – Given a Binary Search Tree, Do the Depth First Search/Traversal . Appraoch: Approach is quite simple, use Stack. First add the add root to the Stack. Pop out an element from Stack...

Objective: Given a array of unsorted numbers, check if all the numbers in the array are consecutive numbers. Examples: int [] arrA = {21,24,22,26,23,25}; – True (All the integers are consecutive from 21 to...

Objective: Given two sorted arrays, Find intersection point between them. Examples: int[] a = { 1, 2, 3, 6, 8, 10 }; int[] b = { 4, 5, 6, 11, 15, 20 }; Output:...

Objective: Given a binary tree, Convert it into its Mirror Tree Mirror Tree: Mirror Tree of a binary tree is where left and right child of every node of given binary tree is interexchanged....

Objective: Given a binary tree, Print All the Nodes that don’t have siblings. Note: sibling node is the node which has the same parent, so you need to print the nodes who is a...

Objective: Given Two binary Search Trees, Check if both are identical. Input: Two binary Search Trees Approach:

Objective: Given three sorted(ascending order) arrays of integers, find out all the common elements in them. Input: Three sorted arrays. Output: All the common elements. Examples : Array A = {1,2,3,4,5,6,7,8,9,10}; Array B =...

Objective: Given a sorted array of positive integers, find out the smallest integer which cannot be represented as the sum of any subset of the array Input: A Sorted Array Output: The smallest number...

Objective: Given a Binary tree, Find the size of the tree. Note : Size of the tree is number of nodes in the tree Input: A Binary Tree. Output: Size of the tree. Example...

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

Binary Tree : A data structure in which we have nodes containing data and two references to other nodes, one on the left and one on the right. Binary Tree consist of Nodes Nodes...

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: 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) :...

%d bloggers like this: