سԹ

Menu

Wananga landing Wananga landing
Topic

Algorithm and Data Structure Repository

28 August 2024

Developed for educational purposes, UC's Algorithm and Data Structure Repository provides example implementations of algorithms and data structures. There are various algorithms and data structures implemented in C. Learn more about the Algorithm Repository.

HOW TO APPLY

The downloads below provide a package containing all of the main algorithm repository's C source files.

A separate section of this repository specialises in shortest path algorithms and priority queues implemented in C++.

All algorithms and source files provided by this repository are subject to the disclaimer below.*

Main Repository

Please note that thetiming library can be used to test algorithims (C Source Files:)

Algorithms

Depth First Search and Breadth First Search

  • C source files:
  • Example program:

Tarjan's Algorithm (Strongly Connected Components)

  • C source files:
  • Example program:

Dijkstra's Algorithm

Two implementations are given which differ by the data structure used for the frontier set.

Implemented with a one-dimentional array:

  • C program source file:

Implemented with a heap:

  • C source files:
  • example program:

Floyd's Algorithm

  • C program source file:

Minimal Spanning Tree Algorithms

Currently only Prim's minimal spanning tree algorithm is implemented.

  • C source files:
  • Example program:

Maximum Flow Algorithms

The Ford and Fulkerson, Dinic, MPM, and Karzonov maximum flow algorithms are implemented.

  • C source files:
  • Example program:

  • C Source files:
  • Example program:

Someis available for a performance comparison of functions in sort.c, and the qsort() function provided by the C header <stdlib.h>.

Quicksort

Mergesort

Radix Sort

Heap Sort

  • C source files:
  • Example program:

Currently only binary search is implemented.

Convex Hulls

An implementation of Graham's scan for simple 2-dimensional convex hulls.

  • C source files:
  • Demonstration program (X Windows):
Data Structures

  • Directed graph C source files:
  • Undirected graph C source files:

These C source files are used by the graph algorithms in this repository.

Common Files

Aof all the heaps implemented is provided.

The header filedefines a common structure type for heaps so that they can be used interchangeably. A program which uses this common structure type is then able to use different heaps interchangeably. The heap implementation of Dijkstra's algorithm is an example of this.

  • Example program: []
  • Test data - using heaps in Dijkstra's algorithm:,

Binary Heap

  • C source files:

Fibonacci Heap

  • C source files:

2-3 Heap

The trees in a 2-3 heap can be viewed in two different ways, and this leads to two different 2-3 heap implementations.

Implemented using linked lists of child nodes:

  • C source files:
  • 2-3 heap representation using pointers: ()

Implemented using linked lists of child node-pairs:

  • C source files:
  • 2-3 heap representation using node-pair pointers: ()

In the node-pair implementation the linked list of child nodes is defined differently. Nodes have an extra pointer which points to an optional partner node with which the node forms a node-pair. Each node has a boolean field which identifies whether it is the "extra" node a node-pair.

Trinomial heap

The extended trinomial heap implementation supports O(1) worst case time for decrease_key:

  • C source files:
  • extended trinomial heap representation: ()

The basic trinomial heap implementation supports O(1) amortized time for decrease_key:

  • C source files:
  • basic trinomial heap representation: ()

Common Files

The header filedefines a common structure type that each dictionary can provide. A program which uses this common structure type is then able to use different dictionaries interchangeably, as done by the supplied example program.

  • Example program:
  • Experimental data:

Binary Search Tree

  • C source files:
  • Example program:

AVL Tree

  • C source files:
  • Example program:

2-3 Tree

Standard 2-3 tree:

  • C source files:
  • Example program:

Modified 2-3 tree, supporting delete_min() in O(1) worst case time:

  • C source files:
  • Example program:

Red-Black Tree

  • C source files:
  • Example program:

Hash Table

  • C source files:
  • Example program:

Skip List

  • C source files:
  • Example program:

Digital Search Tree

  • C source files:
  • Example program:
  • Pictures: () ()

Radix Search Trie

  • C source files:
  • Example program:
  • Pictures: () ()

Specialised Repositories

Shortest Path Algorithms and Priority Queues in C++

This secondary repository contains C++ implementations of shortest path algorithms and the priority queues that they use. A standard implementation of Dijkstra's algorithm is provided which is able to use the various priority queues interchangeably.

A standard implementation of directed graphs is used by Dijkstra's algorithm.

  • Directed graphs:

Various heaps for use in Dijkstra's algorithm are provided. These are all derived from a common base class.

  • Heap base class:

The individual heap implementations are given below:

  • Fibonacci heap:
  • 2-3 heap:
  • trinomial heap:
  • extended trinomial heap (with O(1) worst-case time for decrease-key operations):
  • radix heap:, ()

Since the radix heap works specifically with Dijkstra's algorithm, it is described separately from the other heaps. A description of other heaps can be found in thesection of the main algorithm repository

Dijkstra's algorithm was implemented with the ability to use any of the above heaps.

  • Dijkstra's algorithm:

Example Usage (Experiment Code)

The following example program demonstrates how to use the different heap implementations with Dijkstra's algorithm.

  • directed graph generation:
  • main program:

In addition, the following experiment code can be used to compare the different instances of Dijkstra's algorithm on different graphs.

  • directed graph providers:
  • experiment:
  • main program:

Algorithm Repository downloads

Files may only be downloaded in acceptance with the disclaimer.*

The entire algorithm repository source code and makefiles can be downloaded as a single package containing the directory structure expected by the source files. Alternatively, individual parts of the algorithm repository are available as separate packages. Individual C source files are viewable from the algorithm repository web pages. Afile is available, which gives an outline of source files in this repository and the directory structure used.

  • contains all of the algorithm repository source code and makefiles.

Algorithms

  • Graph algorithms:
  • Sorting algorithms:
  • Searching algorithms:

Data Structures

  • Graphs:- source files for graphs used by algorithms in this repository.
  • Heaps:
  • Dictionaries:

Related

  • Timing library:

  • Shortest Path Algorithms and Priority Queues in C++:

*Disclaimer:You agree that this repository contains non-commercially developed algorithms and that the source code and related files may contain errors. In no event will the provider of this repository be held responsible for any damages resulting from the source code and related files supplied by this repository or the use thereof. You acknowledge that you use all source code and related files supplied by this repository at you own risk.

Privacy Preferences

By clicking "Accept All Cookies", you agree to the storing of cookies on your device to enhance site navigation, analyse site usage, and assist in our marketing efforts.