Count Inversions of size three in a given array
Given an array arr[] of size n. Three elements arr[i], arr[j] and arr[k] form an inversion of size 3 if a[i] > a[j] >a[k] and… Read More »
Given an array arr[] of size n. Three elements arr[i], arr[j] and arr[k] form an inversion of size 3 if a[i] > a[j] >a[k] and… Read More »
Inversion Count for an array indicates – how far (or close) the array is from being sorted. If the array is already sorted then inversion… Read More »
The article describes an approach to solving the problem of finding the LCA of two nodes in a tree by reducing it to a RMQ… Read More »
We have an array arr[0 . . . n-1]. We should be able to efficiently find the minimum value from index L (query start) to… Read More »
Given an array of integers. find the maximum XOR subarray value in given array. Expected time complexity O(n). Examples: Input: arr[] = {1, 2, 3,… Read More »
We strongly recommend to refer set 1 as a prerequisite of this post. Treap (A Randomized Binary Search Tree) In this post, implementations of search,… Read More »
Like Red-Black and AVL Trees, Treap is a Balanced Binary Search Tree, but not guaranteed to have height as O(Log n). The idea is to… Read More »
Given an array of words, find all shortest unique prefixes to represent each word in the given array. Assume that no word is prefix of… Read More »
Heaps are mainly used for implementing priority queue. We have discussed below heaps in previous posts. Binary Heap Binomial Heap In terms of Time Complexity,… Read More »
We strongly recommend to refer below posts as a prerequisite of this. K Dimensional Tree | Set 1 (Search and Insert) K Dimensional Tree |… Read More »
We strongly recommend to refer below post as a prerequisite of this. K Dimensional Tree | Set 1 (Search and Insert) In this post find… Read More »
Segment tree is introduced in previous post with an example of range sum problem. We have used the same “Sum of given Range” problem to… Read More »
How to design a system that takes big URLs like “https://www.geeksforgeeks.org/count-sum-of-digits-in-numbers-from-1-to-n/” and converts them into a short 6 character URL. It is given that URLs… Read More »
Design a data structure that supports the following operations in Θ(1) time. insert(x): Inserts an item x to the data structure if not already present.… Read More »
Unlike C++ and Java, C doesn’t support generics. How to create a linked list in C that can be used for any data type? In… Read More »