stevenhalim / cpbook-code

CP4 Free Source Code Project (C++17, Java11, Python3 and OCaml)
2k stars 493 forks source link

Ocaml code and some minor improvements to code in other languages #65

Closed howsiwei closed 4 years ago

howsiwei commented 4 years ago

Too lazy to create many PRs. So I'll just make all the changes here if that's ok. @stevenhalim you can review and/or merge this PR anytime. Any code that is pushed here is more or less finalized.

stevenhalim commented 4 years ago

Noted @howsiwei , will let you populate this PR over weekend and review/merge in one go on Monday 13 Jul morning. Finalising ch9 content first.

howsiwei commented 4 years ago

The comment at https://github.com/stevenhalim/cpbook-code/blob/666991eaa9c08d22228ae469710b1176b35cd35e/ch2/ourown/fenwicktree_ds.cpp#L84-L85 feels misleading since rupq.point_query(j)*j is neither optimistic nor pessimistic, in the sense that it can be either large or smaller than the real value even if all values used in updates are positive. In fact, I always view -purq.rsq(j) as the main part and rupq.point_query(j)*j as the offset.

howsiwei commented 4 years ago

Done with this PR for now. Will continue next weekend if free.

stevenhalim commented 4 years ago

I will sync the writeup with your weekend contribution. Thanks. Getting close to full completion of OCaml translations.