Skip to content

Repository files navigation

Algorithms-Implementation

Abstract

Implementations of classic algorithms in computer science, mostly on graphs. Each algorithm lives in its own folder together with its source file and a README that documents the variables it uses, the parameters it takes and the results it produces.

Computes the shortest paths from a single source vertex to all the others in a weighted digraph. It is slower than Dijkstra, but it accepts negative edge weights and reports whether the graph contains a negative cycle.

Traverses a graph level by level, visiting every neighbour of a node before moving outwards, which also gives the shortest path in an unweighted graph.

Finds the bridges of an undirected graph, the edges whose removal breaks it into more components. They mark the fragile links of a network.

Traverses a graph by following each branch as far as it goes before backtracking to the last unexplored one.

Finds the shortest paths from one source node to every other node of a graph with non-negative edge weights.

A disjoint-set, or union-find, data structure that keeps a collection of elements partitioned into non-overlapping subsets, supporting a find and a merge operation.

Builds a minimum spanning tree with Kruskal's algorithm, connecting every vertex of a graph with the smallest possible total edge weight.

Four elementary sorting algorithms, each in its own file: bubble sort, insertion sort, selection sort and merge sort.

Looks for the shortest route that visits every city exactly once and returns to the origin, using a bitmask over the set of visited nodes to remember which ones are already covered.

To use this work on your researches or projects you need:

  • GNU (c++11 or higher)

To compile and run an algorithm:

From the folder of the algorithm you want to run:

g++ -std=c++11 Source.cpp
./a.out

The Sorting folder holds one file per algorithm, so compile the one you need instead:

g++ -std=c++11 MergeSort.cpp
./a.out

About

This repository will hold source codes for different classic algorithms in computer science

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages