bogosearch

package module
v0.0.0-...-26bd15c Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 1 Imported by: 0

README

Bogosearch

Overview

The bogosearch package implements a bogo approach to searching for a target value within an integer array.

Performance

Its bad

Alt text

Usage

go get github.com/rshcoding/bogosearch

Below is a simple example demonstrating how to use the Bogosearch:

package main

import (
    "fmt"
    "github.com/rshcoding/bogosearch"
)

func main() {
    arr := []int{5, 3, 7, 1, 4, 9, 8}
    target := 4
    index, found := bogosearch.Search(arr, target)
    if found {
        fmt.Printf("bogo found target %d at index %d.\n", target, index)
    } else {
        fmt.Println("bogo was unable to find target")
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Search(arr []int, target int) (int, bool)

Search attempts to find the target integer within the provided array. If the target is found, Search returns the original index of the target within arr and true; If the target is not found (i.e., arr becomes empty through reduction), it returns 0 and false.

Parameters: - arr: The array of integers to be searched. - target: The integer value to search for within arr.

Returns: - int: The original index of the target in the array if found; otherwise, returns 0. - bool: True if the target is found within the array; false if the target is not found.

Types

This section is empty.

Jump to

Keyboard shortcuts

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