Tutorialspoint.dev
Welcome To Tutorialspoint.dev
Officially launched 18th May 2019
Searching Binary Search Searching

Minimum time required to produce m items

Consider n machines which produce same type of items but at different rate i.e., machine 1 takes a1 sec to produce an item, machine 2 takes a2 sec to produce an item....
Advanced Data Structure Pattern Searching Suffix-Tree

Suffix Tree Application 4 – Build Linear Time Suffix Array

Given a string, build it’s Suffix Array We have already discussed following two ways of building suffix array: Naive O(n2Logn) algorithm Enhanced O(nLogn) alg...
Advanced Data Structure Competitive Programming Tree

Sqrt (or Square Root) Decomposition Set 2 (LCA of Tree in O(sqrt(height)) time)

Prerequisite : Introduction and DFS The task is to find LCA of two given nodes in a tree (not necessarily a Binary Tree). In previous posts, we have seen how to calcu...
Arrays rotation Arrays

Print left rotation of array in O(n) time and O(1) space

Given an array of size n and multiple values around which we need to left rotate the array. How to quickly print multiple left rotations? Examples : Input : arr[] = {...
Arrays Amazon array-rearrange

Rearrange positive and negative numbers in O(n) time and O(1) extra space

An array contains both positive and negative numbers in random order. Rearrange the array elements so that positive and negative numbers are placed alternatively. Num...
Searching Order-Statistics Quick Sort

K’th Smallest/Largest Element in Unsorted Array Set 2 (Expected Linear Time)

We recommend to read following post as a prerequisite of this post. K’th Smallest/Largest Element in Unsorted Array | Set 1 Given an array and a number k where...
Arrays Searching ABCO

K’th Smallest/Largest Element in Unsorted Array Set 3 (Worst Case Linear Time)

We recommend reading following posts as a prerequisite of this post. K’th Smallest/Largest Element in Unsorted Array | Set 1 K’th Smallest/Largest Eleme...
Arrays array-range-queries Directi

Constant time range add operation on an array

Given an array of size N which is initialized with all zeros. We are given many range add queries, which should be applied to this array. We need to print final updat...
Advanced Data Structure Searching Technical Scripter

XOR of numbers that appeared even number of times in given Range

Given an array of numbers of size N and Q queries. Each query or a range can be represented by L (LeftIndex) and R(RightIndex). Find the XOR-sum of the numbers that a...
Binary Search Tree Amazon Google

Find median of BST in O(n) time and O(1) space

Given a Binary Search Tree, find median of it. If no. of nodes are even: then median = ((n/2th node + (n+1)/2th node) /2 If no. of nodes are odd : then median = (n+1...

Subscribe to Our Newsletter