heaps

package
v0.0.0-...-7dccd96 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2016 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package heaps implements solutions for the problems described in the chapter Heaps of the book Elements of Programming Interview.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MedianStream

func MedianStream(in <-chan int, out chan<- *big.Rat)

MedianStream reads the stream of values from in channel, computes a median from first n read values, and write the result after every read entry to out channel. The time complexity per read entry is O(log(n)). The O(n) additional space is needed for the first n read entries.

func MergeSorted

func MergeSorted(ss [][]int) (m []int)

MergeSorted merges given slice of already sorted slices into one sorted slice. The time complexity is O(n*log(k)) where n is the total number of elements combining all slices together and k = len(ss). The O(k) additional space is needed (beyond the space needed to write the final result).

func SortK

func SortK(xs []int) []int

SortK sorts k-increasing-decreasing slice xs and returns the result. The time complexity is O(n*log(k)). Beyond the space needed to write the final result, the O(k) additional space is needed. The xs can be modified during the function execution.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL