# Category Archives: Advanced Data Structure

## B-Tree | Set 1 (Introduction)April 21, 2013

B-Tree is a self-balancing search tree. In most of the other self-balancing search trees (like AVL and Red Black Trees), it is assumed that everything is in main memory. To understand use of B-Trees, we must think of huge amount of data that cannot fit in main memory.

## Largest Rectangular Area in a Histogram | Set 1April 8, 2013

Find the largest rectangular area possible in a given histogram where the largest rectangle can be made of a number of contiguous bars. For simplicity, assume that all bars have same width and the width is 1 unit.

## Skip List | Set 1 (Introduction)March 17, 2013

Can we search in a sorted linked list in better than O(n) time? The worst case search time for a sorted linked list is O(n) as we can only linearly traverse the list and cannot skip nodes while searching.

## Design an efficient data structure for given operationsFebruary 8, 2013

Design a Data Structure for the following operations. The data structure should be efficient enough to accommodate the operations according to their frequency.

## Segment Tree | Set 2 (Range Minimum Query)January 29, 2013

We have introduced segment tree with a simple example in the previous post. In this post, Range Minimum Query problem is discussed as another example where Segment Tree can be used.

## Segment Tree | Set 1 (Sum of given range)January 16, 2013

Let us consider the following problem to understand Segment Trees. We have an array arr[0 . . . n-1]. We should be able to 1 Find the sum of elements from index l to r where 0 <= l <= r <= n-1 2 Change value of a specified element of the array to a… Read More »

## Ternary Search TreeJanuary 13, 2013

A ternary search tree is a special trie data structure where the child nodes of a standard trie are ordered as a binary search tree.

## Pattern Searching | Set 8 (Suffix Tree Introduction)January 7, 2013

Given a text txt[0..n-1] and a pattern pat[0..m-1], write a function search(char pat[], char txt[]) that prints all occurrences of pat[] in txt[]. You may assume that n > m.

## Given a sequence of words, print all anagrams together | Set 2October 25, 2012

Given an array of words, print all anagrams together. For example, if the given array is {“cat”, “dog”, “tac”, “god”, “act”}, then output may be “cat tac act dog god”.

## Print unique rows in a given boolean matrixSeptember 28, 2012

Given a binary matrix, print all unique rows of the given matrix.

## Implement LRU Cache

How to implement LRU caching scheme? What data structures should be used? We are given total possible page numbers that can be referred. We are also given cache (or memory) size (Number of page frames that cache can hold at a time). The LRU caching scheme is to remove the least recently used frame when… Read More »