GithubHelp home page GithubHelp logo

wesley-a-leung / resources Goto Github PK

View Code? Open in Web Editor NEW
37.0 2.0 9.0 16.5 MB

Data Structures, Algorithms, Utility Classes for Competitive Programming, Codeforces: https://codeforces.com/profile/wleung_bvg, AtCoder: https://atcoder.jp/users/wleung_bvg, DMOJ: https://dmoj.ca/user/wleung_bvg

License: Creative Commons Zero v1.0 Universal

Java 0.60% C++ 98.78% Kotlin 0.32% Python 0.20% Shell 0.10%
competitive-programming data-structures algorithms icpc codeforces atcoder dmoj

resources's Introduction

ubuntu-build windows-build

Resources

Data Structures, Algorithms, Utility Classes

  • C++ Resources compile with g++-10 in C++11, C++14, C++17, and C++20 on Ubuntu and Windows
  • Java Resources compile in Java 8, Java 11
  • Kotlin Resources compile in Kotlin 1.5

Licensing

  • most files are covered under LICENSE.txt (Creative Commons Zero 1.0), with certain files being covered under a different license, which are listed below, and stated at the top of those files with the license files also being provided in their folders
Apache License 2.0
GNU General Public License 3.0

Style Guidelines

  • 79 character line limit unless the line contains the string http
  • 2 spaces for indentation
  • very compressed coding style to reduce wasted space in PDF, with multiple statements on a single line
  • if, else, for, while, etc ... statements should either be immediately followed by a single statement and a newline, a block wrapped in curly braces followed by a newline, a curly brace and a newline, or only a newline
  • short functions and blocks can be squeezed onto a single line wrapped in curly braces
  • all lines should end in \n
  • important variables and constants should be completely capitalized, classes and filename should be upper camel case, other variables and functions should be lower camel case, unless it is to match C++ STL conventions
  • otherwise mostly adheres to Google's Style Guide
  • templates should either be a standalone function, or a struct/class
  • functions and classes should have generic types if possible
  • classes should have constant parameters passed as template parameters if possible, variable parameters should be passed in the constructor
  • classes and functions should have a quick summary, specify conventions used, descriptions of template parameters, constructor arguments, member functions and fields, mention the constant factor (roughly) relative to its advertised time complexity, time complexity and memory complexity, and specify where it was tested
  • constant factors (very small, small, moderate, large, very large) roughly differ by factors of 10
  • if template parameters are non-trivial, those should be described as well, possibly with an example provided
  • std::vector is preferred over fixed-sized arrays and std::string, use std::vector::reserve if possible
  • the new operator should be avoided and memory should be allocated on the stack, or std::unique_ptr should be used

resources's People

Contributors

carson-tang avatar ninjaclasher avatar pidddgy avatar wesley-a-leung avatar zecookiez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

resources's Issues

Deque

Implement Deque Data Structure

Segment Tree

Implement New Segment Tree Class with Lazy Propagation and Reversions

Heaps

Add Binomial Heaps, Multiway Heaps
Add Max varients

Fix Removable Graphs

Implement adj using Bags
Implement removed using HashSets
Restore Edges method
Restore Single Edge method
Remove Vertex method
Restore Verticies method
Restore Single Vertex method
Fix edges counter

Gauss-Jordan Elimination

Implement Gauss-Jordan Elimination algorithm (or Gaussian Elimination because more efficient)

Treap

Implement Treap Data Structure

Matrix

Implement Matrix Data Structure

Binary Search Methods

Implement Binary search for lists, include upper bound, lower bound, and equals range

Mo

Implement Mo's Algorithm

Dinic Max Flow

Implement Dinic Max Flow Algorithm with Link Cut Tree

TimSort

Implement TimSort algorithm

Yen K Shortest Path

Implement Yen's K Shortest Path Algorithm
Pseudo-code:

function YenKSP(Graph, source, sink, K):
   // Determine the shortest path from the source to the sink.
   A[0] = Dijkstra(Graph, source, sink);
   // Initialize the heap to store the potential kth shortest path.
   B = [];
   
   for k from 1 to K:
       // The spur node ranges from the first node to the next to last node in the previous k-shortest path.
       for i from 0 to size(A[k − 1]) − 1:
           
           // Spur node is retrieved from the previous k-shortest path, k − 1.
           spurNode = A[k-1].node(i);
           // The sequence of nodes from the source to the spur node of the previous k-shortest path.
           rootPath = A[k-1].nodes(0, i);
           
           for each path p in A:
               if rootPath == p.nodes(0, i):
                   // Remove the links that are part of the previous shortest paths which share the same root path.
                   remove p.edge(i,i + 1) from Graph;
           
           for each node rootPathNode in rootPath except spurNode:
               remove rootPathNode from Graph;
           
           // Calculate the spur path from the spur node to the sink.
           spurPath = Dijkstra(Graph, spurNode, sink);
           
           // Entire path is made up of the root path and spur path.
           totalPath = rootPath + spurPath;
           // Add the potential k-shortest path to the heap.
           B.append(totalPath);
           
           // Add back the edges and nodes that were removed from the graph.
           restore edges to Graph;
           restore nodes in rootPath to Graph;
                   
       if B is empty:
           // This handles the case of there being no spur paths, or no spur paths left.
           // This could happen if the spur paths have already been exhausted (added to A), 
           // or there are no spur paths at all - such as when both the source and sink vertices 
           // lie along a "dead end".
           break;
       // Sort the potential k-shortest paths by cost.
       B.sort();
       // Add the lowest cost path becomes the k-shortest path.
       A[k] = B[0];
       B.pop();
   
   return A;

Binary Trees

Improve performance of Binary Search Trees, AVL Trees, Red Black Trees
Allow duplicates, add replace/set method

YenKSP

Optimize Yen's Algorithm

Javadocs

Javadocs for Java Utility Classes is incomplete

Lowest Common Ancestor

Implement LCA Algorithm with Euler, Heavy-light decomposition, and dynamic programming.

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.