search

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package search implements linear and binary search algorithms.

go test -bench=. search/*	# run tests and all benchmarks

See github.com/jreisinger/homepage/blob/master/notes/cs/big-o-notation.md for more.

Level: intermediate Topics: algorithms, testing, benchmarking

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Binary

func Binary(list []int, item int) int

Binary returns the smallest index of item from a *sorted* list or -1 if not found. Binary search is an O(log n) algorithm.

func Linear

func Linear(list []int, item int) int

Linear returns the smallest index of item from a list or -1 if not found. Linear (or simple) search is an O(n) algorithm.

Types

This section is empty.

Jump to

Keyboard shortcuts

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