Coder Social home page Coder Social logo

algorithm's Introduction

C++ implementations of algorithms

These are my C++ implementations of algorithms, which are written for studying/understanding algorithms.

These codes are published in public domain. You can use the codes for any purpose without any warranty.

author: Takanori MAEHARA (web: http://www.prefield.com, e-mail: [email protected], twitter: @tmaehara)

Recruiting

I am a researcher at RIKEN Center for Advanced Intelligence Project, which is a Japanese governmental academic research institute. I am working on discrete algorithms (including topics in this github repository). We are hiring strong programmers who has some achievements in some competitions. If you are interested in, please feel free to contact me.

algorithm's People

Contributors

msakai avatar sethwang10 avatar wang502 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  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  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  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  avatar

algorithm's Issues

Bug of Euler Tour Tree

Challenge case

int main() {
  euler_tour_tree ETT;

  auto a = ETT.make_node(1 << 0);
  auto b = ETT.make_node(1 << 1);
  auto c = ETT.make_node(1 << 2);

  auto ba = ETT.link(b, a);
  auto ca = ETT.link(c, a);
  ETT.cut(ba);

  // Now components are {a, c} and {b}.
  // Since b is a singleton component, there should be no child.
  cout << b->ch[0] << " " << b->ch[1] << endl; // expects 0 0

  // Something undefined happens...
  auto ab = ETT.link(a, b);
  cout << ETT.sum_in_component(a) << endl; // expects 0b111
  return 0;
}

Cause

Here's the current implementation of cut operation.

void cut(node *uv) {
splay(uv); disconnect(uv,1); splay(uv->r);
join(disconnect(uv,0), disconnect(uv->r,1));
delete uv, uv->r;
}

This implementation assumes that uv->r is in the right subtree of uv after splay(uv). This assumption is true right after link(u, v), but not maintained in the following operations.

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.