explaingit

opengenus/cosmos

13,709C++Audience · developerComplexity · 1/5LicenseSetup · easy

TLDR

A community-maintained collection of algorithm and data structure implementations across 25+ computer science topics, with working code in C, C++, Java, Python, Go, JavaScript, and more.

Mindmap

mindmap
  root((cosmos))
    What it does
      Algorithm reference
      Multi-language code
      25 topic areas
    Tech Stack
      C++ and C
      Python and Java
      Go and JavaScript
    Audience
      CS students
      Interview preppers
      Contributors
    Use Cases
      Offline reference
      Language comparison
      Internship credit
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Browse offline reference implementations of sorting, searching, or graph algorithms in your preferred language

USE CASE 2

Study how the same algorithm is solved differently across C++, Python, Java, and Go side by side

USE CASE 3

Contribute an algorithm implementation to build open-source experience through the OpenGenus internship program

Tech stack

C++CJavaPythonGoJavaScriptSwift

Getting it running

Difficulty · easy Time to first run · 5min
You can use and share this code freely, but any project you build with it must also be released as open source under the same GPL v3 license.

In plain English

Cosmos is a large collection of algorithm and data structure implementations maintained by the OpenGenus community. The idea is to give programmers an offline reference covering the breadth of foundational computer science topics, with code written in multiple languages so you can see how the same problem is solved in C, C++, Java, Python, Go, JavaScript, Swift, and others. The repository is organized into around 25 broad topic areas: artificial intelligence, backtracking, bit manipulation, cellular automaton, compression, computational geometry, cryptography, data structures, design patterns, divide and conquer, dynamic programming, graph algorithms, greedy algorithms, mathematical algorithms, networking, numerical analysis, operating system concepts, quantum algorithms, randomized algorithms, searching, sorting, string algorithms, and several more. Each area contains many specific problems with working implementations in the supported languages. The project is contributor-driven. Over 1,000 people have added code to the repository, which is why the collection is large enough to serve as a self-contained offline reference. A small team of active maintainers reviews incoming contributions and keeps quality consistent. The wiki includes contributing guidelines and per-language style guides for anyone who wants to add implementations or documentation. OpenGenus also runs an internship program connected to this repository, where participants earn credit by making meaningful contributions. The code in Cosmos feeds into other OpenGenus products: a search engine called Quark and a knowledge platform called OpenGenus IQ, where the implementations appear alongside written explanations of each algorithm or data structure. The project is licensed under the GNU General Public License version 3. Sponsors include DigitalOcean and Discourse.

Copy-paste prompts

Prompt 1
Using the opengenus/cosmos coding style, write me a Python implementation of Dijkstra's shortest path algorithm with comments explaining each step
Prompt 2
Show me how to implement a red-black tree in C++ following the structure used in the cosmos repository
Prompt 3
I want to contribute a new sorting algorithm to opengenus/cosmos, write me a cycle sort implementation in Java that matches their conventions
Prompt 4
Using cosmos as a reference, show me BFS and DFS graph traversal implemented side by side in Go so I can see how they differ
Open on GitHub → Explain another repo

← opengenus on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.