GithubHelp home page GithubHelp logo

algorithms-in-go's Introduction

Algorithms Implemented in GO

Intro

A personal learning record.
All algorithms are Implemented in GO.

Resources & Test Cases

http://www.algorithmsilluminated.org/

Implemented Algorithms

Divide and Conquer

go run cmd/closest_pair/closest_pair.go
shows
5.0990195135927845

QuickSort (RandomPivot + In-place Partition)

go run cmd/sort/quick_sort.go
shows

Testcase 1:
25 comparisons (choose first as pivot)
31 comparisons (choose last as pivot)
24 comparisons (median of 3)
22 comparisons (random pivot)

Testcase 2:
620 comparisons (choose first as pivot)
573 comparisons (choose last as pivot)
507 comparisons (median of 3)
649 comparisons (random pivot)

Random Selection

go run cmd/random_selection/random_selection.go
shows

5469
4715

Deterministic Selection

go run cmd/deterministic_selection/deterministic_selection.go
shows

5469
4715

Random Selection

Strong Connected Components

go run cmd/scc/scc.go
shows top 5 SCC size

[3 3 3 0 0]
[3 3 2 0 0]
[3 3 1 1 0]
[7 1 0 0 0]
[6 3 2 1 0]

Strong Connected Components

Heap

go run cmd/test_heap/test_heap.go
shows a sorted order

1
3
4
5
7
10
100

Dijkstra Shortest Path

go run cmd/dijkstra_shortest_path/dijkstra_shortest_path.go
shows the shortest-path distances from vertex 1 to every other vertex

vertices: 1, shortest path: 0
vertices: 2, shortest path: 1
vertices: 3, shortest path: 2
vertices: 4, shortest path: 3
vertices: 5, shortest path: 4
vertices: 6, shortest path: 4
vertices: 7, shortest path: 3
vertices: 8, shortest path: 2

Median Maintenance

go run .\cmd\median_maintenance\median_maintenace.go
shows the last digits of all kth medians (one by one compute the median of array)

9335 (from 29335)
2408 (from 46842408)

Median Maintenance

algorithms-in-go's People

Contributors

james77777778 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.