Skip to main content

22 docs tagged with "Sort and Search"

View All Tags

Color Sort

Assume that we are given n pairs of items as input, where the first item is a

Find Transition Index

Given unbounded 0s followed by unbounded number of 1s, find the first index of transition.

Group Anagrams

Write a method to sort an array ot strings so that all tne anagrams are next to each other.

K Sorted List Merge

Give an O(n log k)-time algorithm that merges k sorted lists with a total of n

K Sum

Given a set S of n integers and an integer T,

Magic Index Search

[4-33] Algorithm to determine whether there exists an i index such as ai = i given array of {a1, a2, a3 ... an}

Rank From Stream

Imagine you are reading in a stream of integers. Periodically, you wish

Selection Sort

Identify the smallest element from unsorted portion and put it at the end of the sorted portion

Sorted Merge

You are given two sorted arrays, A and B, where A has a large enough buffer at the

Sparse Search

Given a sorted array of strings that is interspersed with empty strings, write a

Two Pair Sum

O(nlogn) algorithm for finding whether there exists a pair of elements, one from S1 and one