Data Structures and Algorithms implementation in Go

Data Structures and Algorithms

Go Report Card Build Status License

Clean and simple implementation in Go

Implementation

There are several data structures and algorithms implemented in this project. The list will be replenished with time.

Data structures
  • Circular Buffer
  • Linked List
  • Doubly Linked List
  • Stack
  • Queue
  • Binary Tree
  • Hash Table
  • Trie
Searching algorithms
  • Linear Search
  • Binary Search
  • Jump Search
  • Interpolation Search
  • Exponential Search
  • Ternary Search
String searching algorithms
  • Naive String Search
  • Rabin-Karp Algorithm
Sorting algorithms
  • Selection Sort
  • Insertion Sort
  • Bubble Sort
  • Comb Sort
  • Cocktail Sort
  • Gnome Sort
  • Merge Sort

Usage

The library is not intended for direct use by importing. We strongly recommend copying the necessary implementations and adjusting to your case.

You can download the source using go get command:

go get github.com/floyernick/Data-Structures-and-Algorithms

Don't forget about proverb:

A little copying is better than a little dependency.

Contribute

We would be happy to receive your propositions of improvement! Read Contributing Guide for more details.

License

This project is licensed under the MIT License.

Authors

Mykyta Paliienko - GitHub profile

Owner
Comments
  • Binary search test polishing

    Binary search test polishing

    • Use "sort.Slice" for sorting.

    No need to write you own algorithm (unless you want to write tests for it too)

    • TableDriven test instead of random generator.

    Testing randomly generated slice by iterating over its elements is a strange idea. You will obviously get the expected result - you can't suddenly find something that wasn't already there or miss something that was.

    • Formatted Error message.

    You should provide some usefull info about the error. And "Fatal" has a different use case.

  • Make repo go get-able by adding a .go file to top folder level

    Make repo go get-able by adding a .go file to top folder level

    You need to make the top level of the repo a Go package in order to make it go get-able. Otherwise, it returns an error:

    package github.com/floyernick/Data-Structures-and-Algorithms: no Go files in /Users/philip/src/github.com/floyernick/Data-Structures-and-Algorithms
    

    It can as simple as a package declaration and it will work, i.e. in new file dsa.go at the top level of the package, just have a single line of package dsa and you're good to go.

  • Flaky test

    Flaky test

    https://github.com/floyernick/Data-Structures-and-Algorithms/blob/6ae8c0f2e09c371f47f2a3c76f3b73989e4f3c45/BinarySearch/BinarySearch_test.go#L21

    • This line could generate the number 0 in which case it would pass without making any verifications. suggest you add 10 to get some numbers.
  • Update MergeSort.go

    Update MergeSort.go

    make it faster than before

    Benchmark_MergeSort_new-12 10 102711316 ns/op Benchmark_MergeSort_new-12 10 102242814 ns/op Benchmark_MergeSort_new-12 10 104988258 ns/op Benchmark_MergeSort_old-12 3 338513872 ns/op Benchmark_MergeSort_old-12 4 334441485 ns/op Benchmark_MergeSort_old-12 3 334280000 ns/op

  • Implement MergeSort more concisely

    Implement MergeSort more concisely

    This version reslices the left and right arrays instead of passing around array indices. This feels like more idiomatic Go to me, but it might not follow the textbook version of mergesort as closely as the old version.

  • Items in README.md should be linked

    Items in README.md should be linked

    Data Structures and Algorithms

    Go Report Card Build Status License

    Clean and simple implementation in Go

    Implementation

    There are several data structures and algorithms implemented in this project. The list will be replenished with time.

    Data structures
  • Some Changes for MergeSort

    Some Changes for MergeSort

    #18 It Make MergeSort faster than before and I Commit a pull request. ———————————————————————————————————— Benchmark_MergeSort_new Benchmark_MergeSort_new-12 10 101394033 ns/op 209956300 B/op 1000041 allocs/op Benchmark_MergeSort_new-12 10 103156080 ns/op 209956320 B/op 1000041 allocs/op Benchmark_MergeSort_new-12 10 105631558 ns/op 209956272 B/op 1000041 allocs/op Benchmark_MergeSort_old Benchmark_MergeSort_old-12 4 322263281 ns/op 582174710 B/op 4052123 allocs/op Benchmark_MergeSort_old-12 3 333629871 ns/op 582175192 B/op 4052124 allocs/op Benchmark_MergeSort_old-12 3 350259903 ns/op 582174706 B/op 4052122 allocs/op

  • Optimize GetLast() in DoublyLinkedList

    Optimize GetLast() in DoublyLinkedList

    The GetLast() function traverses through the entire LL to get to the last pointer, when there's already a tail node. The fix gets rid of the traversal and returns the tail node value.

    func (list *LinkedList) GetLast() (int, bool) {
    	if list.head == nil {
    		return 0, false
    	}
    	return list.tail.data, true
    }
    
Data Structures and Algorithms implementation in Go

Data Structures and Algorithms Clean and simple implementation in Go Implementation There are several data structures and algorithms implemented in th

Jan 2, 2023
Graph algorithms and data structures
Graph algorithms and data structures

Your basic graph Golang library of basic graph algorithms Topological ordering, image by David Eppstein, CC0 1.0. This library offers efficient and we

Jan 2, 2023
Graph algorithms and data structures
Graph algorithms and data structures

Your basic graph Golang library of basic graph algorithms Topological ordering, image by David Eppstein, CC0 1.0. This library offers efficient and we

Jan 25, 2021
Algorithms and Data Structures Solved in Golang

Algorithms and Data Structures Solved in Golang Hi! I'm Bruno Melo and this repository contains a lot challenges solved on many plataforms using go as

Oct 20, 2022
Some data structures and algorithms using golang

Some data structures and algorithms using golang

Aug 13, 2022
Practice-dsa-go - Data Structures and Algorithms for Interview Preparation in Go

Data Structures and Algorithms for Interview Preparation in Go Data Structures K

Jul 3, 2022
Data Structures & Algorithms in Go

Data Structures and Algorithms with Go The aim of this repository is to provide Gophers with how data structures and algorithms are implemented in the

Dec 28, 2021
Grokking-algorithms-go - Solutions to common Data Structures problems

This is a repository dedicated to study, learn and solve Data Structure algorith

Apr 4, 2022
Golang string comparison and edit distance algorithms library, featuring : Levenshtein, LCS, Hamming, Damerau levenshtein (OSA and Adjacent transpositions algorithms), Jaro-Winkler, Cosine, etc...

Go-edlib : Edit distance and string comparison library Golang string comparison and edit distance algorithms library featuring : Levenshtein, LCS, Ham

Dec 20, 2022
Go translations of the algorithms and clients in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

Overview Go translations of the Java source code for the algorithms and clients in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin

Dec 13, 2022
Data Structure Libraries and Algorithms implementation

Algorithms Data Structure Libraries and Algorithms implementation in C++ Disclaimer This repository is meant to be used as a reference to learn data s

Dec 8, 2022
Basic Implementation of Data-structures in Go

Data structures in Go v1.15.6 This repo consists the implementation of the following: Stacks Queues Linked Lists (Singly) Binary Search Trees Heaps (M

May 24, 2021
Tutorial code for my video Learn to Use Basic Data Structures - Slices, Structs and Maps in Golang

Learn to Use Basic Data Structures - Slices, Structs and Maps in Golang Read text from a file and split into words. Introduction to slices / lists. Co

Jan 26, 2022
Go implementation of C++ STL iterators and algorithms.

iter Go implementation of C++ STL iterators and algorithms. Less hand-written loops, more expressive code. README translations: 简体中文 Motivation Althou

Dec 19, 2022
Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching.

Trie Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching. Usage Create a Trie with: t := trie.New() Add Keys with:

Dec 27, 2022
A tree like tool help you to explore data structures in your redis server
 A tree like tool help you to explore data structures in your redis server

Redis-view is a tree like tool help you explore data structures in your redis server

Mar 17, 2022
Probabilistic data structures for processing continuous, unbounded streams.

Boom Filters Boom Filters are probabilistic data structures for processing continuous, unbounded streams. This includes Stable Bloom Filters, Scalable

Dec 30, 2022
This is the course materials for the Go Data Structures Crash Course!

Go Data Structures Course ?? Welcome Gophers! This is the official repository that contains all of the data structures we cover in the Go Data Structu

May 10, 2022