├── .gitignore ├── LICENSE ├── README.md ├── cpp ├── concurrency_and_parallelism.md ├── conferences.md ├── core_language.md ├── libraries_and_applications.md ├── modules_and_preprocessor.md ├── optimization_and_hardware.md ├── patterns_and_idioms.md ├── std_library.md ├── templates.md └── tools.md ├── data_structures_and_algorithms ├── backtracking.md ├── bit_algorithms.md ├── combinatorics.md ├── cryptographic.md ├── data_exchange.md ├── design_and_analysis.md ├── distributed.md ├── dynamic_programming.md ├── game_theory.md ├── geometric.md ├── graphs.md ├── hash_tables.md ├── heaps.md ├── lists.md ├── misc.md ├── numeric.md ├── optimization.md ├── parsing.md ├── random.md ├── sequence.md ├── signal_processing.md ├── sorting.md ├── string.md ├── tools.md └── trees.md ├── distributed_systems.md ├── general_reviews.md ├── hardware.md ├── low_level.md ├── people.md └── programming.md /.gitignore: -------------------------------------------------------------------------------- 1 | todo/ 2 | src/ 3 | /books.md 4 | chess.md 5 | system_design.md 6 | linux.md 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Data structures, algorithms, and C++ reference library 2 | 3 | :construction: A library of usefull and interesting references – web pages, videos, books, research papers – on common data structures and algorithms with an emphasis on C++ when it comes to their implementation. 4 | 5 | ## Table of contents 6 | 7 | - :heavy_plus_sign: C++ 8 | * :chestnut: [Core language](cpp/core_language.md) 9 | * :anchor: [The standard library and proposals](cpp/std_library.md) 10 | * :white_square_button: [Templates](cpp/templates.md) 11 | * :twisted_rightwards_arrows: [Concurrency and parallelism](cpp/concurrency_and_parallelism.md) 12 | * :rocket: [Optimization](cpp/optimization_and_hardware.md) 13 | * :bookmark_tabs: [Patterns, idioms, and design principles](cpp/patterns_and_idioms.md) 14 | * :hash: [Modules and preprocessor](cpp/modules_and_preprocessor.md) 15 | * :ferris_wheel: [Libraries and applications](cpp/libraries_and_applications.md) 16 | * :wrench: [Tools](cpp/tools.md) 17 | * :microphone: [Conferences](cpp/conferences.md) 18 | - :seedling: Data structures and algorithms 19 | * :microscope: [Design and analysis](data_structures_and_algorithms/design_and_analysis.md) 20 | * :keycap_ten: [Bit algorithms](data_structures_and_algorithms/bit_algorithms.md) 21 | * :1234: [Sequence data structures and algorithms](data_structures_and_algorithms/sequence.md) 22 | * :signal_strength: [Sorting and searching](data_structures_and_algorithms/sorting.md) 23 | * :left_right_arrow: [Lists](data_structures_and_algorithms/lists.md) 24 | * :deciduous_tree: [Trees](data_structures_and_algorithms/trees.md) 25 | * :hash: [Hash tables and hashing](data_structures_and_algorithms/hash_tables.md) 26 | * :top: [Heaps](data_structures_and_algorithms/heaps.md) 27 | * :curly_loop: [Graphs](data_structures_and_algorithms/graphs.md) 28 | * :abc: [String algorithms](data_structures_and_algorithms/string.md) 29 | * :exclamation: [Combinatorial algorithms](data_structures_and_algorithms/combinatorics.md) 30 | * :arrow_heading_up: [Backtracking](data_structures_and_algorithms/backtracking.md) 31 | * :rocket: [Optimization algorithms](data_structures_and_algorithms/optimization.md) 32 | * :triangular_ruler: [Geometric algorithms](data_structures_and_algorithms/geometric.md) 33 | * :symbols: [Parsers and compilers](data_structures_and_algorithms/parsing.md) 34 | * :satellite: [Data exchange and compression](data_structures_and_algorithms/data_exchange.md) 35 | * :chart_with_upwards_trend: [Digital signal processing](data_structures_and_algorithms/signal_processing.md) 36 | * :spades: [Game theory](data_structures_and_algorithms/game_theory.md) 37 | * :heavy_division_sign: [Numeric algorithms](data_structures_and_algorithms/numeric.md) 38 | * :lock: [Cryptographic algorithms](data_structures_and_algorithms/cryptographic.md) 39 | * :game_die: [Randomized algorithms and probabilistic data structures](data_structures_and_algorithms/random.md) 40 | * :sparkler: [Distributed algorithms](data_structures_and_algorithms/distributed.md) 41 | * :wrench: [Tools](data_structures_and_algorithms/tools.md) 42 | - :hammer: [Assembly, low-level programming, and OS internals](low_level.md) 43 | - :floppy_disk: [Hardware and hardware history](hardware.md) 44 | - :eight_spoked_asterisk: [Distributed systems and computer networks](distributed_systems.md) 45 | - :newspaper: [General reviews and interviews](general_reviews.md) 46 | * :computer: [Programming](programming.md) 47 | * :bust_in_silhouette: [People in computer science](people.md) 48 | -------------------------------------------------------------------------------- /cpp/concurrency_and_parallelism.md: -------------------------------------------------------------------------------- 1 | # Concurrency and parallelism 2 | 3 | ## Table of contents 4 | 5 | - [Introduction and overview](#introduction-and-overview) 6 | - [SIMD](#simd) 7 | - [SIMD within a register (SWAR)](#simd-within-a-register-swar) 8 | - [Multithreading](#multithreading) 9 | - [Concurrency and the standard library](#concurrency-and-the-standard-library) 10 | - [`std::atomic`](#stdatomic) 11 | - [`std::atomic_shared_ptr`](#stdatomic_shared_ptr) 12 | - [`std::condition_variable`](#stdcondition_variable) 13 | - [`std::mutex`](#stdmutex) 14 | - [`std::promise` / `std::future`](#stdpromise--stdfuture) 15 | - [`std::async`](#stdasync) 16 | - [`std::thread`](#stdthread) 17 | - [`std::lock_guard`](#stdlock_guard) 18 | - [Data races and race conditions](#data-races-and-race-conditions) 19 | - [Lock-based](#lock-based) 20 | - [Mutex locks](#mutex-locks) 21 | - [Spin locks](#spin-locks) 22 | - [Lock-free](#lock-free) 23 | - [Hazard pointers](#hazard-pointers) 24 | - [Read-copy-update (RCU)](#read-copy-update-rcu) 25 | - [Memory model](#memory-model) 26 | - [POSIX threads](#posix-threads) 27 | - [Coroutines](#coroutines) 28 | - [Executors](#executors) 29 | - [Concurrency patterns](#concurrency-patterns) 30 | - [GPU computing](#gpu-computing) 31 | 32 | --- 33 | 34 | ## Introduction and overview 35 | 36 | :link: 37 | 38 | - B.Barney. [*Introduction to parallel computing*](https://computing.llnl.gov/tutorials/parallel_comp/) – Lawrence Livermore National Laboratory 39 | 40 | --- 41 | 42 | 47 | 48 | --- 49 | 50 | ## SIMD 51 | 52 | :movie_camera: 53 | 54 | - B.Steagall. [*Adventures in SIMD-thinking*](https://www.youtube.com/watch?v=1FPobiebZLE) – CppNow (2021) 55 | - B.Steagall. *Adventures in SIMD-thinking* [Part I](https://www.youtube.com/watch?v=qejTqnxQRcw), [Part II](https://www.youtube.com/watch?v=qXleSwCCEvY) – CppCon (2020) 56 | 57 | ### SIMD within a register (SWAR) 58 | 59 | :link: 60 | 61 | - [*SWAR*](https://en.wikipedia.org/wiki/SWAR) – Wikipedia 62 | - H.Dietz. [Ch. 4: *SIMD within a register (e.g., using MMX)*](https://www.tldp.org/HOWTO/Parallel-Processing-HOWTO-4.html) – Linux parallel processing HOWTO 63 | - [*SIMD and SWAR techniques*](https://www.chessprogramming.org/SIMD_and_SWAR_Techniques) – Chess Programming Wiki 64 | 65 | :grey_question: 66 | 67 | - [*Is `reinterpret_cast`ing between hardware SIMD vector pointer and the corresponding type an undefined behavior?*](https://stackoverflow.com/q/52112605) – Stack Overflow 68 | - [*Is casting to simd-type undefined behaviour in C++?*](https://stackoverflow.com/questions/58910969) – Stack Overflow 69 | 70 | --- 71 | 72 | ## Multithreading 73 | 74 | :link: 75 | 76 | - E.Bendersky. [*C++11 threads, affinity and hyperthreading*](https://eli.thegreenplace.net/2016/c11-threads-affinity-and-hyperthreading/) (2016) 77 | 78 | :movie_camera: 79 | 80 | - A.Williams. [*An introduction to multithreading in C++20*](https://www.youtube.com/watch?v=A7sVFJLJM-A) – CppCon (2022) 81 | - F.Petriconi. [*An adventure in race conditions*](https://www.youtube.com/watch?v=asgO4P2fhTw) – ACCU (2019) 82 | - A.Sermersheim. *Multithreading is the answer. What is the question?* [Part I](https://www.youtube.com/watch?v=GNw3RXr-VJk), [Part II](https://www.youtube.com/watch?v=sDLQWivf1-I) – CppCon (2017) 83 | - R.Grimm. [*C++11 multithreading done right?*](https://www.youtube.com/watch?v=paK38WAq8WY) – Meeting C++ (2014) 84 | - A.Williams. [*The continuing future of C++ concurrency*](https://www.youtube.com/watch?v=FaHJOkOrfNo) – CppCon (2016) 85 | 86 | :book: 87 | 88 | - P.E.McKenney. [*Is parallel programming hard, and, if so, what can you do about it?*](https://mirrors.edge.kernel.org/pub/linux/kernel/people/paulmck/perfbook/perfbook.html) (2018) 89 | - A.Williams. [*C++ concurrency in action: Practical multithreading*](https://www.manning.com/books/c-plus-plus-concurrency-in-action-second-edition) (2019) 90 | - Ch. 9: *Parallelism and concurrency* – J.Galowicz. [*C++17 STL cookbook: Discover the latest enhancements to functional programming and lambda expressions*](https://www.packtpub.com/application-development/c17-stl-cookbook) (2017) 91 | - Ch. 18: *Concurrency* – N.M.Josuttis. [*The C++ standard library: A tutorial and reference*](http://www.cppstdlib.com/) (2012) 92 | 93 | :page_facing_up: 94 | 95 | - P.E.McKenney. [*Memory barriers: A hardware view for software hackers*](http://www.rdrop.com/~paulmck/scalability/paper/whymb.2010.06.07c.pdf) (2010) 96 | 97 | ### Concurrency and the standard library 98 | 99 | :link: 100 | 101 | - L.R.Teodorescu. [*A case against blind use of C++ parallel algorithms*](https://accu.org/journals/overload/29/161/teodorescu/) – [Overload **161**](https://accu.org/journals/overload/overload161) (2021) 102 | - A.Williams. [*Multi-threading in C++0x*](https://accu.org/journals/overload/17/93/williams_1584/) – [Overload **93**](https://accu.org/journals/overload/overload93) (2009) 103 | - [*C++11 standard library extensions: Concurrency*](https://isocpp.org/wiki/faq/cpp11-library-concurrency) – Standard C++ Foundation 104 | 105 | :movie_camera: 106 | 107 | - J.Machutová. [*Memory Model: Get your shared data under control*](https://www.youtube.com/watch?v=L5RCGDAan2Y) – C++ Meeting (2023) 108 | - A.Williams. [*An introduction to multithreading in C++20*](https://www.youtube.com/watch?v=A7sVFJLJM-A) – CppCon (2022) 109 | - M.Shah. [*Back to basics: Concurrency*](https://www.youtube.com/watch?v=pfIC-kle4b0) – CppCon (2021) 110 | - A.O’Dwyer. [*Back to basics: Concurrency*](https://www.youtube.com/watch?v=F6Ipn7gCOsY) – CppCon (2020) 111 | - B.A.Lelbach. [*The C++17 parallel algorithms library and beyond*](https://www.youtube.com/watch?v=Vck6kzWjY88) – CppCon (2016) 112 | - D.Kühl. [*C++17 parallel algorithms*](https://www.youtube.com/watch?v=Ve8cHE9LNfk) – CppCon (2017) 113 | 114 | #### `std::atomic` 115 | 116 | :grey_question: 117 | 118 | - [*Does `std::atomic::operator++` really return by value?*](https://stackoverflow.com/q/13231048) – Stack Overflow 119 | 120 | :movie_camera: 121 | 122 | - H.-J.Boehm. [*Using weakly ordered C++ atomics correctly*](https://www.youtube.com/watch?v=M15UKpNlpeM) – CppCon (2016) 123 | 124 | #### `std::atomic_shared_ptr` 125 | 126 | :link: 127 | 128 | - A.Williams. [*Why do we need `atomic_shared_ptr`?*](https://www.justsoftwaresolutions.co.uk/threading/why-do-we-need-atomic_shared_ptr.html) (2015) 129 | 130 | :grey_question: 131 | 132 | - [*What is the difference between `std::shared_ptr` and `std::experimental::atomic_shared_ptr`?*](https://stackoverflow.com/q/40223599) – Stack Overflow 133 | 134 | #### `std::condition_variable` 135 | 136 | > The `std::condition_variable` is a synchronization primitive that can be used to block a thread, or multiple threads at the same time, until another thread both modifies a shared variable (the condition), and notifies the `std::condition_variable`. 137 | 138 | :grey_question: 139 | 140 | - [*Shared atomic variable is not properly published if it is not modified under mutex*](https://stackoverflow.com/q/38147825) – Stack Overflow 141 | 142 | :anchor: 143 | 144 | - [`std::condition_variable`](https://en.cppreference.com/w/cpp/thread/condition_variable) – C++ reference 145 | 146 | #### `std::mutex` 147 | 148 | > The `std::mutex` class is a synchronization primitive that can be used to protect shared data from being simultaneously accessed by multiple threads. 149 | 150 | :grey_question: 151 | 152 | - [*Move constructor for `std::mutex`*](https://stackoverflow.com/q/7557179) – Stack Overflow 153 | - [*Why is `std::mutex::unlock()` not `noexcept`*](https://stackoverflow.com/q/38450189) – Stack Overflow 154 | 155 | :anchor: 156 | 157 | - [*`std::mutex`*](https://en.cppreference.com/w/cpp/thread/mutex) – C++ reference 158 | 159 | #### `std::promise` / `std::future` 160 | 161 | > The `std::promise` provides a facility to store a value or an exception that is later acquired asynchronously via a `std::future` object created by the `std::promise` object. 162 | 163 | :grey_question: 164 | 165 | - [*What is `std::promise`?*](https://stackoverflow.com/q/11004273) – Stack Overflow 166 | - [*Futures vs. promises*](https://stackoverflow.com/q/12620186) – Stack Overflow 167 | - [*Why we need both `std::promise` and `std::future`?*](https://stackoverflow.com/q/34169602) – Stack Overflow 168 | 169 | :anchor: 170 | 171 | - [`std::promise`](https://en.cppreference.com/w/cpp/thread/promise) – C++ reference 172 | 173 | #### `std::async` 174 | 175 | :link: 176 | 177 | - E.Bendersky. [*The promises and challenges of `std::async` task-based parallelism in C++11 *](https://eli.thegreenplace.net/2016/the-promises-and-challenges-of-stdasync-task-based-parallelism-in-c11/) (2016) 178 | - M.Nelson. [*C++11’s `async` template*](https://www.drdobbs.com/cpp/c11s-async-template/240001196) – Dr.Dobb’s Journal (2012) 179 | 180 | :grey_question: 181 | 182 | - [*`std::async` won’t spawn a new thread when return value is not stored*](https://stackoverflow.com/q/9490405) – Stack Overflow 183 | 184 | :anchor: 185 | 186 | - N.Josuttis. [*Why deprecating `async()` is the worst of all options*](https://wg21.link/n3780) – WG21/N3780 187 | - H.-J.Boehm. [*`async()` future destructors must wait*](https://wg21.link/n3679) – WG21/N3679 188 | - H.Sutter. [*`async` and `~future`*](https://wg21.link/n3451) – WG21/N3451 189 | 190 | #### `std::thread` 191 | 192 | :anchor: 193 | 194 | - H.-J.Boehm. [*A plea to reconsider detach-on-destruction for thread objects*](https://wg21.link/n2802) – WG21/N2802 195 | 196 | #### `std::lock_guard` 197 | 198 | :grey_question: 199 | 200 | - [*Why is `std::lock_guard` not movable?*](https://stackoverflow.com/q/22502606) – Stack Overflow 201 | 202 | :anchor: 203 | 204 | - [*`std::lock_guard`*](https://en.cppreference.com/w/cpp/thread/lock_guard) – C++ reference 205 | 206 | ### Data races and race conditions 207 | 208 | :grey_question: 209 | 210 | - [*Are “data races” and “race condition” actually the same thing in context of concurrent programming*](https://stackoverflow.com/q/11276259) – Stack Overflow 211 | 212 | ### Lock-based 213 | 214 | #### Mutex locks 215 | 216 | :link: 217 | 218 | - S.Ignatchenko. [*5 big fat reasons why mutexes suck big time*](https://accu.org/journals/overload/27/149/ignatchenko_2623/) – [Overload **149**](https://accu.org/journals/overload/overload149) (2019) 219 | - M.Spertus. [*Thread-safe copy and move constructors*](https://www.justsoftwaresolutions.co.uk/threading/thread-safe-copy-constructors.html) (2011) 220 | 221 | #### Spin locks 222 | 223 | 224 | 225 | :link: 226 | 227 | - [*When should one use a spinlock instead of mutex?*](https://stackoverflow.com/q/5869825) – Stack Overflow 228 | - [*Spinlock versus semaphore*](https://stackoverflow.com/q/195853) – Stack Overflow 229 | 230 | ### Lock-free 231 | 232 | > Lock-free programming is a set of techniques for writing concurrent programs without using explicit locks. 233 | 234 | :movie_camera: 235 | 236 | - F.Pikus. [*C++ atomics, from basic to advanced: What do they really do?*](https://www.youtube.com/watch?v=ZQFzMfHIxng) – CppCon (2017) 237 | - F.Pikus. *Live lock-free or deadlock (practical lock-free programming).* [Part I](https://www.youtube.com/watch?v=lVBvHbJsg5Y), [Part II](https://www.youtube.com/watch?v=1obZeHnAwz4) – CppCon (2015) 238 | - H.Sutter. *`atomic<>` weapons:* [Part I](https://www.youtube.com/watch?v=A8eCGOqgvH4), [Part II](https://www.youtube.com/watch?v=KeLBd2EJLOU) – C++ and Beyond (2012) 239 | 240 | #### Hazard pointers 241 | 242 | :link: 243 | 244 | - [*Hazard pointer* – Wikipedia](https://en.wikipedia.org/wiki/Hazard_pointer) 245 | - A.Alexandrescu, M.Michael. [*Lock-free data structures with hazard pointers*](http://www.drdobbs.com/lock-free-data-structures-with-hazard-po/184401890) – Dr.Dobb’s Journal (2004) 246 | 247 | #### Read-copy-update (RCU) 248 | 249 | :link: 250 | 251 | - [*Read-copy-update*](https://en.wikipedia.org/wiki/Read-copy-update) – Wikipedia 252 | - P.E.McKenney. [*Introduction to RCU*](http://www2.rdrop.com/users/paulmck/RCU/) 253 | 254 | :movie_camera: 255 | 256 | - F.Pikus. [*Read, copy, update, then what? RCU for non-kernel programmers*](https://www.youtube.com/watch?v=rxQ5K9lo034) – CppCon (2017) 257 | - P.E.McKenney. [*A lock-free concurrency toolkit for deferred reclamation and optimistic speculation*](https://www.youtube.com/watch?v=uhgrD_B1RhQ&t=2289) – CppCon (2016) 258 | 259 | :anchor: 260 | 261 | - P.E.McKenney et al. [*Proposed RCU C++ API*](https://wg21.link/p0461) – WG21/P0461 262 | - P.E.McKenney. [*Read-copy update (RCU) for C++*](https://wg21.link/p0279) – WG21/P0279 263 | 264 | ### Memory model 265 | 266 | :link: 267 | 268 | - [*C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?*](https://stackoverflow.com/q/6319146) – Stack Overflow 269 | 270 | :anchor: 271 | 272 | - [*Memory model*](https://en.cppreference.com/w/cpp/language/memory_model) – C++ reference 273 | 274 | ### POSIX threads 275 | 276 | :link: 277 | 278 | - B.Barney. [*POSIX threads programming*](https://computing.llnl.gov/tutorials/pthreads/) 279 | 280 | :grey_question: 281 | 282 | - [*When to use `pthread_exit()` and when to use `pthread_join()` in Linux?*](https://stackoverflow.com/q/20824229) – Stack Overflow 283 | 284 | 293 | 294 | ### Coroutines 295 | 296 | :movie_camera: 297 | 298 | - R.Barkan. [*Coroutine intuition in C++*](https://www.youtube.com/watch?v=2jzuuOeUDQI) – C++ on Sea (2023) 299 | - J.McNellis. [*Introduction to C++ coroutines*](https://www.youtube.com/watch?v=ZTqHjjm86Bw) – CppCon (2016) 300 | 301 | ### Executors 302 | 303 | :movie_camera: 304 | 305 | - E.Niebler. *Working with asynchrony generically: A tour of C++ executors*. [Part I](https://www.youtube.com/watch?v=xLboNIf7BTg), [Part II](https://www.youtube.com/watch?v=6a0zzUBUNW4) – CppCon (2021) 306 | - D.Vollmann. [*Executors for C++ – A Long story ...*](https://www.youtube.com/watch?v=sAJGoHN6Xx8) – CppCon (2015) 307 | 308 | ### Concurrency patterns 309 | 310 | See [*Concurrency patterns* – Patterns, idioms, and design principles](patterns_and_idioms.md#concurrency-patterns). 311 | 312 | --- 313 | 314 | ## GPU computing 315 | 316 | :movie_camera: 317 | 318 | - P.Steinbach. [*C++ on GPUs done right?*](https://www.youtube.com/watch?v=z43l_LaOqnM) – Meeting C++ (2015) 319 | -------------------------------------------------------------------------------- /cpp/conferences.md: -------------------------------------------------------------------------------- 1 | # C++ conferences 2 | 3 | :link: 4 | 5 | - [CppCon](https://www.youtube.com/channel/UCMlGfpWw-RUdWX_JbLCukXg) 6 | - [C++Now / BoostCon](https://www.youtube.com/channel/UC5e__RG9K3cHrPotPABnrwg) 7 | - [Meeting C++](https://www.youtube.com/user/MeetingCPP) 8 | - [Pacific++](https://www.youtube.com/channel/UCrRR5mU5aqvtZAuEGYfdTjw) 9 | - [code::dive](https://www.youtube.com/channel/UCU0Rt8VHO5-YNQXwIjkf-1g) 10 | - [ACCU](https://www.youtube.com/channel/UCJhay24LTpO1s4bIZxuIqKw) 11 | - [Sweden C++](https://www.youtube.com/channel/UC_LAXFBuK7J2J6NLiYzdPEA) 12 | - [C++ on Sea](https://www.youtube.com/@cpponsea2834) 13 | - [CppNorth](https://www.youtube.com/@cppnorth) 14 | -------------------------------------------------------------------------------- /cpp/libraries_and_applications.md: -------------------------------------------------------------------------------- 1 | # Libraries and applications 2 | 3 | ## Table of contents 4 | 5 | - [Dimensional analysis](#dimensional-analysis) 6 | - [Boost.Units](#boostunits) 7 | - [mp-units](#mp-units) 8 | - [Boost](#boost) 9 | - [Boost.Iterator](#boostiterator) 10 | - [Boost.SmartPtr](#boostsmartptr) 11 | - [`boost::intrusive_ptr`](#boostintrusive_ptr) 12 | - [Applications](#applications) 13 | - [Space industry](#space-industry) 14 | - [Robotics](#robotics) 15 | 16 | --- 17 | 18 | ## Dimensional analysis 19 | 20 | ### Boost.Units 21 | 22 | > The Boost.Units library is an implementation of dimensional analysis in a general and extensible manner, treating it as a generic compile-time metaprogramming problem. Support for units and quantities (defined as a unit and associated value) for arbitrary unit system models and arbitrary value types is provided, as is a fine-grained general facility for unit conversions. 23 | 24 | ### mp-units 25 | 26 | :link: 27 | 28 | - [*`mp-units` – A physical quantities and units library for C++*](https://github.com/mpusz/mp-units) 29 | 30 | :movie_camera: 31 | 32 | - M.Pusz. [*`mp-units`: Lessons learned and a new C++ library design*](https://www.youtube.com/watch?v=l0rXdJfXLZc) – ACCU (2023) 33 | 34 | --- 35 | 36 | ## Boost 37 | 38 | :link: 39 | 40 | - [Boost library incubator](http://blincubator.com/) 41 | 42 | ### Boost.Iterator 43 | 44 | :anchor: 45 | 46 | - [*Boost.Iterator: The iterator library*](https://www.boost.org/doc/libs/release/libs/iterator/) 47 | 48 | ### Boost.SmartPtr 49 | 50 | :anchor: 51 | 52 | - [*Boost.SmartPtr: The smart pointer library*](https://www.boost.org/doc/libs/release/libs/smart_ptr/) 53 | 54 | #### `boost::intrusive_ptr` 55 | 56 | > The `boost::intrusive_ptr` class is a smart pointer that stores a pointer to an object with an embedded reference count, which is managed somewhere outside the smart pointer. 57 | 58 | :link: 59 | 60 | - B.Wicht. [*Boost `intrusive_ptr`: Faster shared pointer*](https://baptiste-wicht.com/posts/2011/11/boost-intrusive_ptr.html) (2011) 61 | 62 | :grey_question: 63 | 64 | - [*Boost intrusive pointer*](https://stackoverflow.com/q/40137660) – Stack Overflow 65 | 66 | :anchor: 67 | 68 | - [*`intrusive_ptr`*](https://www.boost.org/doc/libs/release/libs/smart_ptr/smart_ptr.htm#intrusive_ptr) – Boost.SmartPtr 69 | - I.Muerte. [*An intrusive smart pointer*](https://wg21.link/p0468) – WG21/P0468 70 | 71 | --- 72 | 73 | ## Applications 74 | 75 | ### Space industry 76 | 77 | :movie_camera: 78 | 79 | - P.Nyman. [*C++ in space*](https://www.youtube.com/watch?v=VxNVGVW9nyI) – Sweden C++ (2023) 80 | - J.Arrieta. [*Traveling the Solar system with C++: Programming rocket science*](https://www.youtube.com/watch?v=YXs3DFrZZL4) – CppCon (2017) 81 | 82 | ### Robotics 83 | 84 | - S.Brawner. [*Robotics at compile time: Optimizing robotics algorithms with C++’s compile-time features*](https://www.youtube.com/watch?v=Y6AUsB3RUhA) – CppCon (2023) 85 | -------------------------------------------------------------------------------- /cpp/modules_and_preprocessor.md: -------------------------------------------------------------------------------- 1 | # Modules and preprocessor 2 | 3 | - [Modules](#modules) 4 | - [Preprocessor](#preprocessor) 5 | - [`#include` directive](#include-directive) 6 | - [Variadic macros](#variadic-macros) 7 | - [X-Macros](#x-macros) 8 | 9 | --- 10 | 11 | ## Modules 12 | 13 | :link: 14 | 15 | - N.Sidwell. [*C++ modules: A brief tour*](https://accu.org/journals/overload/28/159/sidwell/) – [Overload **159**](https://accu.org/journals/overload/overload159) (2020) 16 | - B.Kolpackov. [*Common C++ modules TS misconceptions*](https://build2.org/article/cxx-modules-misconceptions.xhtml) (2020) 17 | - B.Kolpackov. [*Modules introduction*](https://build2.org/build2/doc/build2-build-system-manual.xhtml#cxx-modules) – [The `build2` build system](https://build2.org/build2/doc/build2-build-system-manual.xhtml#cxx-modules) 18 | 19 | :movie_camera: 20 | 21 | - S.Downey. [*Writing a C++20 module*](https://www.youtube.com/watch?v=AO4piAqV9mg) – C++Now (2021) 22 | - B.Kolpackov. [*Building C++ modules*](https://www.youtube.com/watch?v=E8EbDcLQAoc) – CppCon (2017) 23 | 24 | --- 25 | 26 | ## Preprocessor 27 | 28 | :link: 29 | 30 | - A.Karpov. [*Macro evil in C++ code*](https://arne-mertz.de/2019/03/macro-evil/) (2019) 31 | 32 | :grey_question: 33 | 34 | - [*Overloading macro on number of arguments*](https://stackoverflow.com/q/11761703) – Stack Overflow 35 | - [*What is the value of an undefined constant used in `#if`?*](https://stackoverflow.com/q/5085392) – Stack Overflow 36 | - [*What is the worst real-world macros/pre-processor abuse you’ve ever come across?*](https://stackoverflow.com/q/652788/) – Stack Overflow 37 | 38 | :movie_camera: 39 | 40 | - B.Ruth. [*The preprocessor: Everything you need to know and more!*](https://www.youtube.com/watch?v=ElkTaRHZz18) – CppCon (2021) 41 | - J.Jagger. [*Everything you’ve ever wanted to know about the C/C++ preprocessor but didn’t know you couldn ask!*](https://www.youtube.com/watch?v=OAuRkAAh6Hk) – NDC Techtown (2018) 42 | - A.Deutsch. [*Preprocessor 101*](https://www.youtube.com/watch?v=qBJaM8ki7bM) – DigiPen Game Engine Architecture Club (2016) 43 | 44 | ### `#include` directive 45 | 46 | - A.Knatten. [*Another reason to avoid `#include`s in headers*](https://blog.knatten.org/2012/11/09/another-reason-to-avoid-includes-in-headers/#comment-25982) (2012) 47 | 48 | ### Variadic macros 49 | 50 | :anchor: 51 | 52 | - T.Köppe. [*Comma omission and comma deletion*](https://wg21.link/p0306) – WG21/P00306 53 | 54 | ### X-Macros 55 | 56 | :link: 57 | 58 | - [*X Macro*](https://en.wikipedia.org/wiki/X_Macro) – Wikipedia 59 | - [*X-Macros*](https://en.wikibooks.org/wiki/C_Programming/Preprocessor_directives_and_macros#X-Macros) – WikiBooks 60 | - A.Lucas. *Reduce C-language coding errors with X macros.* [Part I](https://www.embedded.com/reduce-c-language-coding-errors-with-x-macros-part-1/), [Part II](https://www.embedded.com/reduce-c-language-coding-errors-with-x-macros-part-2/), [Part III](https://www.embedded.com/reduce-c-language-coding-errors-with-x-macros-part-3/) (2013) 61 | 62 | :grey_question: 63 | 64 | - [*Real-world use of X-Macros*](https://stackoverflow.com/q/6635851) – Stack Overflow 65 | - -------------------------------------------------------------------------------- /cpp/optimization_and_hardware.md: -------------------------------------------------------------------------------- 1 | # Optimization 2 | 3 | ## Table of contents 4 | 5 | - [Optimizations](#optimizations) 6 | - [Branch prediction](#branch-prediction) 7 | - [`[[likely]]` / `[[unlikely]]` attributes](#likely--unlikely-attributes) 8 | - [`likely` / `unlikely` Linux kernel macros](#likely--unlikely-linux-kernel-macros) 9 | - [Memory](#memory) 10 | - [Memory copying](#memory-copying) 11 | - [Memory allocation](#memory-allocation) 12 | - [Memory relocation](#memory-relocation) 13 | - [Memory access](#memory-access) 14 | - [Nested `std::vector`s](#nested-stdvectors) 15 | - [Aliasing](#aliasing) 16 | - [Floating-point arithmetic](#floating-point-arithmetic) 17 | - [Integral arithmetic](#integral-arithmetic) 18 | - [Integral multiplication](#integral-multiplication) 19 | - [Integeral division](#integeral-division) 20 | - [Empty base class optimization (EBO)](#empty-base-class-optimization-ebo) 21 | - [Return value optimization and copy elision](#return-value-optimization-and-copy-elision) 22 | - [Tail call optimisation](#tail-call-optimisation) 23 | - [Devirtualization](#devirtualization) 24 | - [Undefined behavior](#undefined-behavior) 25 | - [Infinite loops](#infinite-loops) 26 | - [Strict aliasing rule](#strict-aliasing-rule) 27 | - [Benchmarking](#benchmarking) 28 | - [Profiling](#profiling) 29 | - [Interaction with hardware](#interaction-with-hardware) 30 | 31 | --- 32 | 33 | ## Optimizations 34 | 35 | See also [*Optimizations* – Compilers](../data_structures_and_algorithms/parsing.md#optimizations). 36 | 37 | :link: 38 | 39 | - [*Optimizing C++*](https://en.wikibooks.org/wiki/Optimizing_C%2B%2B) – WikiBooks 40 | - A.O’Dwyer. [*`[[trivial_abi]]` 101*](https://quuxplusone.github.io/blog/2018/05/02/trivial-abi-101/) 41 | 42 | :grey_question: 43 | 44 | - [*Can `const`-correctness improve performance?*](https://stackoverflow.com/q/3435026) – Stack Overflow 45 | - [*Why does this loop produce “warning: iteration 3u invokes undefined behavior” and output more than 4 lines?*](https://stackoverflow.com/q/24296571) – Stack Overflow 46 | - [*What is tail call optimization?*](https://stackoverflow.com/q/310974) – Stack Overflow 47 | - [*Is premature optimization really the root of all evil?*](https://softwareengineering.stackexchange.com/q/80084) – Software Engineering 48 | 49 | :movie_camera: 50 | 51 | - A.Lachmish. [*Algorithmic complexity, data locality, parallelism, and compiler optimizations, seasoned with some concurrency*](https://www.youtube.com/watch?v=0iXRRCnurvo) – CppCon (2022) 52 | - J.Bielak. [*The most important otimizations to apply in your C++ programs*](https://www.youtube.com/watch?v=qCjEN5XRzHc) – CppCon (2022) 53 | - A.Alexandrescu. [*Speed is found in the minds of people*](https://www.youtube.com/watch?v=FJJTYQYB1JQ) – CppCon (2019) 54 | - H.Matthews. [*Optimising a small real-world C++ application*](https://www.youtube.com/watch?v=fDlE93hs_-U) – ACCU (2019) 55 | - H.Matthews. [*Optimising a small real-world C++ application*](https://www.youtube.com/watch?v=IGFBCvroXJ8) – NDC (2018) 56 | - H.Matthews. [*C++ performance and optimisation*](https://www.youtube.com/watch?v=eICYHA-eyXM) – NDC (2017) 57 | - F.Pikus. [*Design for performance*](https://www.youtube.com/watch?v=m25p3EtBua4) – CppCon (2018) 58 | - C.Bay. [*The CPU cache: Instruction re-ordering made obvious*](https://www.youtube.com/watch?v=tNkVUIv2gEE) – C++Now (2016) 59 | - C.Carruth. [*Understanding compiler optimization*](https://www.youtube.com/watch?v=haQ2cijhvhE) – code::dive (2016) 60 | - C.Cook. [*The speed game: Automated trading systems in C++*](https://www.youtube.com/watch?v=ulOLGX3HNCI) – Meeting C++ (2016) 61 | - T.Doumler. [*Want fast C++? Know your hardware!*](https://www.youtube.com/watch?v=BP6NxVxDQIs) – CppCon (2016) 62 | - A.Alexandrescu. [*Optimization tips*](https://www.youtube.com/watch?v=Qq_WaiwzOtI) – CppCon (2014) 63 | - M.Godbolt. [*x86 internals for fun & profit*](https://www.youtube.com/watch?v=hgcNM-6wr34) – GOTO (2014) 64 | - S.Meyers. [*CPU caches and why you care*](https://www.youtube.com/watch?v=WDIkqP4JbkE) – code::dive (2014) 65 | 66 | :book: 67 | 68 | - Col. 9: *Code tuning* – J.Bentley. [*Programming pearls*](https://www.oreilly.com/library/view/programming-pearls-second/9780134498058/) (1999) 69 | 70 | :anchor: 71 | 72 | - [*Intel 64 and IA-32 architectures optimization reference manual*](https://www-ssl.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-optimization-manual.html) 73 | 74 | ### Branch prediction 75 | 76 | :link: 77 | 78 | - [*Branch predictor*](https://en.wikipedia.org/wiki/Branch_predictor) – Wikipedia 79 | 80 | #### `[[likely]]` / `[[unlikely]]` attributes 81 | 82 | > These attributes allow the compiler to optimize for the case where paths of execution are more or less likely than any alternative path of execution. 83 | 84 | :grey_question: 85 | 86 | - [*How to use C++20’s `likely`/`unlikely` attributes in `if-else` statement*](https://stackoverflow.com/q/51797959) – Stack Overflow 87 | 88 | 89 | 90 | :anchor: 91 | 92 | - [*C++ attribute: `likely`, `unlikely`*](https://en.cppreference.com/w/cpp/language/attributes/likely) – C++ reference 93 | 94 | #### `likely` / `unlikely` Linux kernel macros 95 | 96 | :grey_question: 97 | 98 | - [*How do the `likely`/`unlikely` macros in the Linux kernel work and what is their benefit?*](https://stackoverflow.com/q/109710) – Stack Overflow 99 | 100 | ### Memory 101 | 102 | :link: 103 | 104 | - J.Müller. [*`malloc()` and `free()` are a bad API*](https://www.foonathan.net/2022/08/malloc-interface/) (2022) 105 | 106 | #### Memory copying 107 | 108 | :link: 109 | 110 | - [*Time to revisit `REP MOVS`*](https://software.intel.com/en-us/forums/intel-fortran-compiler/topic/275765) – Intel Developer Zone (2006) 111 | 112 | :grey_question: 113 | 114 | - [*Enhanced `REP MOVSB` for `memcpy`*](https://stackoverflow.com/q/43343231) – Stack Overflow 115 | - [*What setup does `REP` do?*](https://stackoverflow.com/q/33902068) – Stack Overflow 116 | - [*Why are complicated `memcpy`/`memset` superior?*](https://stackoverflow.com/q/8858778) – Stack Overflow 117 | 118 | #### Memory allocation 119 | 120 | See also [*Allocators* – The standard library and proposals](std_library.md#allocators). 121 | 122 | :link: 123 | 124 | - N.Fitzgerald. [*Always bump downwards*](https://fitzgeraldnick.com/2019/11/01/always-bump-downwards.html) (2019) 125 | 126 | :grey_question: 127 | 128 | - [*Is the compiler allowed to optimize out heap memory allocations?*](https://stackoverflow.com/q/31873616) – Stack Overflow 129 | 130 | :movie_camera: 131 | 132 | - S.Al Bahra, H.Sowa, P.Khuong. [*What programmers should know about memory allocation*](https://www.youtube.com/watch?v=gYfd25Bdmws) – CppCon (2019) 133 | - J.Lakos. *Local (“arena”) memory allocators.* [Part I](https://www.youtube.com/watch?v=nZNd5FjSquk), [Part II](https://www.youtube.com/watch?v=CFzuFNSpycI) – CppCon (2017) 134 | - J.Lakos. [*Local (“arena”) memory allocators*](https://www.youtube.com/watch?v=d1DpVR0tw0U) – ACCU (2017) 135 | - A.Alexandrescu. [*`std::allocator` is to allocation what `std::vector` is to vexation*](https://www.youtube.com/watch?v=LIb3L4vKZ7U) – CppCon (2015) 136 | 137 | #### Memory relocation 138 | 139 | :link: 140 | 141 | - A.O’Dwyer. [*Announcing “trivially relocatable”*](https://quuxplusone.github.io/blog/2018/07/18/announcing-trivially-relocatable/) (2018) 142 | 143 | :movie_camera: 144 | 145 | - A.O’Dwyer. [*Trivially relocatable*](https://www.youtube.com/watch?v=SGdfPextuAU) – C++Now (2019) 146 | 147 | :anchor: 148 | 149 | - A.O’Dwyer. [*Object relocation in terms of move plus destroy*](https://wg21.link/p1144) – WG21/P1144 150 | 151 | #### Memory access 152 | 153 | :grey_question: 154 | 155 | - [*Why is transposing a matrix of `512x512` much slower than transposing a matrix of `513x513`?*](https://stackoverflow.com/q/11413855) – Stack Overflow 156 | - [*Why are elementwise additions much faster in separate loops than in a combined loop?*](https://stackoverflow.com/q/8547778) – Stack Overflow 157 | - [*Why don’t C++ compilers optimize this conditional boolean assignment as an unconditional assignment?*](https://stackoverflow.com/q/40303182) – Stack Overflow 158 | 159 | #### Nested `std::vector`s 160 | 161 | :grey_question: 162 | 163 | - [*Is it a good idea to use `vector>` to form a matrix class for high performance scientific computing code?*](https://scicomp.stackexchange.com/questions/3159/is-it-a-good-idea-to-use-vectorvectordouble-to-form-a-matrix-class-for-high/3162) – Computational Science 164 | - [*Performance impact of nested vectors vs. contiguous arrays*](https://stackoverflow.com/q/45747848) – Stack Overflow 165 | - [*Using nested vectors vs a flatten vector wrapper, strange behaviour*](https://stackoverflow.com/q/33093860) – Stack Overflow 166 | 167 | #### Aliasing 168 | 169 | See also [*Type-punning* – Core language](core_language.md#type-punning). 170 | 171 | :movie_camera: 172 | 173 | - R.Barkan. [*Aliasing: Risks, opportunities and techniques*](https://www.youtube.com/watch?v=zHkmk1Y-gqM) – CppCon (2022) 174 | - R.Barkan. [*Aliasing: Risks, opportunities and techniques*](https://www.youtube.com/watch?v=1eAERikCzVg) – C++ on Sea (2022) 175 | 176 | ### Floating-point arithmetic 177 | 178 | :link: 179 | 180 | - K.Walfridsson. [*Optimizations enabled by `-ffast-math`*](https://kristerw.github.io/2021/10/19/fast-math/) (2021) 181 | 182 | :grey_question: 183 | 184 | - [*What does gcc’s `ffast-math` actually do?*](https://stackoverflow.com/q/7420665) – Stack Overflow 185 | 186 | :anchor: 187 | 188 | - [Bug 323: *Optimized code gives strange floating point results*](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323) – GCC Bugzilla 189 | 190 | ### Integral arithmetic 191 | 192 | :grey_question: 193 | 194 | - [*What is the performance impact of using `int64_t` instead of `int32_t` on 32-bit systems?*](https://stackoverflow.com/q/16841382) – Stack Overflow 195 | 196 | #### Integral multiplication 197 | 198 | :grey_question: 199 | 200 | - [*Why is `imul` used for multiplying unsigned numbers?*](https://stackoverflow.com/q/42587607) – Stack Overflow 201 | 202 | #### Integeral division 203 | 204 | :link: 205 | 206 | - D.W.Jones. [*Reciprocal multiplication, a tutorial*](https://homepage.divms.uiowa.edu/~jones/bcd/divide.html) (1999) 207 | - T.Granlund, P.L.Montgomery. [*Division by invariant integers using multiplication*](https://gmplib.org/~tege/divcnst-pldi94.pdf) (1994) 208 | 209 | :grey_question: 210 | 211 | - [*Why does GCC use multiplication by a strange number in implementing integer division?*](https://stackoverflow.com/q/41183935) – Stack Overflow 212 | - [*Why does the compiler generate a right-shift by 31 bits when dividing by 2?*](https://stackoverflow.com/q/40638335) – Stack Overflow 213 | 214 | ### Empty base class optimization (EBO) 215 | 216 | > Empty base class optimization allows the size of an empty base subobject to be zero. Empty base optimization is required for standard layout types. 217 | > ```cpp 218 | > struct Empty {}; 219 | > static_assert(sizeof(Empty) >= 1); 220 | > 221 | > struct Derived : Empty { 222 | > T i; 223 | > }; 224 | > static_assert(sizeof(Derived) == sizeof(T)); 225 | > ``` 226 | 227 | :link: 228 | 229 | - N.C.Myers. [*The “empty member” C++ optimization*](https://www.drdobbs.com/cpp/the-empty-member-c-optimization/184410250) ([mirror](http://www.cantrip.org/emptyopt.html)) – Dr.Dobb’s Journal (1997) 230 | - [*Empty base optimization*](https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Empty_Base_Optimization) – WikiBooks 231 | - [*`boost::compressed_pair`*](https://www.boost.org/doc/libs/release/libs/utility/compressed_pair.htm) 232 | - [*`boost::empty_value`*](https://www.boost.org/doc/libs/release/libs/core/doc/html/core/empty_value.html) 233 | 234 | :movie_camera: 235 | 236 | - J.Berg. [*Empty objects*](https://www.youtube.com/watch?v=vKDQxhyyMr8) – Sweden C++ (2023) 237 | 238 | :book: 239 | 240 | - Sec. 21.1: *The empty base class optimization*, Sec. 25.5.1: *Tuples and the EBCO* – D.Vandevoorde, N.M.Josuttis, D.Gregor. [*C++ templates: The complete guide*](http://www.tmplbook.com/) – [Addison-Wesley](https://www.informit.com/store/c-plus-plus-templates-the-complete-guide-9780321714121) (2017) 241 | 242 | :anchor: 243 | 244 | - [*Empty base optimization*](https://en.cppreference.com/w/cpp/language/ebo) – C++ reference 245 | 246 | ### Return value optimization and copy elision 247 | 248 | :link: 249 | 250 | - R.Chen. [*On harmful overuse of `std::move`*](https://devblogs.microsoft.com/oldnewthing/20231124-00/?p=109059) (2023) 251 | - A.Fertig. [*Why you should use `std::move` only rarely*](https://andreasfertig.blog/2022/02/why-you-should-use-stdmove-only-rarely/) (2022) 252 | 253 | :movie_camera: 254 | 255 | - A.O’Dwyer. [*The complete guide to `return x;`*](https://www.youtube.com/watch?v=OGKAJD7bmr8) – C++Now (2021) 256 | - J.Kalb. [*Copy elision*](https://www.youtube.com/watch?v=fSB57PiXpRw) – C++Now (2018) 257 | 258 | :anchor: 259 | 260 | - [*Copy elision*](https://en.cppreference.com/w/cpp/language/copy_elision) – C++ reference 261 | 262 | ### Tail call optimisation 263 | 264 | :link: 265 | 266 | - A.O’Dwyer. [*It’s not always obvious when tail-call optimization is allowed*](https://quuxplusone.github.io/blog/2021/01/09/tail-call-optimization/) (2021) 267 | - A.Balaam. [*Tail call optimisation in C++*](https://accu.org/journals/overload/20/109/balaam_1914/) – [Overload **109**](https://accu.org/journals/overload/overload109) (2012) 268 | 269 | ### Devirtualization 270 | 271 | :link: 272 | 273 | - A.O’Dwyer. [*When can the C++ compiler devirtualize a call?*](https://quuxplusone.github.io/blog/2021/02/15/devirtualization/) (2021) 274 | 275 | ### Undefined behavior 276 | 277 | :link: 278 | 279 | - T.Chatzigiannakis. [*Undefined behavior can literally erase your hard disk*](https://blog.tchatzigiannakis.com/undefined-behavior-can-literally-erase-your-hard-disk/) (2017) 280 | - K.Walfridsson. [*How undefined signed overflow enables optimizations in GCC*](https://kristerw.blogspot.com/2016/02/how-undefined-signed-overflow-enables.html) (2016) 281 | - K.Walfridsson. [*Dangling pointers and undefined behavior*](https://kristerw.blogspot.com/2016/04/dangling-pointers-and-undefined-behavior.html) (2016) 282 | - K.Walfridsson. [*Pointer comparison — an invalid optimization in GCC*](https://kristerw.blogspot.com/2016/12/pointer-comparison-invalid-optimization.html) (2016) 283 | - J.Regehr. [*Finding undefined behavior bugs by finding dead code*](https://blog.regehr.org/archives/970) (2013) 284 | - C.Lattner. *What every C programmer should know about undefined behavior.* [Part I](http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html), [Part II](http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_14.html), [Part III](http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_21.html) – LLVM project (2013) 285 | - O.Maudel. [*Demons may fly out of your nose*](https://accu.org/journals/overload/21/115/maudel_1857/) – [Overload **115**](https://accu.org/journals/overload/overload115) (2013) 286 | - M.Shroyer. [*Both true and false: A Zen moment with C*](https://markshroyer.com/2012/06/c-both-true-and-false/) (2012) 287 | 288 | 289 | 290 | :movie_camera: 291 | 292 | - F.Pikus. [*Undefined behavior in C++: What every programmer should know and fear*](https://www.youtube.com/watch?v=k9N8OrhrSZw) – CppCon (2023) 293 | - A.Meredith. [*Removing needless undefined behavior for a safer C++*](https://www.youtube.com/watch?v=iY7ft98nM2k) – ACCU (2023) 294 | - A.Sermersheim, B.Geller. [*Back to basics: Undefined behavior*](https://www.youtube.com/watch?v=NpL9YnxnOqM) – CppCon (2021) 295 | - J.Regehr. [*Undefined behavior and compiler optimizations*](https://www.youtube.com/watch?v=AeEwxtEOgH0) – C++Now (2018) 296 | - B.Geller, A.Sermersheim. [*Undefined behavior is not an error*](https://www.youtube.com/watch?v=XEXpwis_deQ) – CppCon (2018) 297 | - P.Padlewski. [*Undefined behaviour is awesome!*](https://www.youtube.com/watch?v=ehyHyAIa5so) – CppCon (2017) 298 | - M.Spencer. [*My little optimizer: Undefined behavior is magic*](https://www.youtube.com/watch?v=g7entxbQOCc) – CppCon (2016) 299 | 300 | #### Infinite loops 301 | 302 | See also [*Infinite loop* – Patterns, idioms, and design principles](patterns_and_idioms.md#infinite-loop). 303 | 304 | :grey_question: 305 | 306 | - [*Optimizing away a `while(1);` in C++0x*](https://stackoverflow.com/q/3592557) – Stack Overflow 307 | 308 | :movie_camera: 309 | 310 | - O.Giroux. [*Forward progress in C++*](https://www.youtube.com/watch?v=CuWM-OrPitw) – CppNorth (2022) 311 | 312 | :anchor: 313 | 314 | - H.-J. Boehm. [*Why undefined behavior for infinite loops?*](https://wg14.link/n1528) – WG14/N1528 315 | - JF.Bastien. [*Trivial infinite loops are not Undefined Behavior*](https://wg14.link/p2809) – WG14/P2809 316 | 317 | #### Strict aliasing rule 318 | 319 | See [*Type-punning* – Core language](core_language.md#type-punning). 320 | 321 | --- 322 | 323 | ## Benchmarking 324 | 325 | :link: 326 | 327 | - D.Ferenc. [*Contractual loopholes*](https://accu.org/journals/overload/25/138/ferenc_2363/) – [Overload **138**](https://accu.org/journals/overload/overload138) (2017) 328 | 329 | --- 330 | 331 | ## Profiling 332 | 333 | :movie_camera: 334 | 335 | - M.Ropert. [*The basics of profiling*](https://www.youtube.com/watch?v=dToaepIXW4s) – CppCon (2021) 336 | 337 | --- 338 | 339 | ## Interaction with hardware 340 | 341 | :movie_camera: 342 | 343 | - J.Erickson. [*Leveraging C++20/23 features for low level interactions*](https://www.youtube.com/watch?v=RzO7s-RbLwk) – CppCon (2024) 344 | - D.Saks. [*Writing better embedded software*](https://www.youtube.com/watch?v=3VtGCPIoBfs) – Meeting C++ (2018) 345 | - K.Smith. [*C++ hardware register access*](https://www.youtube.com/watch?v=lrrQaa_-hzU) – CppCon (2014) 346 | -------------------------------------------------------------------------------- /cpp/templates.md: -------------------------------------------------------------------------------- 1 | # Templates 2 | 3 | ## Table of contents 4 | 5 | - [Introduction and overview](#introduction-and-overview) 6 | - [Applications](#applications) 7 | - [Template arguments](#template-arguments) 8 | - [Argument deduction](#argument-deduction) 9 | - [Class template argument deduction (CTAD)](#class-template-argument-deduction-ctad) 10 | - [Deduction guides](#deduction-guides) 11 | - [Concepts](#concepts) 12 | - [Standard concepts](#standard-concepts) 13 | - [Applications](#applications-1) 14 | - [Function templates](#function-templates) 15 | - [Friend function templates](#friend-function-templates) 16 | - [Parsing and compilation](#parsing-and-compilation) 17 | - [Optimization](#optimization) 18 | - [`extern template`](#extern-template) 19 | - [Two-phase lookup](#two-phase-lookup) 20 | - [Keywords `template` and `typename` as disambiguators](#keywords-template-and-typename-as-disambiguators) 21 | - [SFINAE](#sfinae) 22 | - [Detection idiom](#detection-idiom) 23 | - [Specialization](#specialization) 24 | - [Explicit instantiation](#explicit-instantiation) 25 | - [Tuples](#tuples) 26 | - [Type lists](#type-lists) 27 | - [Type traits](#type-traits) 28 | - [Variadic templates](#variadic-templates) 29 | - [Fold expressions](#fold-expressions) 30 | 31 | --- 32 | 33 | ## Introduction and overview 34 | 35 | :link: 36 | 37 | - S.Golodetz. [*Functional programming using C++ templates (Part I)*](https://accu.org/journals/overload/15/81/golodetz_1422/) – [Overload **81**](https://accu.org/journals/overload/overload81) (2007) 38 | - S.Golodetz. [*Functional programming using C++ templates (Part II)*](https://members.accu.org/index.php/journals/1616) – [Overload **82**](https://accu.org/journals/overload/overload82) (2007) 39 | 40 | :grey_question: 41 | 42 | - [*Templates*](https://isocpp.org/wiki/faq/templates) – C++ FAQ 43 | 44 | :movie_camera: 45 | 46 | - J.Hagins. [*Template metaprogramming: Practical application*](https://www.youtube.com/watch?v=4YC6_77-iEY) – CppCon (2021) 47 | - H.Matthews. [*The C++ type system is your friend*](https://www.youtube.com/watch?v=MCiVdu7gScs) – ACCU (2017) 48 | - W.E.Brown. *Modern template metaprogramming: A compendium.* [Part I](https://www.youtube.com/watch?v=Am2is2QCvxY), [Part II](https://www.youtube.com/watch?v=a0FliKwcwXE) – CppCon (2014) 49 | - A.Modell. [*C++ advanced topics in templates*](https://www.youtube.com/watch?v=X30OwlsMWak) – Tech Talk (2014) 50 | - M.Caisse. *Introduction to modern C++ techniques.* [Part I](https://www.youtube.com/watch?v=9TFV2JxX7L0), [Part II](https://www.youtube.com/watch?v=urshrBatNo4) – C++Now (2012) 51 | 52 | :page_facing_up: 53 | 54 | - B.Stroustrup. [*Parameterized types for C++*](https://www.usenix.org/legacy/publications/compsystems/1989/win_stroustrup.pdf) – Computing System **2**, 55 (1989) 55 | 56 | :book: 57 | 58 | - D.Vandevoorde, N.M.Josuttis, D.Gregor. [*C++ templates: The complete guide*](http://www.tmplbook.com/) – [Addison-Wesley](https://www.informit.com/store/c-plus-plus-templates-the-complete-guide-9780321714121) (2017) 59 | - A.Alexandrescu. [*Modern C++ design: Generic programming and design patterns applied*](http://erdani.com/index.php/books/modern-c-design/) – [Addison-Wesley](https://www.informit.com/store/modern-c-plus-plus-design-generic-programming-and-design-9780201704310) (2001) 60 | 61 | ### Applications 62 | 63 | :movie_camera: 64 | 65 | - J.Gopel. [*Using modern C++ to eliminate virtual functions*](https://www.youtube.com/watch?v=gTNJXVmuRRA) – CppCon (2022) 66 | 67 | --- 68 | 69 | ## Template arguments 70 | 71 | :link: 72 | 73 | - J.Müller. [*Tricks with default template arguments*](https://foonathan.net/2020/10/tricks-default-template-argument/) (2020) 74 | 75 | ### Argument deduction 76 | 77 | :grey_question: 78 | 79 | - [*What is a nondeduced context?*](https://stackoverflow.com/q/25245453) – Stack Overflow 80 | 81 | :movie_camera: 82 | 83 | - S.Meyers. [*Type deduction and why you care*](https://www.youtube.com/watch?v=wQxj20X-tIU) – CppCon (2014) 84 | 85 | :anchor: 86 | 87 | - [*Template argument deduction*](https://en.cppreference.com/w/cpp/language/template_argument_deduction) – C++ reference 88 | 89 | #### Class template argument deduction (CTAD) 90 | 91 | :link: 92 | 93 | - A.O’Dwyer. [*Beware CTAD on `reverse_iterator`*](https://quuxplusone.github.io/blog/2022/08/02/reverse-iterator-ctad/) (2022) 94 | - A.O’Dwyer. [*Thoughts on `-Wctad-maybe-unsupported`*](https://quuxplusone.github.io/blog/2022/10/07/wctad-maybe-unsupported/) (2022) 95 | - R.Orr. [*CTAD – What is this new acronym all about?*](https://accu.org/journals/overload/26/143/orr_2465/) – [Overload **143**](https://accu.org/journals/overload/overload143) (2019) 96 | 97 | :grey_question: 98 | 99 | - [*Is `std::make_move_iterator` redundant since C++17’s class template argument deduction?*](https://stackoverflow.com/q/57762121) – Stack Overflow 100 | 101 | :movie_camera: 102 | 103 | - M.Clow. [*Class template argument deduction: History, how to ise it, and how to enable it for your classes*](https://www.youtube.com/watch?v=EPfPMW-rOtc) – CppCon (2022) 104 | - T.Doumler. [*Class template argument deduction in C++17*](https://www.youtube.com/watch?v=UDs90b0yjjQ) – CppCon (2018) 105 | - T.Doumler. [*Class template argument deduction in C++17*](https://www.youtube.com/watch?v=STJExxBU54M) – ACCU (2018) 106 | - S.T.Lavavej. [*Class template argument deduction for everyone*](https://www.youtube.com/watch?v=-H-ut6j1BYU) – CppCon (2018) 107 | - Z.Yuan. [*Class template argument deduction: A new abstraction*](https://www.youtube.com/watch?v=4X8gXzi8bx8) – CppCon (2017) 108 | 109 | :anchor: 110 | 111 | - M.Spertus, F.Vali, R.Smith. [*Template argument deduction for class templates*](https://wg21.link/p0091) – WG21/P0091 112 | 113 | #### Deduction guides 114 | 115 | :grey_question: 116 | 117 | - [*What are template deduction guides and when should we use them?*](https://stackoverflow.com/q/40951697) – Stack Overflow 118 | 119 | :anchor: 120 | 121 | - [*Deduction for class templates*](https://en.cppreference.com/w/cpp/language/class_template_argument_deduction#Deduction_for_class_templates) – C++ reference 122 | 123 | --- 124 | 125 | ## Concepts 126 | 127 | See also [*Concepts* – The standard library and proposals](core_language.md#concepts). 128 | 129 | :link: 130 | 131 | - A.Krzemieński. [*Concepts – case studies*](https://akrzemi1.wordpress.com/2021/09/16/concepts-case-studies/) (2021) 132 | - A.Krzemieński. [*Semantic requirements in concepts*](https://akrzemi1.wordpress.com/2020/10/26/semantic-requirements-in-concepts/) (2020) 133 | - A.Sutton. [*Defining concepts*](https://accu.org/journals/overload/24/131/sutton_2198/) – [Overload **131**](https://accu.org/journals/overload/overload131) (2016) 134 | - A.Sutton. [*Introducing concepts*](https://accu.org/journals/overload/23/129/sutton_2157/) – [Overload **129**](https://accu.org/journals/overload/overload129) (2015) 135 | 136 | :grey_question: 137 | 138 | - [*How will concepts lite interact with universal references?*](https://stackoverflow.com/q/29182279) – Stack Overflow 139 | - [*Why does `same_as` concept check type equality twice?*](https://stackoverflow.com/q/58509147) – Stack Overflow 140 | 141 | :movie_camera: 142 | 143 | - J.Garland. *Using concepts: C++ design in a concept world.* [Part I](https://www.youtube.com/watch?v=Ffu9C1BZ4-c), [Part II](https://www.youtube.com/watch?v=IXbf5lxGtr0) – C++Now (2021) 144 | - R.Barkan. [*Semantic sugar: Tips for effective template library APIs*](https://www.youtube.com/watch?v=u0rvEMV8Qq4) – C++Now (2021) 145 | - H.Matthews. [*C++ concepts for developers*](https://www.youtube.com/watch?v=ut40iShzqEY) – NDC (2019) 146 | - R.Grimm. [*Concepts in C++20: Revolution or evolution*](https://www.youtube.com/watch?v=BXBnAmqZvpo) – CppCon (2019) 147 | - B.Stroustrup. [*Concepts: The future of generic programming (the future is here)*](https://www.youtube.com/watch?v=HddFGPTAmtU) – CppCon (2018) 148 | 149 | :anchor: 150 | 151 | - W.E.Brown. [*`enable_if` vs.`requires`: A case study*](https://wg21.link/p0552) – WG21/P0552 152 | 153 | ### Standard concepts 154 | 155 | :grey_question: 156 | 157 | - [*Why is the `std::derived_from` concept implemented with an additional convertibility test that adds cv-qualifiers?*](https://stackoverflow.com/q/65915059) – Stack Overflow 158 | 159 | ### Applications 160 | 161 | :link: 162 | 163 | - A.Fertig. [*C++20 concepts applied – Safe bitmasks using scoped enums*](https://andreasfertig.blog/2024/01/cpp20-concepts-applied/) (2024) 164 | 165 | --- 166 | 167 | ## Function templates 168 | 169 | :link: 170 | 171 | - H.Sutter. [*Why not specialize function templates?*](http://www.gotw.ca/publications/mill17.htm) 172 | 173 | :grey_question: 174 | 175 | - [*Necessity of forward-declaring template functions*](https://stackoverflow.com/q/7255281) – Stack Overflow 176 | 177 | :movie_camera: 178 | 179 | - B.Saks. [*Back to basics: Function call resolution in C++*](https://www.youtube.com/watch?v=ab_RzvGAS1Q) – CppCon (2024) 180 | - W.E.Brown. [*C++ function templates: How do they really work?*](https://www.youtube.com/watch?v=nfIX8yWlByY) – C++ on Sea (2019) 181 | - W.E.Brown. [*C++ function templates: How do they really work?*](https://www.youtube.com/watch?v=NIDEjY5ywqU) – CppCon (2018) 182 | 183 | ### Friend function templates 184 | 185 | :grey_question: 186 | 187 | - [*Why do I get linker errors when I use template friends?*](https://isocpp.org/wiki/faq/templates#template-friends) – C++ FAQ 188 | - [*Correct syntax for friend template function*](https://stackoverflow.com/q/42692050) – Stack Overflow 189 | 190 | :movie_camera: 191 | 192 | - D.Saks. [*Making new friends*](https://www.youtube.com/watch?v=POa_V15je8Y&t=1854s) – CppCon (2018) 193 | 194 | --- 195 | 196 | ## Parsing and compilation 197 | 198 | :link: 199 | 200 | - [*C++ keyword of the day: `export`*](https://blogs.msmvps.com/vandooren/2008/09/24/c-keyword-of-the-day-export/) (2008) 201 | 202 | :grey_question: 203 | 204 | - [*Why do templates use the angle bracket syntax?*](https://stackoverflow.com/q/43254027) – Stack Overflow 205 | - [*How do compilers eliminate the need to write white spaces between closing angle brackets, when using template classes since C++ 11 standard?*](https://www.quora.com/How-do-C++-compilers-eliminate-the-need-to-write-white-spaces-between-closing-angle-brackets-when-using-template-classes-since-C++-11-standard) – Quora 206 | 207 | :anchor: 208 | 209 | - D.Vandevoorde. [*Right angle brackets*](https://wg21.link/n1757) – WG21/N1757 210 | 211 | ### Optimization 212 | 213 | :link: 214 | 215 | - C.DaCamara. [*Improving the state of debug performance in C++*](https://devblogs.microsoft.com/cppblog/improving-the-state-of-debug-performance-in-c/) (2022) 216 | - A.O’Dwyer. [*Benchmarking Clang’s `-fbuiltin-std-forward`*](https://quuxplusone.github.io/blog/2022/12/24/builtin-std-forward/) (2022) 217 | - D.Pallastrelli. [*Reduce compilation times with `extern template`*](https://arne-mertz.de/2019/02/extern-template-reduce-compile-times/) (2019) 218 | - L.Dionne. [*Efficient parameter pack indexing*](https://ldionne.com/2015/11/29/efficient-parameter-pack-indexing/) (2015) 219 | - A.Bergé. [*True story: Efficient packing*](http://talesofcpp.fusionfenix.com/post-22/true-story-efficient-packing) (2015) 220 | 221 | :movie_camera: 222 | 223 | - J.Brown. [*Reducing template compilation overhead, using C++11, 14, 17, and 20*](https://www.youtube.com/watch?v=TyiiNVA1syk) – CppCon (2019) 224 | 225 | #### `extern template` 226 | 227 | :grey_question: 228 | 229 | - [*Using `extern template` with third-party header-only library*](https://stackoverflow.com/q/61477486) – Stack Overflow 230 | 231 | ### Two-phase lookup 232 | 233 | > Names are resolved in two steps: first, non-dependent names are resolved at the time of template definition and, second, dependent names are resolved at the time of template instantiation. 234 | 235 | :link: 236 | 237 | - T.Gani et al. [*Two-phase name lookup support comes to MSVC*](https://devblogs.microsoft.com/cppblog/two-phase-name-lookup-support-comes-to-msvc/) – Microsoft C++ team blog (2017) 238 | - [*Two-phase lookup in C++ templates*](https://www.gonwan.com/2014/12/12/two-phase-lookup-in-c-templates/) (2014) 239 | - E.Bendersky. [*Dependent name lookup for C++ templates*](https://eli.thegreenplace.net/2012/02/06/dependent-name-lookup-for-c-templates) (2012) 240 | 241 | :grey_question: 242 | 243 | - [*Why do I have to access template base class members through the `this` pointer?*](https://stackoverflow.com/q/4643074) – Stack Overflow 244 | 245 | :anchor: 246 | 247 | - J.Wilkinson, J.Dehnert, M.Austern. [*A proposed new template compilation model*](http://www.open-std.org/JTC1/SC22/WG21/docs/papers/1996/N0906.pdf) – WG21/N0906 248 | 249 | #### Keywords `template` and `typename` as disambiguators 250 | 251 | > ```cpp 252 | > struct S { template using type = T; }; 253 | > template void foo() { typename T::template type x; } 254 | > 255 | > foo(); 256 | > ``` 257 | 258 | :link: 259 | 260 | - H.Sutter. [GotW #35: *Typename*](http://www.gotw.ca/gotw/035.htm) 261 | 262 | :grey_question: 263 | 264 | - [*Why don’t I need to specify `typename` before a dependent type in C++20?*](https://stackoverflow.com/q/61990971) – Stack Overflow 265 | - [*Where and why do I have to put the `template` and `typename` keywords?*](https://stackoverflow.com/q/610245) – Stack Overflow 266 | 267 | :movie_camera: 268 | 269 | - A.Stepanov. [*Efficient programming with components* (part of Lec. 12)](https://www.youtube.com/watch?v=revYKQKg-eo&t=138) – A9 (2013) 270 | 271 | --- 272 | 273 | ## SFINAE 274 | 275 | > "Substitution Failure Is Not An Error" – when substituting the explicitly specified or deduced type for the template parameter fails, the specialization is discarded from the overload set instead of causing a compile error. 276 | 277 | :link: 278 | 279 | - [*Substitution failure is not an error*](http://blog.olivierlanglois.net/index.php/2007/09/01/what_is_the_c_sfinae_principle) – Wikipedia 280 | 281 | :grey_question: 282 | 283 | - [*What exactly is the “immediate context” mentioned in the C++11 Standard for which SFINAE applies?*](https://stackoverflow.com/q/15260685) – Stack Overflow 284 | - [*What is “Expression SFINAE”?*](https://stackoverflow.com/q/12654067) – Stack Overflow 285 | - [*How does `std::void_t` work*](https://stackoverflow.com/q/27687389) – Stack Overflow 286 | - [*SFINAE and partial class template specializations*](https://stackoverflow.com/q/30676839) – Stack Overflow 287 | - [*SFINAE examples?*](https://stackoverflow.com/q/982808) – Stack Overflow 288 | 289 | :anchor: 290 | 291 | - [*SFINAE*](https://en.cppreference.com/w/cpp/language/sfinae) – C++ reference 292 | 293 | ### Detection idiom 294 | 295 | - P.Barber. [*Unit testing compilation failure*](https://accu.org/journals/overload/20/108/barber_1928/) – [Overload **108**](https://accu.org/journals/overload/overload108) (2012) 296 | 297 | --- 298 | 299 | ## Specialization 300 | 301 | :link: 302 | 303 | - A.O’Dwyer. [*Don’t reopen namespace `std`*](https://quuxplusone.github.io/blog/2021/10/27/dont-reopen-namespace-std/) (2021) 304 | - O.Wigley. [*Alternatives for partial template function specialisation*](https://accu.org/journals/overload/10/50/wigley_385/) – [Overload **50**](https://accu.org/journals/overload/overload50) (2002) 305 | 306 | :grey_question: 307 | 308 | - [*Partial specialization of template class copy constructor*](https://stackoverflow.com/q/16575257) – Stack Overflow 309 | 310 | --- 311 | 312 | ## Explicit instantiation 313 | 314 | - A.O’Dwyer. [*Don’t explicitly instantiate `std` templates*](https://quuxplusone.github.io/blog/2021/08/06/dont-explicitly-instantiate-std-templates/) (2021) 315 | 316 | --- 317 | 318 | ## Tuples 319 | 320 | :link: 321 | 322 | - N.Deppe. [*Template metaprogramming. Part 3: Tuple iteration with recursion*](https://nilsdeppe.com/posts/tmpl-part3) (2017) 323 | - N.Deppe. [*Template metaprogramming. Part 4: Recursion free tuple iteration*](https://nilsdeppe.com/posts/tmpl-part4) (2017) 324 | 325 | :movie_camera: 326 | 327 | - J.Brown. [*Reducing template compilation overhead, using C++11, 14, 17, and 20*](https://www.youtube.com/watch?v=TyiiNVA1syk&t=872) – CppCon (2019) 328 | - A.Modell. [*C++ advanced topics in templates*](https://www.youtube.com/watch?v=X30OwlsMWak&t=2112) – Tech Talk (2014) 329 | 330 | --- 331 | 332 | ## Type lists 333 | 334 | :link: 335 | 336 | - N.Deppe. [*Template metaprogramming. Part 2: Typelist*](https://nilsdeppe.com/posts/tmpl-part2) (2017) 337 | - J.Galowicz. [*Type lists*](https://blog.galowicz.de/2016/05/08/compile_time_type_lists/) (2016) 338 | - J.Galowicz. [*Type list compile time performance*](https://blog.galowicz.de/2016/06/25/cpp_template_type_list_performance/) (2016) 339 | - J.Galowicz. [*Transformations between user input/output and type lists*](https://blog.galowicz.de/2016/05/14/converting_between_c_strings_and_type_lists/) (2016) 340 | 341 | :book: 342 | 343 | - Ch. 3: *Typelists* – A.Alexandrescu. [*Modern C++ design: Generic programming and design patterns applied*](http://erdani.com/index.php/books/modern-c-design/) (2001) 344 | 345 | --- 346 | 347 | ## Type traits 348 | 349 | See also [*Type traits* – The standard library and Boost](std_library.md#type-traits). 350 | 351 | :link: 352 | 353 | - J.Müller. [*Trivially copyable does not mean trivially copy constructible*](https://www.foonathan.net/2021/03/trivially-copyable/) (2021) 354 | - J.Müller. [*Technique: Immediately-invoked function expression for metaprogramming*](https://www.foonathan.net/2020/10/iife-metaprogramming/) (2020) 355 | - N.Deppe. [*Template metaprogramming. Part 1*](https://nilsdeppe.com/posts/tmpl-part1) (2017) 356 | - T.Frogley. [*An introduction to C++ traits*](https://accu.org/journals/overload/9/43/frogley_442/) – ACCU (2001) 357 | - J.Maddock, S.Cleary. [*C++ type traits*](https://www.boost.org/doc/libs/1_31_0/libs/type_traits/c++_type_traits.htm) ([mirror](https://www.drdobbs.com/cpp/c-type-traits/184404270)) – Dr. Dobb’s Journal (2000) 358 | 359 | :grey_question: 360 | 361 | - [*What are the 15 classifications of types in C++?*](https://stackoverflow.com/q/27032790) – Stack Overflow 362 | 363 | :movie_camera: 364 | 365 | - J.Hagins. *Template Metaprogramming: Type Traits.* [*Part 1*](https://www.youtube.com/watch?v=tiAVWcjIF6o), [*Part 2*](https://www.youtube.com/watch?v=dLZcocFOb5Q) – CppCon (2020) 366 | - A.O’Dwyer. [*The best type traits that C++ doesn’t have*](https://www.youtube.com/watch?v=MWBfmmg8-Yo) – C++Now (2018) 367 | - H.Matthews. [*The C++ type system is your friend*](https://www.youtube.com/watch?v=MCiVdu7gScs&t=2028) – ACCU (2017) 368 | 369 | :anchor: 370 | 371 | - [*C++ named requirements: `UnaryTypeTrait`*](https://en.cppreference.com/w/cpp/named_req/UnaryTypeTrait) – C++ reference 372 | - [*C++ named requirements: `BinaryTypeTrait`*](https://en.cppreference.com/w/cpp/named_req/BinaryTypeTrait) – C++ reference 373 | - [*C++ named requirements: `TransformationTrait`*](https://en.cppreference.com/w/cpp/named_req/TransformationTrait) – C++ reference 374 | 375 | --- 376 | 377 | ## Variadic templates 378 | 379 | :link: 380 | 381 | - E.Bendersky. [*Variadic templates in C++*](https://eli.thegreenplace.net/2014/variadic-templates-in-c/) (2014) 382 | 383 | :grey_question: 384 | 385 | - [*Variadic template pack expansion*](https://stackoverflow.com/q/25680461) – Stack Overflow 386 | 387 | :movie_camera: 388 | 389 | - M.Dominiak. [*“Variadic expansion in examples*](https://www.youtube.com/watch?v=Os5YLB5D2BU) – CppCon (2016) 390 | 391 | :anchor: 392 | 393 | - B.Seymour, S.T.Lavavej. [*Searching for types in parameter packs*](https://wg21.link/n4115) – WG21/N4115 394 | 395 | ### Fold expressions 396 | 397 | :link: 398 | 399 | - J.Müller. [*Nifty fold expression tricks*](https://www.foonathan.net/2020/05/fold-tricks/) (2020) 400 | - A.O’Dwyer. [*Folding over `operator=`*](https://quuxplusone.github.io/blog/2020/05/07/assignment-operator-fold-expression/) (2020) 401 | 402 | :anchor: 403 | 404 | - [*Fold expression*](https://en.cppreference.com/w/cpp/language/fold) – C++ reference 405 | 406 | 416 | 417 | 418 | -------------------------------------------------------------------------------- /cpp/tools.md: -------------------------------------------------------------------------------- 1 | # Tools 2 | 3 | ## Table of contents 4 | 5 | - [Build automation](#build-automation) 6 | - [CMake](#cmake) 7 | - [Version control](#version-control) 8 | - [Git](#git) 9 | - [Compilation and compilers](#compilation-and-compilers) 10 | - [GCC](#gcc) 11 | - [Clang](#clang) 12 | - [MSVC](#msvc) 13 | - [Circle](#circle) 14 | - [Linking and linkers](#linking-and-linkers) 15 | - [IDE](#ide) 16 | - [Visual Studio](#visual-studio) 17 | - [Visual Studio Code](#visual-studio-code) 18 | - [Code analysis and optimization tools](#code-analysis-and-optimization-tools) 19 | - [Online compilers](#online-compilers) 20 | - [Intel Architecture Code Analyzer (IACA)](#intel-architecture-code-analyzer-iaca) 21 | - [Valgrind](#valgrind) 22 | - [Debugging](#debugging) 23 | - [GDB](#gdb) 24 | - [Pretty printers](#pretty-printers) 25 | - [AI tools](#ai-tools) 26 | - [C++ tests and quizes](#c-tests-and-quizes) 27 | 28 | --- 29 | 30 | ## Build automation 31 | 32 | ### CMake 33 | 34 | :link: 35 | 36 | - [*Include Google Benchmark/Test in C++ project*](https://felixmoessbauer.com/blog-reader/include-google-benchmark-test-in-c-project.html) – Software Engineering Blog 37 | 38 | :movie_camera: 39 | 40 | - F.Castelli. [*Introduction to CMake*](https://www.youtube.com/watch?v=jt3meXdP-QI) – SwedenCpp (2018) 41 | - D.Pfeifer. [*Effective CMake*](https://www.youtube.com/watch?v=bsXLMQ6WgIk) – C++Now (2017) 42 | - M.Ropert. [*Using modern CMake patterns to enforce a good modular design*](https://www.youtube.com/watch?v=eC9-iRN2b04) – CppCon (2017) 43 | - J.Turner. [Episode 78: *Intro to CMake*](https://www.youtube.com/watch?v=HPMvU64RUTY) – C++ Weekly (2017) 44 | 45 | --- 46 | 47 | ## Version control 48 | 49 | ### Git 50 | 51 | :movie_camera: 52 | 53 | - E.Campidoglio. [*Git hidden gems*](https://www.youtube.com/watch?v=WtUCZYyv-_w) – NDC Oslo (2023) 54 | - C.Schafer. [*Git tutorial for beginners*](https://www.youtube.com/playlist?list=PL-osiE80TeTuRUfjRe54Eea17-YfnOOAx) 55 | 56 | :grey_question: 57 | 58 | - [*How to make Git “forget” about a file that was tracked but is now in `.gitignore`?*](https://stackoverflow.com/q/1274057) – Stack Overflow 59 | - [*When should I use `git pull --rebase`?*](https://stackoverflow.com/q/2472254) – Stack Overflow 60 | 61 | --- 62 | 63 | ## Compilation and compilers 64 | 65 | :link: 66 | 67 | - A.O’Dwyer. [*Always read the first error message first*](https://quuxplusone.github.io/blog/2023/01/21/did-you-mean-bool/) (2023) 68 | 69 | :movie_camera: 70 | 71 | - V.Romeo. [*Improving C++ compilation times: Tools & techniques*](https://www.youtube.com/watch?v=PfHD3BsVsAM) – ACCU (2023) 72 | 73 | :anchor: 74 | 75 | - [*C++ compiler support*](https://en.cppreference.com/w/cpp/compiler_support) – C++ reference 76 | 77 | ### GCC 78 | 79 | :link: 80 | 81 | - M.Jones [*GCC hacks in the Linux kernel*](https://developer.ibm.com/tutorials/l-gcc-hacks/) (2008) 82 | - M.Davis. [*An introduction to creating GCC plugins*](https://lwn.net/Articles/457543/) (2011) 83 | - F.Aboukhadijeh. [*GCC Easter egg: C++ undefined defined behavior*](https://feross.org/gcc-ownage/) (2010) 84 | 85 | :grey_question: 86 | 87 | - [*Linux kernel’s `__is_constexpr` macro*](https://stackoverflow.com/q/49481217) – Stack Overflow 88 | - [*What are the GCC predefined macros for the compiler’s version number?*](https://stackoverflow.com/q/1936719) – Stack Overflow 89 | 90 | :sound: 91 | 92 | - M.Deters. [Episode 61: *Internals of GCC*](http://www.se-radio.net/2007/07/episode-61-internals-of-gcc/) – Software Engineering Radio (2007) 93 | 94 | :anchor: 95 | 96 | - [*Semantics of floating point math in GCC*](https://gcc.gnu.org/wiki/FloatingPointMath) – GCC Wiki 97 | 98 | ### Clang 99 | 100 | :link: 101 | 102 | - E.Bendersky. [*Dumping a C++ object’s memory layout with Clang*](https://eli.thegreenplace.net/2012/12/17/dumping-a-c-objects-memory-layout-with-clang/) (2012) 103 | 104 | ### MSVC 105 | 106 | :link: 107 | 108 | - [*Compiler limits*](https://learn.microsoft.com/en-us/cpp/cpp/compiler-limits) (2021) 109 | 110 | :anchor: 111 | 112 | - [*Compiler options: `/fp` (specify floating-point behavior)](https://docs.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior) – Visual C++ documentation 113 | 114 | ### Circle 115 | 116 | :link: 117 | 118 | - [*Circle C++ compiler*](https://www.circle-lang.org/) 119 | 120 | --- 121 | 122 | ## Linking and linkers 123 | 124 | See also [*Libraries* – Assembly, low-level programming, and OS internals](../low_level.md#libraries). 125 | 126 | :link: 127 | 128 | - D.Drysdale. [*Beginner’s guide to linkers*](http://www.lurklurk.org/linkers/linkers.html) (2009) 129 | 130 | :grey_question: 131 | 132 | - [*What do linkers actually do with multiply-defined `inline` functions?*](https://stackoverflow.com/q/35233468) – Stack Overflow 133 | 134 | :movie_camera: 135 | 136 | - N.Friedman. [*What C++ developers should know about globals (and the linker)*](https://www.youtube.com/watch?v=xVT1y0xWgww) – CppCon (2017) 137 | 138 | :book: 139 | 140 | - J.R.Levine. [*Linkers and loaders*](https://linker.iecc.com/) – Morgan-Kauffman (1999) 141 | 142 | --- 143 | 144 | ## IDE 145 | 146 | ### Visual Studio 147 | 148 | :link: 149 | 150 | - A.Rich. [*Troubleshooting tips for IntelliSense slowness*](https://devblogs.microsoft.com/cppblog/troubleshooting-tips-for-intellisense-slowness/) 151 | 152 | ### Visual Studio Code 153 | 154 | :link: 155 | 156 | - [*Visual Studio Code*](https://code.visualstudio.com/) 157 | - [*Visual Studio Code: Getting started*](https://code.visualstudio.com/docs) 158 | - [*C/C++ for Visual Studio Code*](https://code.visualstudio.com/docs/languages/cpp) 159 | 160 | --- 161 | 162 | ## Code analysis and optimization tools 163 | 164 | :movie_camera: 165 | 166 | - H.Matthews. [*Optimising a small real-world C++ application*](https://www.youtube.com/watch?v=fDlE93hs_-U) – ACCU (2019) 167 | 168 | ### Online compilers 169 | 170 | :link: 171 | 172 | - [*Compiler explorer*](https://godbolt.org/) 173 | 174 | :movie_camera: 175 | 176 | - M.Godbolt [*Compiler explorer: Behind the scenes*](https://www.youtube.com/watch?v=kIoZDUd5DKw) – CppCon (2019) 177 | 178 | ### Intel Architecture Code Analyzer (IACA) 179 | 180 | - [*What is IACA and how do I use it?*](https://stackoverflow.com/q/26021337) – Stack Overflow 181 | 182 | ### Valgrind 183 | 184 | :movie_camera: 185 | 186 | - J.Turner. [Episode 86: *Valgrind compiler optimization*](https://www.youtube.com/watch?v=3l0BQs2ThTo) – C++ Weekly (2017) 187 | 188 | --- 189 | 190 | ## Debugging 191 | 192 | :link: 193 | 194 | - [*Debugging stack traces from crash dumps*](https://github.com/microsoft/WinObjC/wiki/Debugging-Stack-Traces-from-Crash-Dumps) – Microsoft 195 | 196 | :grey_question: 197 | 198 | - [*Creating a `SIGSEGV` for debug purposes*](https://stackoverflow.com/q/9457928) – Stack Overflow 199 | - [*When and why will an OS initialise memory to `0xCD`, `0xDD`, etc. on `malloc`/`free`/`new`/`delete`?*](https://stackoverflow.com/q/370195) – Stack Overflow 200 | 201 | :movie_camera: 202 | 203 | - B.Steagall. [*Back to basics: Debugging techniques*](https://www.youtube.com/watch?v=M7fV-eQwxrY) – CppCon (2021) 204 | - H.Matthews. [*Optimising a small real-world C++ application*](https://www.youtube.com/watch?v=fDlE93hs_-U) – ACCU (2019) 205 | - G.Law. [*Debugging Linux C++*](https://www.youtube.com/watch?v=V1t6faOKjuQ) – CppCon (2018) 206 | - [*Unusual memory bit patterns*](https://www.softwareverify.com/memory-bit-patterns.php) 207 | 208 | ### GDB 209 | 210 | :link: 211 | 212 | - [*Debugging with GDB*](https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing.html) 213 | 214 | :grey_question: 215 | 216 | - [*Identify source file name for a symbol in gdb debugger*](https://stackoverflow.com/q/58826430) – Stack Overflow 217 | 218 | #### Pretty printers 219 | 220 | :link: 221 | 222 | - [Sec. 10.9: *Pretty printing*](https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing.html) – Debugging with GDB 223 | - [Sec. 23.2.2: *Python API*](https://sourceware.org/gdb/onlinedocs/gdb/Python-API.html) – Debugging with GDB 224 | - D.Haguenauer. [*Writing custom GDB pretty-printers*](http://www.kurokatta.org/grumble/2018/05/gdb-pretty) (2018) 225 | - *Pretty printing.* [Part I](http://tromey.com/blog/?p=524), [Part II](http://tromey.com/blog/?p=546) (2008) 226 | - [*Make debugging easier with custom pretty-printers*](https://rethinkdb.com/blog/make-debugging-easier-with-custom-pretty-printers) (2010) 227 | - R.Sonderfeld. [*GDB pretty printers for Boost*](https://github.com/ruediger/Boost-Pretty-Printer) 228 | 229 | --- 230 | 231 | ## AI tools 232 | 233 | :movie_camera: 234 | 235 | - A.Alexandrescu. [*Robots are after your job: Exploring generative AI for C++*](https://www.youtube.com/watch?v=J48YTbdJNNc) – CppCon (2023) 236 | 237 | --- 238 | 239 | ## C++ tests and quizes 240 | 241 | :link: 242 | 243 | - A.S.Knatten. [*C++ quiz*](http://cppquiz.org/) 244 | - J.Nieminen. [*Test your C++ knowledge*](http://warp.povusers.org/c++test/) 245 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/backtracking.md: -------------------------------------------------------------------------------- 1 | # Backtracking 2 | 3 | ## Table of contents 4 | 5 | - [Exact cover](#exact-cover) 6 | - [Algorithm X and dancing links](#algorithm-x-and-dancing-links) 7 | --- 8 | 9 | ## Exact cover 10 | 11 | ### Algorithm X and dancing links 12 | 13 | https://www-cs-faculty.stanford.edu/~knuth/fasc5c.ps.gz 14 | 15 | - D.E.Knuth. [*Dancing links*](https://www.youtube.com/watch?v=_cR9zDlvP88) – Stanford Lecture: Donald Knuth’s 24th annual Christmas lecture (2018) 16 | 17 | 20 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/bit_algorithms.md: -------------------------------------------------------------------------------- 1 | # Bit algorithms 2 | 3 | ## Table of contents 4 | 5 | - [Bit operations](#bit-operations) 6 | - [Bit index](#bit-index) 7 | - [De Bruijn sequence](#de-bruijn-sequence) 8 | - [Reversing bits](#reversing-bits) 9 | - [Boolean functions](#boolean-functions) 10 | - [Karnaugh map](#karnaugh-map) 11 | 12 | --- 13 | 14 | ## Bit operations 15 | 16 | :link: 17 | 18 | - J.L.Neumann. [*Bit permutations*](http://programming.sirrida.de/bit_perm.html) (2020) 19 | - S.E.Anderson. [*Bit twiddling hacks*](http://graphics.stanford.edu/~seander/bithacks.html) (2005) 20 | - H.G.Dietz. [*The aggregate magic algorithms*](http://aggregate.org/MAGIC/) 21 | 22 | :movie_camera: 23 | 24 | - J.Shun. [*Bit hacks*](https://www.youtube.com/watch?v=ZusiKXcz_ac) – MIT 6.172: [Performance engineering of software systems](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-172-performance-engineering-of-software-systems-fall-2018/) (2018) 25 | 26 | 27 | 28 | ### Bit index 29 | 30 | :link: 31 | 32 | - [*BitScan*](https://www.chessprogramming.org/BitScan) – Chess Programming Wiki 33 | 34 | 35 | :grey_question: 36 | 37 | - [*Position of least significant bit that is set*](https://stackoverflow.com/q/757059) – Stack Overflow 38 | 39 | #### De Bruijn sequence 40 | 41 | :link: 42 | 43 | - [*De Bruijn sequence*](https://en.wikipedia.org/wiki/De_Bruijn_sequence) – Wikipedia 44 | - C.E.Leiserson, H.Prokop, K.H.Randall. [*Using de Bruijn sequences to index a `1` in a computer word*](http://supertech.csail.mit.edu/papers/debruijn.pdf) – MIT (1998) 45 | 46 | ### Reversing bits 47 | 48 | :link: 49 | 50 | - C.Nicholson. [*Reversing bits in C*](https://medium.com/square-corner-blog/reversing-bits-in-c-48a772dc02d7) – Square Corner Blog (2013) 51 | 52 | --- 53 | 54 | ## Boolean functions 55 | 56 | ### Karnaugh map 57 | 58 | :link: 59 | 60 | - [*Karnaugh map*](https://en.wikipedia.org/wiki/Karnaugh_map) – Wikipedia 61 | 62 | 71 | 72 | --- 73 | 74 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/combinatorics.md: -------------------------------------------------------------------------------- 1 | # Combinatorial algorithms 2 | 3 | ## Table of contents 4 | 5 | - [Permutations](#permutations) 6 | - [Algorithm L](#algorithm-l) 7 | - [Heap’s algorithm](#heaps-algorithm) 8 | - [Random permutations](#random-permutations) 9 | 10 | --- 11 | 12 | ## Permutations 13 | 14 | 15 | 16 | ### Algorithm L 17 | 18 | > Algorithm L for the given sequence of `n` initially sorted elements {a0 ≤ a1 ≤ ... ≤ an-1}, generates all permutations visiting them in the lexicographic order. Gist of the algorithm: for the current permutation, find the longest decreasing subsequence on the right, {...ap ≤ ai > aj > ... > ak}, find the next front element af > ap with the largest possible `f` in the range `[i, k]`, swap af and ap, and then put the remaining elements in the ascending order, i.e. reverse the subsequence {ai...ap...ak}. 19 | 20 | :memo: 21 | 22 | - This algorithm is used in some implementations of `std::next_permutation` in the standard library. 23 | 24 | :link: 25 | 26 | - [*`std::next_permutation` implementation explanation* – Stack Overflow](https://stackoverflow.com/q/11483060) 27 | 28 | :book: 29 | 30 | - Sec. 7.2.1.2: *Generating all permutations* – D.E.Knuth. [*The art of computer programming.*](https://www-cs-faculty.stanford.edu/~knuth/taocp.html) *Vol. 4A: Combinatorial algorithms, Part 1* (2011) 31 | 32 | ### Heap’s algorithm 33 | 34 | > Heap’s algorithm generates all possible permutations of `n` objects. The algorithm minimizes movement: it generates each permutation from the previous one by interchanging a single pair of elements; the other `n - 2` elements are not disturbed. 35 | 36 | :link: 37 | 38 | - [*Heap’s algorithm*](https://en.wikipedia.org/wiki/Heap%27s_algorithm) – Wikipedia 39 | - [*Heap algorithm for permutations*](https://stackoverflow.com/q/31425531) – Stack Overflow 40 | 41 | ### Random permutations 42 | 43 | See [*Shuffling* – Randomized algorithms](random.md#shuffling). 44 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/cryptographic.md: -------------------------------------------------------------------------------- 1 | # Cryptographic algorithms 2 | 3 | ## Table of contents 4 | 5 | - [Introduction and overview](#introduction-and-overview) 6 | - [Hashing](#hashing) 7 | - [Hash functions](#hash-functions) 8 | - [Password hashing](#password-hashing) 9 | - [Random numbers generation](#random-numbers-generation) 10 | - [Potential problems](#potential-problems) 11 | - [Debian OpenSSL bug](#debian-openssl-bug) 12 | - [Dual\_EC\_DRBG backdoor](#dual_ec_drbg-backdoor) 13 | - [Public-key cryptography](#public-key-cryptography) 14 | - [RSA (Rivest–Shamir–Adleman)](#rsa-rivestshamiradleman) 15 | - [Diffie–Hellman key exchange](#diffiehellman-key-exchange) 16 | - [Protocols](#protocols) 17 | - [TLS](#tls) 18 | 19 | --- 20 | 21 | ## Introduction and overview 22 | 23 | :book: 24 | 25 | - Essay 7: *Locking the barn door* – P.J.Plauger. [*Programming on purpose III: Essays on software technology*](https://www.pearson.com/us/higher-education/program/Plauger-Programming-on-Purpose-III-Essays-on-Software-Technology/PGM133229.html) (1994) 26 | 27 | ## Hashing 28 | 29 | ### Hash functions 30 | 31 | ### Password hashing 32 | 33 | :link: 34 | 35 | - [*Salted password hashing – Doing it right*](https://crackstation.net/hashing-security.htm) – CrackStation 36 | - S.Ignatchenko. [*Password hashing: Why and how*](https://accu.org/journals/overload/23/129/ignatchenko_2159/) – [Overload **129**](https://accu.org/journals/overload/overload129) (2015) 37 | 38 | --- 39 | 40 | ## Random numbers generation 41 | 42 | ### Potential problems 43 | 44 | :movie_camera: 45 | 46 | - N.Heninger. [*Random number generation failures from Netscape to DUHK*](https://www.youtube.com/watch?v=fC6QySrAd7U) (2018) 47 | 48 | #### Debian OpenSSL bug 49 | 50 | :link: 51 | 52 | - R.Cox. [*Lessons from the Debian/OpenSSL fiasco*](https://research.swtch.com/openssl) (2008) 53 | - J.Kroll. [*The Debian OpenSSL bug: Backdoor or security accident?*](https://freedom-to-tinker.com/2013/09/20/software-transparency-debian-openssl-bug/) (2013) 54 | 55 | #### Dual_EC_DRBG backdoor 56 | 57 | :link: 58 | 59 | - B.Schneier. [*Did NSA put a secret backdoor in new encryption standard?*](https://www.wired.com/2007/11/securitymatters-1115/) 60 | 61 | :movie_camera: 62 | 63 | - M.Pound. [*Elliptic curve back door*](https://www.youtube.com/watch?v=nybVFJVXbww) – Computerphile 64 | 65 | :anchor: 66 | 67 | - [*Dual_EC_DRBG*](https://en.wikipedia.org/wiki/Dual_EC_DRBG) – Wikipedia 68 | 69 | --- 70 | 71 | ## Public-key cryptography 72 | 73 | :book: 74 | 75 | - Essay 8: *Half a secret* – P.J.Plauger. [*Programming on purpose III: Essays on software technology*](https://www.pearson.com/us/higher-education/program/Plauger-Programming-on-Purpose-III-Essays-on-Software-Technology/PGM133229.html) (1994) 76 | 77 | ### RSA (Rivest–Shamir–Adleman) 78 | 79 | :movie_camera: 80 | 81 | - J.Keating. [*How does RSA cryptography work?*](https://www.youtube.com/watch?v=qph77bTKJTM) 82 | 83 | ### Diffie–Hellman key exchange 84 | 85 | :link: 86 | 87 | - [*Diffie–Hellman key exchange*](https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange) – Wikipedia 88 | 89 | --- 90 | 91 | ## Protocols 92 | 93 | ### TLS 94 | 95 | :movie_camera: 96 | 97 | - P.Bindels. [*TLS cryptography for programmers*](https://www.youtube.com/watch?v=6_9ODzckrfc) – ACCU (2022) 98 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/data_exchange.md: -------------------------------------------------------------------------------- 1 | # Data exchange and compression 2 | 3 | ## Table of contents 4 | 5 | - [Binary files](#binary-files) 6 | - [Serialization](#serialization) 7 | - [Boost.Serialization](#boostserialization) 8 | - [Compression](#compression) 9 | - [JPEG](#jpeg) 10 | 11 | --- 12 | 13 | ## Binary files 14 | 15 | :movie_camera: 16 | 17 | - P.Bindels. [*What’s in a bit – Designing, using and reverse-engineering binary file formats*](https://www.youtube.com/watch?v=QEIGc3tXGmM) – C++ on Sea (2022) 18 | 19 | ## Serialization 20 | 21 | :movie_camera: 22 | 23 | - C.Ryan. [*Binary object serialization*](https://www.youtube.com/watch?v=aWPI7vDOAK8) – CppNow (2022) 24 | - C.Ryan. [*Binary object serialization with data structure traversal & reconstruction*](https://www.youtube.com/watch?v=rt-c7igYkFw) – CppCon (2022) 25 | 26 | :anchor: 27 | 28 | - [*Serialization*](https://isocpp.org/wiki/faq/serialization) – C++ FAQ 29 | 30 | ### Boost.Serialization 31 | 32 | :movie_camera: 33 | 34 | - R.Thomson. [*Serialization with Boost.Serialization*](https://www.youtube.com/watch?v=YmEPMFMP7TE) – Utah C++ Programmers (2022) 35 | 36 | :anchor: 37 | 38 | - [*Boost.Serialization*](https://www.boost.org/doc/libs/release/libs/serialization/doc/index.html) 39 | 40 | --- 41 | 42 | ## Compression 43 | 44 | :movie_camera: 45 | 46 | - D.Brailsford. [*Compression*](https://www.youtube.com/watch?v=Lto-ajuqW3w), [*Entropy in compression*](https://www.youtube.com/watch?v=M5c_RFKVkko), [*Elegant compression in text (the LZ77 method)*](https://www.youtube.com/watch?v=goOa3DGezUA) – Computerphile (2013) 47 | 48 | ### JPEG 49 | 50 | :movie_camera: 51 | 52 | - [*The unreasonable effectiveness of JPEG: A signal processing approach*](https://www.youtube.com/watch?v=0me3guauqOU) – 53 | Reducible (2022) 54 | 55 | :page_facing_up: 56 | 57 | - N.Ahmed. [*How I came up with the discrete cosine transform*](https://www.cse.iitd.ac.in/~pkalra/col783-2017/DCT-History.pdf) – [Digital Signal Processing **1**, 4-5](https://dx.doi.org/10.1016/1051-2004(91)90086-Z) (1991) 58 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/design_and_analysis.md: -------------------------------------------------------------------------------- 1 | # Design and analysis 2 | 3 | ## Table of contents 4 | 5 | - [Types design](#types-design) 6 | - [Affine space types](#affine-space-types) 7 | - [Algorithms design](#algorithms-design) 8 | - [Generic algorithms design](#generic-algorithms-design) 9 | - [Complexity analysis](#complexity-analysis) 10 | - [Amortized analysis](#amortized-analysis) 11 | - [Loop invariants](#loop-invariants) 12 | - [Binary search](#binary-search) 13 | - [Stability (order of elements)](#stability-order-of-elements) 14 | 15 | --- 16 | 17 | ## Types design 18 | 19 | :movie_camera: 20 | 21 | - V.Ciura. [*Regular types and why do I care?*](https://www.youtube.com/watch?v=OMhzlcBl9Hc) – ACCU (2019) 22 | - V.Ciura. [*Regular types and why do I care?*](https://www.youtube.com/watch?v=h60zqdzIelE) – CppCon (2018) 23 | - A.Stepanov. [*STL and its design principles*](https://www.youtube.com/watch?v=COuHLky7E2Q) (2002) 24 | 25 | ### Affine space types 26 | 27 | :link: 28 | 29 | - A.Shavit. [*Affine space types*](http://videocortex.io/2018/Affine-Space-Types/) (2018) 30 | 31 | :movie_camera: 32 | 33 | - A.Shavit, B.Fahller. [*The curiously recurring pattern of coupled types*](https://www.youtube.com/watch?v=msi4WNQZyWs) – NDC (2019) 34 | - A.Shavit, B.Fahller: [*The Curiously Recurring Pattern of Coupled Types*](https://www.youtube.com/watch?v=EhlYsKnAmjs) – StockholmCpp (2018) 35 | 36 | ## Algorithms design 37 | 38 | ### Generic algorithms design 39 | 40 | :movie_camera: 41 | 42 | - B.Deane. [*Constructing generic algorithms: Principles and practice*](https://www.youtube.com/watch?v=InMh3JxbiTs) – CppCon (2020) 43 | 44 | :book: 45 | 46 | - A.A.Stepanov, D.E.Rose. [*From mathematics to generic programming*](http://www.fm2gp.com/) (2014) 47 | 48 | ## Complexity analysis 49 | 50 | :link: 51 | 52 | - S.Ignatchenko. [*Some big-Os are bigger than others*](https://accu.org/journals/overload/24/134/ignatchenko_2268/) – [Overload **134**](https://accu.org/journals/overload/overload134) (2016) 53 | - R.Orr. [*Order notation in practice*](https://accu.org/journals/overload/22/124/orr_2043/) – [Overload **124**](https://accu.org/journals/overload/overload124) (2014) 54 | 55 | ### Amortized analysis 56 | 57 | :link: 58 | 59 | - [*Amortized analysis*](https://www.cs.cornell.edu/courses/cs3110/2012sp/lectures/lec21-amortized/lec21.html) – Cornell University CS 3110: [Data structures and functional programming](https://www.cs.cornell.edu/courses/cs3110/2012sp/index.php) (2012) 60 | - [Amortized complexity in layman’s terms?](https://stackoverflow.com/q/15079327) – Stack Overflow 61 | - [Difference between average case and amortized analysis](https://stackoverflow.com/q/7333376) – Stack Overflow 62 | 63 | --- 64 | 65 | ## Loop invariants 66 | 67 | > A loop invariant is a property of a program loop that is true before and after each iteration. 68 | 69 | :link: 70 | 71 | - [*Loop invariant*](https://en.wikipedia.org/wiki/Loop_invariant) – Wikipedia 72 | 73 | :book: 74 | 75 | - Col. 4: *Writing correct programs* – J.Bentley. [*Programming pearls*](https://www.oreilly.com/library/view/programming-pearls-second/9780134498058/) (1999) 76 | 77 | :page_facing_up: 78 | 79 | - J.Bentley. [*Programming pearls: Writing correct programs*](https://www.cs.tufts.edu/~nr/cs257/archive/jon-bentley/correct-programs.pdf) – [Communications of the ACM **26**, 1040](https://doi.org/10.1145/358476.358484) (1983) 80 | - D.Gries. [*A note on a standard strategy for developing loop invariants and loops*](https://core.ac.uk/download/pdf/82596333.pdf) – [Science of Computer Programming **2**, 207](https://dx.doi.org/10.1016/0167-6423(83)90015-1) (1982) 81 | 82 | ### Binary search 83 | 84 | :link: 85 | 86 | - A.Koenig. *Invariants for binary search.* [Part I](http://www.drdobbs.com/cpp/invariants-for-binary-search-part-1-a-si/240169169), [Part II](http://www.drdobbs.com/cpp/invariants-for-binary-search-part-2-refi/240169199), [Part III](http://www.drdobbs.com/cpp/invariants-for-binary-search-part-3-impr/240169239), [Part IV](http://www.drdobbs.com/cpp/invariants-for-binary-search-part-4-usin/240169267), [Part V](http://www.drdobbs.com/cpp/abstractions-for-binary-search-part-5-ge/240169289), [Part VI](http://www.drdobbs.com/cpp/abstractions-for-binary-search-part-6-ho/240169326), [Part VII](http://www.drdobbs.com/cpp/abstractions-for-binary-search-part-7-ch/240169367), [Part VIII](http://www.drdobbs.com/cpp/abstractions-for-binary-search-part-8-wh/240169392), [Part IX](http://www.drdobbs.com/cpp/abstractions-for-binary-search-part-9-wh/240169416), [Part X](http://www.drdobbs.com/cpp/abstractions-for-binary-search-part-10-p/240169437) – Dr.Dobb’s Journal 87 | 88 | --- 89 | 90 | ## Stability (order of elements) 91 | 92 | :grey_question: 93 | 94 | - [*What is stability in sorting algorithms and why is it important?*](https://stackoverflow.com/q/1517793) – Stack Overflow 95 | 96 | :movie_camera: 97 | 98 | - W.E.Brown. [*Extrema: Correctly calculating `min` and `max`*](https://www.youtube.com/watch?v=e-TNCbX8mOQ) – itCppCon (2021) 99 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/distributed.md: -------------------------------------------------------------------------------- 1 | # Distributed algorithms 2 | 3 | ## Table of contents 4 | 5 | - [Collaborative editing](#collaborative-editing) 6 | - [Operational transformation](#operational-transformation) 7 | - [Differential synchronization](#differential-synchronization) 8 | 9 | --- 10 | 11 | ## Collaborative editing 12 | 13 | ### Operational transformation 14 | 15 | :link: 16 | 17 | - [*Operational transformation*](https://en.wikipedia.org/wiki/Operational_transformation) – Wikipedia 18 | - D.Spiewak. [*Understanding and applying operational transformation*](http://www.codecommit.com/blog/java/understanding-and-applying-operational-transformation) (2010) 19 | - D.Wang, A.Mah, S.Lassen. [*Google Wave operational transformation*](https://svn.apache.org/repos/asf/incubator/wave/whitepapers/operational-transform/operational-transform.html) (2010) 20 | - [*Apache Wave project* (retired)](https://incubator.apache.org/projects/wave.html) 21 | 22 | 23 | 24 | 25 | 26 | ### Differential synchronization 27 | 28 | :page_facing_up: 29 | 30 | - N.Fraser. [*Differential synchronization*](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/35605.pdf) ([mirror](https://neil.fraser.name/writing/sync/eng047-fraser.pdf)) – [ACM Symposium on Document Engineering, 13](https://research.google/pubs/pub35605/) (2009) 31 | 32 | :movie_camera: 33 | 34 | - N.Fraser. [*Differential synchronization*](https://www.youtube.com/watch?v=S2Hp_1jqpY8) – Google Tech Talks (2009) 35 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/dynamic_programming.md: -------------------------------------------------------------------------------- 1 | # Dynamic programming 2 | 3 | See [*Dynamic programming* – Optimization algorithms](optimization.md#dynamic_programming). 4 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/game_theory.md: -------------------------------------------------------------------------------- 1 | # Game theory 2 | 3 | ## Table of contents 4 | 5 | - [Stable marriage problem](#stable-marriage-problem) 6 | - [Gale–Shapley algorithm](#galendashshapley-algorithm) 7 | 8 | --- 9 | 10 | ## Stable marriage problem 11 | 12 | > Problem: given `n` men and `n` women, where each person has ranked all members of the opposite sex in order of preference, marry the men and women together such that there are no two people of opposite sex who would both rather have each other than their current partners. 13 | 14 | :memo: 15 | 16 | - This problem is also known as the stable matching problem. 17 | 18 | :link: 19 | 20 | - [*Stable marriage problem* – Wikipedia](https://en.wikipedia.org/wiki/Stable_marriage_problem) 21 | 22 | :movie_camera: 23 | 24 | - *Stable marriage problem.* [Part I](https://www.youtube.com/watch?v=Qcv1IqHWAzg), [Part II](https://www.youtube.com/watch?v=LtTV6rIxhdo) – Numberphile (2014) 25 | - [*The stable matching algorithm: Examples and implementation*](https://www.youtube.com/watch?v=FhRf0j068ZA) – The Simple Engineer (2017) 26 | 27 | :book: 28 | 29 | - D.E.Knuth. [*Stable marriage and its relation to other combinatorial problems: An introduction to the mathematical analysis of algorithms*](https://www-cs-faculty.stanford.edu/~knuth/ms.html) (1996) 30 | 31 | :page_facing_up: 32 | 33 | - H.Mairson. [*The stable marriage problem*](https://archive.org/details/brandeisreview1214bran/page/n39) – The Brandeis Review **12**, 38 (1992) 34 | 35 | ### Gale–Shapley algorithm 36 | 37 | :link: 38 | 39 | - D.Austin. [*The stable marriage problem and school choice*](http://www.ams.org/publicoutreach/feature-column/fc-2015-03) – [AMS Feature column](http://www.ams.org/featurecolumn) (2015) 40 | - [*Stable marriage problem*](https://rosettacode.org/wiki/Stable_marriage_problem) – Rosetta Code 41 | 42 | :page_facing_up: 43 | 44 | - D.Gale, L.S.Shapley. [*College admissions and the stability of marriage*](http://www.eecs.harvard.edu/cs286r/courses/fall09/papers/galeshapley.pdf) – [American Mathematical Monthly **69**, 9](https://dx.doi.org/10.2307/2312726) (1962) 45 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/geometric.md: -------------------------------------------------------------------------------- 1 | # Geometric algorithms 2 | 3 | ## Table of contents 4 | 5 | - [Polygons](#polygons) 6 | - [Inscribed circle](#inscribed-circle) 7 | - [Closest pair of points](#closest-pair-of-points) 8 | - [Points generation](#points-generation) 9 | - [Random points generation](#random-points-generation) 10 | - [Random points in triangles](#random-points-in-triangles) 11 | - [Random points in polygons](#random-points-in-polygons) 12 | - [Polyline algorithms](#polyline-algorithms) 13 | - [Ramer–Douglas–Peucker algorithm](#ramerdouglaspeucker-algorithm) 14 | - [Drawing algorithms](#drawing-algorithms) 15 | - [Bresenham’s-type algorithms](#bresenhams-type-algorithms) 16 | - [Bresenham’s line algorithm](#bresenhams-line-algorithm) 17 | - [Bresenham’s circle algorithm](#bresenhams-circle-algorithm) 18 | 19 | --- 20 | 21 | ## Polygons 22 | 23 | ### Inscribed circle 24 | 25 | :link: 26 | 27 | - [*Confusion on Delaunay triangulation and largest inscribed circle*](https://stackoverflow.com/q/27872964) – Stack Overflow 28 | - [*Largest circle inside a non-convex polygon*](https://stackoverflow.com/q/4279478) – Stack Overflow 29 | 30 | --- 31 | 32 | ## Closest pair of points 33 | 34 | > Problem: in the given set of n ≥ 2 points in a metric space, find a pair of points with the smallest distance between them. 35 | 36 | :link: 37 | 38 | - [*Closest pair of points*](https://en.wikipedia.org/wiki/Closest_pair_of_points_problem) – Wikipedia 39 | 40 | :book: 41 | 42 | - Sec. 33.4: *Finding the closest pair of points* – T.H.Cormen, C.E.Leiserson, R.L.Rivest, C.Stein. [*Introduction to algorithms*](https://mitpress.mit.edu/books/introduction-algorithms-third-edition) (2009) 43 | 44 | --- 45 | 46 | ## Points generation 47 | 48 | ### Random points generation 49 | 50 | :book: 51 | 52 | - Sec. 1.5: G.Turk. *Generating random points in triangles* – A.S.Glassner. [*Graphics gems*](https://www.glassner.com/portfolio/graphics-gems/) (1990) 53 | 54 | #### Random points in triangles 55 | 56 | > Problem: given three points `A`, `B` and `C` that describe a triangle, pick a random point in it with uniform probability. 57 | 58 | :grey_question: 59 | 60 | - [*Uniform random point in triangle*](https://math.stackexchange.com/q/18686) – Mathematics 61 | 62 | #### Random points in polygons 63 | 64 | > Problem: given `N` points A1, A2, ..., AN that describe a polygon, pick a random point in it with uniform probability. 65 | 66 | :grey_question: 67 | 68 | - [*How to get a random point on the interior of an irregular polygon?*](https://stackoverflow.com/q/19481514) – Stack Overflow 69 | 70 | --- 71 | 72 | ## Polyline algorithms 73 | 74 | ### Ramer–Douglas–Peucker algorithm 75 | 76 | :link: 77 | 78 | - [*Ramer–Douglas–Peucker algorithm*](https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm) – Wikipedia 79 | 80 | --- 81 | 82 | ## Drawing algorithms 83 | 84 | ### Bresenham’s-type algorithms 85 | 86 | #### Bresenham’s line algorithm 87 | 88 | :link: 89 | 90 | - [*Bresenham’s line algorithm*](https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm) – Wikipedia 91 | 92 | :page_facing_up: 93 | 94 | - R.F.Sproull. [*Using program transformations to derive line-drawing algorithms*](http://public.callutheran.edu/~reinhart/CSC505/Week1/BresenhamLines.pdf) – [ACM Transactions on Graphics **1**, 259](https://doi.org/10.1145/357311.357312) (1982) 95 | 96 | #### Bresenham’s circle algorithm 97 | 98 | :link: 99 | 100 | - [*Midpoint circle algorithm*](https://en.wikipedia.org/wiki/Midpoint_circle_algorithm) – Wikipedia 101 | - J.Kennedy. [*A fast Bresenham type algorithm for drawing circles*](https://web.engr.oregonstate.edu/~sllu/bcircle.pdf) 102 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/graphs.md: -------------------------------------------------------------------------------- 1 | # Graphs 2 | 3 | ## Table of contents 4 | 5 | - [Data structures](#data-structures) 6 | - [Traversal](#traversal) 7 | - [Breadth-first search (BFS)](#breadth-first-search-bfs) 8 | - [Depth-first search (DFS)](#depth-first-search-dfs) 9 | - [Morris traversal](#morris-traversal) 10 | - [Cycle detection](#cycle-detection) 11 | - [Topological sorting](#topological-sorting) 12 | - [DFS-based topological sorting](#dfs-based-topological-sorting) 13 | - [Kahn’s algorithm](#kahns-algorithm) 14 | - [Connectivity](#connectivity) 15 | - [Biconnectivity](#biconnectivity) 16 | - [Articulation points and bridges](#articulation-points-and-bridges) 17 | - [Biconnected components](#biconnected-components) 18 | - [Shortest path](#shortest-path) 19 | - [Single source shortest paths](#single-source-shortest-paths) 20 | - [Dijsktra’s algorithm](#dijsktras-algorithm) 21 | - [Bellman–Ford’s algorithm](#bellmanfords-algorithm) 22 | - [A\* algorithm](#a-algorithm) 23 | - [All pairs shortest paths](#all-pairs-shortest-paths) 24 | - [Floyd–Warshall’s algorithm](#floydwarshalls-algorithm) 25 | - [Route planning](#route-planning) 26 | - [Minimum spanning tree](#minimum-spanning-tree) 27 | - [Kruskal’s algorithm](#kruskals-algorithm) 28 | 29 | --- 30 | 31 | 38 | 39 | ## Data structures 40 | 41 | :book: 42 | 43 | - Sec. 5.2: *Data structures for graphs* – S.S.Skiena. *The algorithm design manual* – Springer (2008) 44 | 45 | --- 46 | 47 | ## Traversal 48 | 49 | :book: 50 | 51 | - Sec. 6.4: *Tree traversal* – Drozdek A. *Data structures and algorithms in C++* – Cengage Learning (2012) 52 | 53 | ### Breadth-first search (BFS) 54 | 55 | > Breadth-first search is an algorithm for traversing or searching a graph that explores all of the neighbour nodes at the present depth prior to moving on to the nodes at the next depth level. 56 | 57 | :link: 58 | 59 | - [*Breadth-first search* – Wikipedia](https://en.wikipedia.org/wiki/Breadth-first_search) 60 | 61 | :movie_camera: 62 | 63 | - [*Breadth-first search*](https://www.youtube.com/watch?v=s-CYnVz-uh4) – MIT OCW 6.006: [Introduction to algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/index.htm) (2011) 64 | 65 | :book: 66 | 67 | - Sec. 22.2: *Breadth-first search* – T.H.Cormen, C.E.Leiserson, R.L.Rivest, C.Stein. [*Introduction to algorithms*](https://mitpress.mit.edu/books/introduction-algorithms-third-edition) (2009) 68 | - Sec. 5.6: *Breadth-first search* – S.S.Skiena. [*The algorithm design manual*](http://www.algorist.com/) (2008) 69 | - Sec. 4.2.2: *Breadth first search* – S.Halim, F.Halim. [*Competitive programming*](https://cpbook.net/) (2013) 70 | 71 | 76 | 77 | ### Depth-first search (DFS) 78 | 79 | > Depth-first search is an algorithm for traversing or searching a graph that explores as far as possible along each branch before backtracking. It can be used for [cycle detection](#cycle-detection), [topological sorting](#dfs-based-topological-sorting), finding [articulation points and bridges](#articulation-points-and-bridges), finding [biconnected components](#biconnected-components). 80 | 81 | :movie_camera: 82 | 83 | - [*Depth-first search (DFS)*](https://www.youtube.com/watch?v=AfSk24UTFS8) – MIT OCW 6.006 [Introduction to algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/index.htm) (2011) 84 | 85 | :book: 86 | 87 | - Sec. 22.3: *Depth-first search* – T.H.Cormen, C.E.Leiserson, R.L.Rivest, C.Stein. [*Introduction to algorithms*](https://mitpress.mit.edu/books/introduction-algorithms-third-edition) (2009) 88 | - Sec. 5.8: *Depth-first search*, Sec. 5.10: *Depth-first search on directed graphs* – S.S.Skiena. [*The algorithm design manual*](http://www.algorist.com/) (2008) 89 | - Sec. 4.2.1: *Depth first search* – S.Halim, F.Halim. [*Competitive programming*](https://cpbook.net/) (2013) 90 | 91 | #### Morris traversal 92 | 93 | :link: 94 | 95 | - [*Morris in-order traversal using threading*](https://en.wikipedia.org/wiki/Tree_traversal#Morris_in-order_traversal_using_threading) – Wikipedia 96 | 97 | :grey_question: 98 | 99 | - [*Explain Morris inorder tree traversal without using stacks or recursion*](https://stackoverflow.com/q/5502916) – Stack Overflow 100 | 101 | :movie_camera: 102 | 103 | - N.Ormrod. [*Fantastic algorithms and where to find them: Morris traversal*](https://www.youtube.com/watch?v=YA-nB2wjVcI&t=703) – CppCon (2017) 104 | 105 | :page_facing_up: 106 | 107 | - P.Mateti, R.Manghirmalani. *Morris’ tree traversal algorithm reconsidered* – [Science of Computer Programming **11**, 29](https://doi.org/10.1016/0167-6423%2888%2990063-9) (1988) 108 | - J.M.Morris. *Traversing binary trees simply and cheaply* – [Information Processing Letters **9**, 197](https://doi.org/10.1016/0020-0190%2879%2990068-1) (1979) 109 | 110 | ### Cycle detection 111 | 112 | :movie_camera: 113 | 114 | - [*Depth-first search (DFS)*](https://www.youtube.com/AfSk24UTFS8?t=1093) – MIT OCW 6.006: [Introduction to algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/index.htm) (2011) 115 | 116 | ### Topological sorting 117 | 118 | > Topological sorting of a directed acyclic graph (DAG) is a linear ordering of its vertices such that for every directed edge (u → v), vertex `u` comes before vertex `v` in the ordering. 119 | 120 | :link: 121 | 122 | - [*Topological sorting*](https://en.wikipedia.org/wiki/Topological_sorting) – Wikipedia 123 | - [*Topological sorting*](http://www3.cs.stonybrook.edu/~algorith/files/topological-sorting.shtml) – SB Algorithm Repository 124 | 125 | :book: 126 | 127 | - Sec. 4.2.5: *Topological sort* – S.Halim, F.Halim. [*Competitive programming*](https://cpbook.net/) (2013) 128 | - Sec. 3.6: *Directed acyclic graphs and topological ordering* – J.Kleinberg, É.Tardos. [*Algorithm design*](https://www.cs.cornell.edu/home/kleinber/) – [Pearson](https://www.pearson.com/us/higher-education/program/Kleinberg-Algorithm-Design/PGM319216.html) (2005) 129 | 130 | :memo: 131 | 132 | - Applications: job scheduling 133 | 134 | 138 | 139 | #### DFS-based topological sorting 140 | 141 | :movie_camera: 142 | 143 | - [*Topological sort*](https://www.youtube.com/watch?v=AfSk24UTFS8&t=2515) – MIT OCW 6.006: [Introduction to algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/index.htm) (2011) 144 | 145 | :book: 146 | 147 | - Sec. 22.4: *Topological sort* – T.H.Cormen, C.E.Leiserson, R.L.Rivest, C.Stein. [*Introduction to algorithms*](https://mitpress.mit.edu/books/introduction-algorithms-third-edition) (2009) 148 | - Sec. 5.10.1: *Topological sorting* – S.S.Skiena. [*The algorithm design manual*](http://www.algorist.com/) (2008) 149 | 150 | #### Kahn’s algorithm 151 | 152 | :link: 153 | 154 | - M.Kettenis. [*`tsort.c` source code*](http://agentzh.org/misc/code/coreutils/tsort.c.html) 155 | 156 | :book: 157 | 158 | - Sec. 2.2.3: *Linked allocation* – D.E.Knuth. [*The art of computer programming.*](https://www-cs-faculty.stanford.edu/~knuth/taocp.html) *Vol. 1: Fundamental algorithms* (1997) 159 | 160 | :page_facing_up: 161 | 162 | - A.B.Kahn. *Topological sorting of large networks* – [Communications of the ACM **5**, 558](https://dx.doi.org/10.1145/368996.369025) (1962) 163 | 164 | 171 | 172 | --- 173 | 174 | ## Connectivity 175 | 176 | :link: 177 | 178 | - [*Graph connectivity* – AlgoWiki](https://algowiki-project.org/en/Graph_connectivity) 179 | 180 | :page_facing_up: 181 | 182 | - J.Hopcroft, R.Tarjan. [*Algorithm 447: Efficient algorithms for graph manipulation*](http://akira.ruc.dk/~keld/teaching/algoritmedesign_f03/Artikler/06/Hopcroft73.pdf) – [Communications of the ACM **16**, 372](https://doi.org/10.1145/362248.362272) (1973) 183 | 184 | ### Biconnectivity 185 | 186 | :book: 187 | 188 | - Ch. 30: *Connectivity*, Sec.: *Biconnectivity* – R.Sedgewick. *Algorithms* (1983) 189 | - Sec. 6.4: *Biconnected components and DFS* – E.Horowitz, S.Sahni, S.Rajasekaran. *Computer algorithms* (1997) 190 | 191 | #### Articulation points and bridges 192 | 193 | > An articulation point (cut vertex) is a vertex which, if deleted, would increase the number connected components. A bridge (cut adge) is an edge which, if deleted, would increase the number of connected components. 194 | 195 | :movie_camera: 196 | 197 | - W.Fiset. [*Bridges and articulation points algorithm*](https://www.youtube.com/watch?v=aZXi1unBdJA) 198 | 199 | #### Biconnected components 200 | 201 | > A biconnected component is a set of vertices mutually accessible via two distinct paths. 202 | 203 | :link: 204 | 205 | - [*Biconnected component*](https://en.wikipedia.org/wiki/Biconnected_component) – Wikipedia 206 | 207 | --- 208 | 209 | ## Shortest path 210 | 211 | ### Single source shortest paths 212 | 213 | :movie_camera: 214 | 215 | - S.Devadas. [*Single-source shortest paths problem*](https://www.youtube.com/watch?v=Aa2sqUhIn-E) – MIT OCW 6.006: [Introduction to algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/index.htm) (2011) 216 | 217 | #### Dijsktra’s algorithm 218 | 219 | :link: 220 | 221 | - [*Dijkstra’s algorithm*](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm) – Wikipedia 222 | 223 | :grey_question: 224 | 225 | - [*Why does Dijkstra’s algorithm use decrease-key?*](https://stackoverflow.com/q/9255620) – Stack Overflow 226 | - [*How to implement `O(log n)` decrease-key operation for min-heap-based priority queue?*](https://stackoverflow.com/q/17009056) – Stack Overflow 227 | 228 | :movie_camera: 229 | 230 | - S.Devadas. [*SSSP on DAGs and Dijkstra’s algorithm*](https://www.youtube.com/watch?v=2E7MmKv0Y24), [*Speeding up Dijkstra*](https://www.youtube.com/watch?v=CHvQ3q_gJ7E) – MIT OCW 6.006: [Introduction to algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/index.htm) (2011) 231 | - M.Pound. [*Dijkstra’s algorithm*](https://www.youtube.com/watch?v=GazC3A4OQTE) – Computerphile 232 | 233 | :book: 234 | 235 | - Ch. 9: *Dijkstra’s shortest-path algorithm* – Roughgarden T. [*Algorithms illuminated (Part 2): Graph algorithms and data structures*](http://timroughgarden.org/books.html) – Soundlikeyourself Publishing (2018) 236 | - Sec. 4.4: *Shortest paths in a graph* – J.Kleinberg, É.Tardos. [*Algorithm design*](https://www.cs.cornell.edu/home/kleinber/) – [Addison-Wesley](https://www.pearson.com/us/higher-education/program/Kleinberg-Algorithm-Design/PGM319216.html) (2005) 237 | - Sec. 6.3: *The single source shortest paths problem* – A.V.Aho, J.E.Hopcroft, J.D.Ullman. *Data structures and algorithms* – Addison-Wesley (1983) 238 | 239 | #### Bellman–Ford’s algorithm 240 | 241 | :movie_camera: 242 | 243 | - S.Devadas. [*SSSP on DAGs and Dijkstra’s algorithm*](https://www.youtube.com/watch?v=2E7MmKv0Y24) – MIT OCW 6.006: [Introduction to algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/index.htm) (2011) 244 | 245 | #### A\* algorithm 246 | 247 | :movie_camera: 248 | 249 | - M.Pound. [*A\* search algorithm*](https://www.youtube.com/watch?v=ySN5Wnu88nE) – Computerphile 250 | 251 | ### All pairs shortest paths 252 | 253 | #### Floyd–Warshall’s algorithm 254 | 255 | :book: 256 | 257 | - Sec. 4.5: *All-pairs shortest paths* – S.Halim, F.Halim. [*Competitive programming*](https://cpbook.net/) (2013) 258 | 259 | ### Route planning 260 | 261 | 262 | 263 | :page_facing_up: 264 | 265 | - H.Bast et al. [*Route planning in transportation networks*](https://arxiv.org/abs/1504.05140) – Technical report MSR-TR-2014-4, Microsoft Research (2015) 266 | 267 | --- 268 | 269 | ## Minimum spanning tree 270 | 271 | > A minimum spanning tree is a subset of the edges of a connected, edge-weighted undirected graph that connects all the vertices together, without any cycles and with the minimum possible total edge weight. 272 | 273 | :link: 274 | 275 | - [*Minimum spanning tree*](https://en.wikipedia.org/wiki/Minimum_spanning_tree) – Wikipedia 276 | 277 | :book: 278 | 279 | - Sec. 4.5: *The minimum spanning tree problem* – J.Kleinberg, É.Tardos. [*Algorithm design*](https://www.cs.cornell.edu/home/kleinber/) – [Pearson](https://www.pearson.com/us/higher-education/program/Kleinberg-Algorithm-Design/PGM319216.html) (2005) 280 | 281 | ### Kruskal’s algorithm 282 | 283 | :book: 284 | 285 | - Sec. 4.6: *Implementing Kruskal’s algorithm: The union-find data structure* – J.Kleinberg, É.Tardos. [*Algorithm design*](https://www.cs.cornell.edu/home/kleinber/) – [Pearson](https://www.pearson.com/us/higher-education/program/Kleinberg-Algorithm-Design/PGM319216.html) (2005) 286 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/hash_tables.md: -------------------------------------------------------------------------------- 1 | # Hash tables and hashing 2 | 3 | ## Table of contents 4 | 5 | - [Introduction and overview](#introduction-and-overview) 6 | - [Hash functions](#hash-functions) 7 | - [Fowler–Noll–Vo hash function](#fowlernollvo-hash-function) 8 | - [Cryptographic hash functions](#cryptographic-hash-functions) 9 | - [Custom hash functions](#custom-hash-functions) 10 | - [Combining hash values](#combining-hash-values) 11 | - [Hash tables](#hash-tables) 12 | - [Bloom filter](#bloom-filter) 13 | - [Extendible hashing](#extendible-hashing) 14 | - [Consistent hashing](#consistent-hashing) 15 | - [Implementations](#implementations) 16 | 17 | --- 18 | 19 | ## Introduction and overview 20 | 21 | :link: 22 | 23 | - R.L.Burk. [*Hashing: From good to perfect*](https://github.com/eugnsp/CUJ/blob/master/10.02/burk/burk.md) – C/C++ Users Journal **10** (1992) 24 | 25 | ## Hash functions 26 | 27 | > A hash function is a function that maps data of arbitrary size to fixed-size values. A good hash function satisfies two basic properties: it should be very fast to compute and it should minimize duplication of output values (collisions). Hashing in the C++ standard library is implemented via `std::hash` function object type. 28 | 29 | :link: 30 | 31 | - [*Hash function*](https://en.wikipedia.org/wiki/Hash_function) – Wikipedia 32 | 33 | :grey_question: 34 | 35 | - [*Why is XOR the default way to combine hashes?*](https://stackoverflow.com/q/5889238) – Stack Overflow 36 | - [*Why does Java’s `hashCode()` in `String` use 31 as a multiplier?*](https://stackoverflow.com/q/299304) – Stack Overflow 37 | 38 | :movie_camera: 39 | 40 | - D.Kühl. [*#Hashing*](https://www.youtube.com/watch?v=CJsQSIp7-Ig) – ACCU (2019) 41 | 42 | ### Fowler–Noll–Vo hash function 43 | 44 | > The FNV hashing algorithm is used in the `std::hash` implementation in the Microsoft standard library. 45 | 46 | ### Cryptographic hash functions 47 | 48 | See [*Hashing* – Cryptographic algorithms](cryptographic.md#hashing). 49 | 50 | ### Custom hash functions 51 | 52 | :link: 53 | 54 | - [*xxHash – Extremely fast hash algorithm*](https://github.com/Cyan4973/xxHash) 55 | 56 | ### Combining hash values 57 | 58 | :anchor: 59 | 60 | - N.Josuttis. [*Convenience functions to combine hash values*](https://wg21.link/n3876) – WG21/N3876 61 | 62 | ## Hash tables 63 | 64 | > A hash table is a data structure that implements an associative array abstract data type, a structure that can map keys to values. A hash table uses a hash function to compute an index into an array of buckets or slots, from which the desired value can be found. Hash tables in the C++ standard library go by the names of `std::unordered_[multi]set` and `std::unordered_[multi]map`. See [*Unordered containers* – The standard library](../cpp/std_library.md#unordered-containers). 65 | 66 | :link: 67 | 68 | - [*Hash table*](https://en.wikipedia.org/wiki/Hash_table) – Wikipedia 69 | - [*Hashtable benchmarks*](https://github.com/google/hashtable-benchmarks) 70 | 71 | :grey_question: 72 | 73 | - [*Why should hash functions use a prime number modulus?*](https://stackoverflow.com/q/1145217) – Stack Overflow 74 | - [*Does making array size a prime number help in hash table implementation? Why?*](https://www.quora.com/Does-making-array-size-a-prime-number-help-in-hash-table-implementation-Why) – Quora 75 | 76 | :movie_camera: 77 | 78 | - M.Kulukundis. [*Designing a fast, efficient, cache-friendly hash table, step by step*](https://www.youtube.com/watch?v=CJsQSIp7-Ig) – CppCon (2017) 79 | 80 | ### Bloom filter 81 | 82 | > Bloom filter is a space-efficient probabilistic data structure that is used to test whether an element is a member of a set. False positive matches are possible, but false negatives are not. 83 | 84 | :link: 85 | 86 | - [*Bloom filter*](https://en.wikipedia.org/wiki/Bloom_filter) – Wikipedia 87 | - [*Bloom filter calculator*](https://hur.st/bloomfilter/) 88 | - M.Majkowski. [*When Bloom filters don’t bloom*](https://blog.cloudflare.com/when-bloom-filters-dont-bloom/) (2020) 89 | - J.Talbot. [*What are Bloom filters?*](https://blog.medium.com/what-are-bloom-filters-1ec2a50c68ff) (2015) 90 | 91 | :movie_camera: 92 | 93 | - A.Deutsch. [*Esoteric data structures and where to find them: Bloom filter*](https://www.youtube.com/watch?v=-8UZhDjgeZU&t=603) – CppCon (2017) 94 | - R.Edwards. [*Bloom filters*](https://www.youtube.com/watch?v=heEDL9usFgs) 95 | - N.L.Gowda. [*Bloom filter for system design*](https://www.youtube.com/watch?v=Bay3X9PAX5k) 96 | 97 | :page_facing_up: 98 | 99 | - A.Broder, M.Mitzenmacher. [*Network applications of Bloom filters: A survey*](https://www.cs.princeton.edu/courses/archive/spring05/cos598E/bib/broder-survey.pdf) – [Internet Mathematics **1**, 485](https://doi.org/10.1080/15427951.2004.10129096) (2004) 100 | - B.H.Bloom. [*Space/time trade-offs in hash coding with allowable errors*](https://www.cs.princeton.edu/courses/archive/spring05/cos598E/bib/p422-bloom.pdf) – [Communications of the ACM **13**, 422](https://doi.org/10.1145/362686.362692) (1970) 101 | 102 | :book: 103 | 104 | - Sec. 12.5: *Bloom filters: The basics*, Sec. 12.6: *Bloom filters: Heuristic analysis* – Roughgarden T. [*Algorithms illuminated (Part 2): Graph algorithms and data structures*](http://timroughgarden.org/books.html) – Soundlikeyourself Publishing (2018) 105 | 106 | :dizzy: 107 | 108 | - J.Davies. [*Bloom filters*](https://www.jasondavies.com/bloomfilter/) 109 | 110 | ### Extendible hashing 111 | 112 | > Extendible hashing is a type of hash system that treats a hash as a bit string and uses a trie for bucket lookup. 113 | 114 | :link: 115 | 116 | - [*Extendible hashing*](https://en.wikipedia.org/wiki/Extendible_hashing) – Wikipedia 117 | 118 | 119 | ## Consistent hashing 120 | 121 | :link: 122 | 123 | - [*Consistent hashing*](https://en.wikipedia.org/wiki/Consistent_hashing) – Wikipedia 124 | - M.Nielsen. [*Consistent hashing*](http://michaelnielsen.org/blog/consistent-hashing/) (2009) 125 | 126 | ## Implementations 127 | 128 | :grey_question: 129 | 130 | - [*Super high performance C/C++ hash map (table, dictionary)*](https://stackoverflow.com/q/3300525) – Stack Overflow 131 | 132 | 139 | 140 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/heaps.md: -------------------------------------------------------------------------------- 1 | # Heaps 2 | 3 | ## Table of contents 4 | 5 | - [General information](#general-information) 6 | - [Binary heaps](#binary-heaps) 7 | 8 | --- 9 | 10 | ## General information 11 | 12 | > A heap is a tree-based data structure which is an almost complete tree that satisfies the heap property: in a max heap, for any given node `C`, if `P` is a parent node of `C`, then the key of `P` is greater than or equal to the key of `C`. 13 | 14 | :link: 15 | 16 | - [*Heap*](https://en.wikipedia.org/wiki/Heap_(data_structure)) – Wikipedia 17 | 18 | ## Binary heaps 19 | 20 | :link: 21 | 22 | - [*Binary heap*](https://en.wikipedia.org/wiki/Binary_heap) – Wikipedia 23 | 24 | :grey_question: 25 | 26 | - [*Argument for `O(1)` average-case complexity of heap insertion*](https://stackoverflow.com/q/39514469) – Stack Overflow 27 | - [*Amortized analysis on min-heap?*](https://stackoverflow.com/q/29103659) – Stack Overflow 28 | - [*How to implement `O(log n)` decrease-key operation for min-heap-based priority queue?*](https://stackoverflow.com/q/17009056) – Stack Overflow 29 | 30 | :book: 31 | 32 | - Ch. 10: *The heap data structure* – Roughgarden T. [*Algorithms illuminated (Part 2): Graph algorithms and data structures*](http://timroughgarden.org/books.html) – Soundlikeyourself Publishing (2018) 33 | 34 | 36 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/lists.md: -------------------------------------------------------------------------------- 1 | # Lists 2 | 3 | ## Table of contents 4 | 5 | - [General information](#general-information) 6 | - [Singly linked lists](#singly-linked-lists) 7 | - [Doubly linked lists](#doubly-linked-lists) 8 | - [XOR doubly linked lists](#xor-doubly-linked-lists) 9 | - [Circular lists](#circular-lists) 10 | - [Skip lists](#skip-lists) 11 | 12 | --- 13 | 14 | ## General information 15 | 16 | :link: 17 | 18 | - [*Linked list*](https://en.wikipedia.org/wiki/Linked_list) – Wikipedia 19 | - B.Stroustrup. [*Are lists evil?*](http://www.stroustrup.com/bs_faq.html#list) – B.Stroustrup’s FAQ 20 | - K.Hedström. [*Number crunching: Why you should never, ever, **ever** use linked-list in your code again*](https://kjellkod.wordpress.com/2012/02/25/why-you-should-never-ever-ever-use-linked-list-in-your-code-again/) (2012) 21 | 22 | :movie_camera: 23 | 24 | - B.Stroustrup. [*Why you should avoid linked lists*](https://www.youtube.com/watch?v=YQs6IC-vgmo) – Going Native (2012) 25 | - S.Bagley. [*Arrays vs linked lists*](https://www.youtube.com/watch?v=DyG9S9nAlUM) – Computerphile (2017) 26 | 27 | :book: 28 | 29 | - Ch. 3: *Linked lists* – Drozdek A. *Data structures and algorithms in C++* – Cengage Learning (2012) 30 | 31 | --- 32 | 33 | ## Singly linked lists 34 | 35 | > A singly linked list contains nodes which have a data field, and `next` field, which points to the next node in the list. In the C++ standard library a singly linked list is implemented in `std::forward_list` class template (also known as `std::slist` in some extensions before it was standardized). See [*std::forward_list* – The standard library](../cpp/std_library.md#stdforward_list). 36 | 37 | :book: 38 | 39 | - Sec. 3.1: *Singly linked lists* – Drozdek A. *Data structures and algorithms in C++* – Cengage Learning (2012) 40 | 41 | :page_facing_up: 42 | 43 | - Z.Shao, J.H.Reppy, A.W.Appel. [*Unrolling lists*](http://flint.cs.yale.edu/flint/publications/listrep.ps.gz) – [ACM conference on LISP and functional programming, 185](https://doi.org/10.1145/182409.182453) (1994) 44 | 45 | :anchor: 46 | 47 | - [*`std::forward_list`*](https://en.cppreference.com/w/cpp/container/forward_list) – C++ reference 48 | 49 | --- 50 | 51 | ## Doubly linked lists 52 | 53 | > A doubly linked list contains nodes which have a data field, and `next` and `prev` fields, which point to the next and to the previous nodes in the list, respectively. In the C++ standard library a doubly linked list is implemented in `std::list` class template. See [*std::list* – The standard library](../cpp/std_library.md#stdlist). 54 | 55 | :link: 56 | 57 | - [*Doubly linked list*](https://en.wikipedia.org/wiki/Doubly_linked_list) – Wikipedia 58 | 59 | :book: 60 | 61 | - Sec. 3.2: *Doubly linked lists* – Drozdek A. *Data structures and algorithms in C++* – Cengage Learning (2012) 62 | 63 | :anchor: 64 | 65 | - [*`std::list`*](https://en.cppreference.com/w/cpp/container/list) – C++ reference 66 | 67 | ### XOR doubly linked lists 68 | 69 | :memo: 70 | 71 | - If garbage collection is enabled, XOR linked list needs to declare its nodes reachable. For C++, see [`std::declare_reachable`](https://en.cppreference.com/w/cpp/memory/gc/declare_reachable) – C++ reference. 72 | 73 | :link: 74 | 75 | - [*XOR linked list*](https://en.wikipedia.org/wiki/XOR_linked_list) – Wikipedia 76 | - P.Sinha. [*A memory-efficient doubly linked list*](https://www.linuxjournal.com/article/6828) – Linux Journal 77 | 78 | ### Circular lists 79 | 80 | - Sec. 3.3: *Circular lists* – Drozdek A. *Data structures and algorithms in C++* – Cengage Learning (2012) 81 | 82 | --- 83 | 84 | ## Skip lists 85 | 86 | See [*Skip lists* – Randomized algorithms and probabilistic data structures](random.md#skip-lists) 87 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/misc.md: -------------------------------------------------------------------------------- 1 | # Miscellaneous datastructures 2 | 3 | - [*Colonies, performance and why you should care* – M.Bentley @ CppCon (2016)](https://www.youtube.com/watch?v=wBER1R8YyGY) 4 | 5 | ## Volumetric data structures 6 | 7 | - [OpenVDB: An open source data structure and toolkit for high-resolution volumes](https://www.youtube.com/watch?v=7hUH92xwODg) 8 | 9 | 12 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/numeric.md: -------------------------------------------------------------------------------- 1 | # Numeric data structures and algorithms 2 | 3 | ## Table of contents 4 | 5 | - [Introduction and overview](#introduction-and-overview) 6 | - [Floating-point arithmetic](#floating-point-arithmetic) 7 | - [IEEE 754](#ieee-754) 8 | - [Denormal numbers](#denormal-numbers) 9 | - [NaNs](#nans) 10 | - [Applications](#applications) 11 | - [History](#history) 12 | - [Arithmetic algorithms](#arithmetic-algorithms) 13 | - [Common functions](#common-functions) 14 | - [Powers and logarithms](#powers-and-logarithms) 15 | - [Square root](#square-root) 16 | - [Inverse square root](#inverse-square-root) 17 | - [Greatest common divisor (GCD)](#greatest-common-divisor-gcd) 18 | - [Euclidean algorithm](#euclidean-algorithm) 19 | - [Binary Euclidean algorithm (Stein’s algorithm)](#binary-euclidean-algorithm-steins-algorithm) 20 | - [Interpolation](#interpolation) 21 | - [Arithmetic means](#arithmetic-means) 22 | - [Binomial coefficient](#binomial-coefficient) 23 | - [Division algorithms](#division-algorithms) 24 | - [Integer division](#integer-division) 25 | - [Horner’s method](#horners-method) 26 | - [Kahan summation algorithm](#kahan-summation-algorithm) 27 | - [Prime numbers](#prime-numbers) 28 | - [Linear equations solution algorithms](#linear-equations-solution-algorithms) 29 | - [Iterative methods](#iterative-methods) 30 | - [Jacobi method](#jacobi-method) 31 | - [Matrix diagonalization](#matrix-diagonalization) 32 | - [Jacobi eigenvalue algorithm](#jacobi-eigenvalue-algorithm) 33 | - [Wavelets](#wavelets) 34 | - [Applications](#applications-1) 35 | - [Finite elements and finite volume methods](#finite-elements-and-finite-volume-methods) 36 | 37 | --- 38 | 39 | ## Introduction and overview 40 | 41 | :link: 42 | 43 | - R.Munafo. [*Notable properties of specific numbers*](https://mrob.com/pub/math/numbers.html) 44 | 45 | :movie_camera: 46 | 47 | - S.Strogatz. [*The beauty of calculus*](https://www.youtube.com/watch?v=1r6893ga_So) (2019) 48 | - S.Strogatz. [*The joy of `x`: A guided tour of math*](https://www.youtube.com/watch?v=lmL8RKB7mlE) (2014) 49 | 50 | --- 51 | 52 | ## Floating-point arithmetic 53 | 54 | > Floating-point arithmetic is arithmetic in which real numbers are represented approximately to a fixed number of significant digits and scaled using an exponent in some fixed base: r = significand × baseexponent. The relative error due to rounding is uniform, i.e. it is independent of the magnitude of the number. The binary-based floating-point system has the smallest possible wobble (a range of relative errors). 55 | 56 | :link: 57 | 58 | - [*Floating-point arithmetic*](https://en.wikipedia.org/wiki/Floating-point_arithmetic) – Wikipedia 59 | - C.Moler. [*Floating point arithmetic before IEEE 754*](https://blogs.mathworks.com/cleve/2019/01/18/floating-point-arithmetic-before-ieee-754/) (2019) 60 | 61 | :book: 62 | 63 | - Essay 3: *Floating-point arithmetic*, Essay 5: *Safe math* – P.J.Plauger. [*Programming on purpose III: Essays on software technology*](https://www.pearson.com/us/higher-education/program/Plauger-Programming-on-Purpose-III-Essays-on-Software-Technology/PGM133229.html) (1994) 64 | 65 | :page_facing_up: 66 | 67 | - J.Gustafson, I.Yonemoto. [*Beating floating point at its own game: Posit arithmetic*](http://www.johngustafson.net/pdfs/BeatingFloatingPoint.pdf) 68 | 69 | ### IEEE 754 70 | 71 | > IEEE 754 is a technical standard for floating-point arithmetic established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE). If two (non-extended) floating-point numbers in the same format are ordered, then they are ordered the same way when their bits are reinterpreted as sign-magnitude integers. NaNs are endowed with a field of bits into which software can record, say, how and/or where the NaN came into existence; no software exists now to exploit this feature. 72 | 73 | :link: 74 | 75 | - R.Harris. [*You’re going to have to think!*](https://accu.org/journals/overload/18/99/harris_1702/) – [Overload **99**](https://accu.org/journals/overload/overload99) (2010) 76 | - R.Harris. [*Why fixed point won’t cure your floating point blues*](https://accu.org/journals/overload/18/100/harris_1717/) – [Overload **100**](https://accu.org/journals/overload/overload100) (2011) 77 | - R.Harris. [*Why rationals won’t cure your floating point blues*](https://accu.org/journals/overload/19/101/harris_1986/) – [Overload **101**](https://accu.org/journals/overload/overload101) (2011) 78 | - D.Goldberg. [*What every computer scientist should know about floating-point arithmetic*](https://www.itu.dk/~sestoft/bachelor/IEEE754_article.pdf) (1991) 79 | 80 | :grey_question: 81 | 82 | - [*How many unique values are there between 0 and 1 of a standard float?*](https://stackoverflow.com/q/17949796) – Stack Overflow 83 | - [*Why does IEEE 754 reserve so many NaN values?*](https://stackoverflow.com/q/19800415) – Stack Overflow 84 | - [*How many normalized numbers can be represented using IEEE-754 single precision?*](https://stackoverflow.com/q/12558780) – Stack Overflow 85 | - [*Is assigning two `double`s guaranteed to yield the same bitset patterns?*](https://stackoverflow.com/q/55379715) – Stack Overflow 86 | 87 | :page_facing_up: 88 | 89 | - W.Kahan. [*Lecture notes on the status of IEEE standard 754 for binary floating-point arithmetic*](https://people.eecs.berkeley.edu/~wkahan/ieee754status/IEEE754.PDF) (1997) 90 | - C.Allison. [*Where did all my decimals go?*](http://uvu.freshsources.com/decimals.pdf) (2006) 91 | 92 | :book: 93 | 94 | - M.L.Overton. [*Numerical computing with IEEE floating point arithmetic*](https://doi.org/10.1137/1.9780898718072) – SIAM (2001) 95 | - Sec. 2.5: *Floating-point arithmetic* – D.H.Eberly. [*GPGPU 96 | programming for games and science*](https://www.crcpress.com/GPGPU-Programming-for-Games-and-Science/Eberly/p/book/9781466595354) – CRC Press (2014) 97 | - C.Allison. [*Floating-point numbers aren’t real*](http://freshsources.com/FPNotReal.pdf) – K.Henney. [*97 things every programmer should know*](https://www.oreilly.com/library/view/97-things-every/9780596809515/) (2010) 98 | 99 | :movie_camera: 100 | 101 | - J.Farrier. [*Demystifying floating point*](https://www.youtube.com/watch?v=k12BJGSc2Nc) – CppCon (2015) 102 | - J.Gustafson. [*Beating floats at their own game*](https://www.youtube.com/watch?v=N05yYbUZMSQ) – HPC Advisory Council Australia Conference (2017) 103 | 104 | :anchor: 105 | 106 | - [*IEEE 754*](https://en.wikipedia.org/wiki/IEEE_754) – Wikipedia 107 | 108 | #### Denormal numbers 109 | 110 | :link: 111 | 112 | - [*Denormal number*](https://en.wikipedia.org/wiki/Denormal_number) – Wikipedia 113 | - C.Moler. [*Floating point denormals, insignificant but controversial*](https://blogs.mathworks.com/cleve/2014/07/21/floating-point-denormals-insignificant-but-controversial-2/) (2014) 114 | 115 | :movie_camera: 116 | 117 | - D.Kohlbrenner. [*On subnormal floating point and abnormal timing*](https://www.youtube.com/watch?v=DftejgRgmc8) – IEEE Symposium on Security and Privacy (2015) 118 | 119 | #### NaNs 120 | 121 | :link: 122 | 123 | - A.Cherkaev. [*The secret life of NaN*](https://anniecherkaev.com/the-secret-life-of-nan) (2018) 124 | 125 | :grey_question: 126 | 127 | - [*What is the rationale for all comparisons returning false for IEEE 754 NaN values?*](https://stackoverflow.com/q/1565164) – Stack Overflow 128 | 129 | :movie_camera: 130 | 131 | - A.Cherkaev. [*The secret life of Not-a-Number*](https://www.youtube.com/watch?v=3jddE24Ep54) – Con West (2019) 132 | 133 | ### Applications 134 | 135 | :link: 136 | 137 | - M.Rayman. [*How many decimals of π do we really need?*](https://www.jpl.nasa.gov/edu/news/2016/3/16/how-many-decimals-of-pi-do-we-really-need/) – NASA (2016) 138 | 139 | ### History 140 | 141 | :link: 142 | 143 | - C.Severance. [*An interview with the old man of floating-point*](https://people.eecs.berkeley.edu/~wkahan/ieee754status/754story.html) (1998) 144 | 145 | --- 146 | 147 | ## Arithmetic algorithms 148 | 149 | :link: 150 | 151 | - T.Prince. [*Tuning up math functions*](https://github.com/eugnsp/CUJ/blob/master/10.12/prince/prince.md) – C/C++ Users Journal **10** (1992) 152 | 153 | ### Common functions 154 | 155 | :book: 156 | 157 | - Essay 6: *Do-it-yourself math functions* – P.J.Plauger. [*Programming on purpose III: Essays on software technology*](https://www.pearson.com/us/higher-education/program/Plauger-Programming-on-Purpose-III-Essays-on-Software-Technology/PGM133229.html) (1994) 158 | 159 | #### Powers and logarithms 160 | 161 | :link: 162 | 163 | - [*How to check if an integer is a power of `3`?*](https://stackoverflow.com/q/1804311) – Stack Overflow 164 | 165 | #### Square root 166 | 167 | :link: 168 | 169 | - [*Methods of computing square roots*](https://en.wikipedia.org/wiki/Methods_of_computing_square_roots) – Wikipedia 170 | - P.Martin. [*Eight rooty pieces*](https://accu.org/journals/overload/24/135/martin_2294/) – [Overload **135**](https://accu.org/journals/overload/overload135) (2016) 171 | 172 | #### Inverse square root 173 | 174 | :link: 175 | 176 | - [*Fast inverse square root*](https://en.wikipedia.org/wiki/Fast_inverse_square_root) – Wikipedia 177 | - C.Lomont. [*Fast inverse square root*](http://www.lomont.org/papers/2003/InvSqrt.pdf) (2003) 178 | 179 | 184 | 185 | ### Greatest common divisor (GCD) 186 | 187 | #### Euclidean algorithm 188 | 189 | :link: 190 | 191 | - [*Euclidean algorithm*](https://en.wikipedia.org/wiki/Euclidean_algorithm) – Wikipedia 192 | 193 | #### Binary Euclidean algorithm (Stein’s algorithm) 194 | 195 | :link: 196 | 197 | - [*Binary GCD algorithm*](https://en.wikipedia.org/wiki/Binary_GCD_algorithm) – Wikipedia 198 | 199 | ### Interpolation 200 | 201 | :link: 202 | 203 | - J.Bloch. [*Extra, Extra – Read all about it: Nearly all binary searches and mergesorts are broken*] – Google AI blog (2006) 204 | 205 | :grey_question: 206 | 207 | - [*What are the differences between the two lerp functions?*](https://stackoverflow.com/q/72668151) – Stack Overflow 208 | - [*Floating point linear interpolation*](https://stackoverflow.com/q/4353525) – Stack Overflow 209 | - [*Accurate floating-point linear interpolation*](https://math.stackexchange.com/q/907327) – Mathematics 210 | 211 | :anchor: 212 | 213 | - S.D.Herring. [*Well-behaved interpolation for numbers and pointers*](https://wg21.link/p0811) – WG21/P0811 214 | 215 | ### Arithmetic means 216 | 217 | > To compute the arithmetic mean μ = 1 / N ∑ xi in a numerically stable way, the following recurrence relation can be used: μN = μN - 1 + 1 / N (xN - μN - 1). 218 | 219 | :link: 220 | 221 | - D.Assencio. [*Numerically stable computation of arithmetic means*](https://diego.assencio.com/?index=c34d06f4f4de2375658ed41f70177d59) (2015) 222 | - T.Finch. [*Incremental calculation of weighted mean and variance*](https://fanf2.user.srcf.net/hermes/doc/antiforgery/stats.pdf) (2009) 223 | 224 | ### Binomial coefficient 225 | 226 | :link: 227 | 228 | - M.Dominus. [*How to calculate binomial coefficients*](https://blog.plover.com/math/choose.html) 229 | - M.Dominus. [*How to calculate binomial coefficients, again*](https://blog.plover.com/math/choose-2.html) 230 | 231 | ### Division algorithms 232 | 233 | 235 | 236 | #### Integer division 237 | 238 | :link: 239 | 240 | - I.Kaplan. [*Integer division*](http://bearcave.com/software/divide.htm) (1996) 241 | 242 | ### Horner’s method 243 | 244 | > Horner’s method is a polynomial evaluation method expressed by p(x) = a0 + a1 x + a2 x2 + ... + aN xN = a0 + x (a1 + x (a2 + ... + x (aN) ... )). 245 | 246 | :link: 247 | 248 | - [Horner’s method](https://en.wikipedia.org/wiki/Horner%27s_method) – Wikipedia 249 | 250 | ### Kahan summation algorithm 251 | 252 | :link: 253 | 254 | - [*Kahan summation algorithm*](https://en.wikipedia.org/wiki/Kahan_summation_algorithm) – Wikipedia 255 | 256 | :grey_question: 257 | 258 | - [*Kahan summation*](https://stackoverflow.com/q/4940072) – Stack Overflow 259 | 260 | --- 261 | 262 | ## Prime numbers 263 | 264 | :grey_question: 265 | 266 | - [*How many prime numbers are there (available for RSA encryption)?*](https://stackoverflow.com/q/16091581) – Stack Overflow 267 | 268 | --- 269 | 270 | ## Linear equations solution algorithms 271 | 272 | ### Iterative methods 273 | 274 | :link: 275 | 276 | - G.Strang. [*Iterative methods*](https://ocw.mit.edu/courses/mathematics/18-086-mathematical-methods-for-engineers-ii-spring-2006/readings/am62.pdf) (2006) 277 | 278 | :book: 279 | 280 | - Sec. 20.5: *Relaxation methods for boundary value problems* – W.H.Press et al. [*Numerical recipes: The art of scientific computing*](http://numerical.recipes/) (2007) 281 | 282 | #### Jacobi method 283 | 284 | > A recurrence relation: xK+1 = D-1 (D - A) xK + D-1 b, where the preconditioner `D` is the diagonal part of `A`: `D = diag(A)`. 285 | 286 | :link: 287 | 288 | - [*Jacobi method*](https://en.wikipedia.org/wiki/Jacobi_method) – Wikipedia 289 | - [*Jacobi method*](http://mathworld.wolfram.com/JacobiMethod.html) – Wolfram MathWorld 290 | 291 | :movie_camera: 292 | 293 | - G.Strang. [*Iterative methods and preconditioners*](https://www.youtube.com/watch?v=LtNVodIs1dI) – MIT 18.086 [*Mathematical methods for engineers II*](https://ocw.mit.edu/courses/mathematics/18-086-mathematical-methods-for-engineers-ii-spring-2006/) (2006) 294 | 295 | --- 296 | 297 | ## Matrix diagonalization 298 | 299 | ### Jacobi eigenvalue algorithm 300 | 301 | :link: 302 | 303 | - [*Jacobi eigenvalue algorithm*](https://en.wikipedia.org/wiki/Jacobi_eigenvalue_algorithm) – Wikipedia 304 | - J.Lambers. [*Jacobi methods*](https://web.stanford.edu/class/cme335/lecture7.pdf) – CME 335 (2010) 305 | 306 | :book: 307 | 308 | - Sec. 11.1: *Jacobi transformations of a symmetric matrix* – W.H.Press et al. [*Numerical recipes: The art of scientific computing*](http://numerical.recipes/) (2007) 309 | - Sec. 8.5: *Jacobi methods* – G.H.Golub, C.F.Van Loan. [*Matrix computations*](https://my.siam.org/Store/Product/viewproduct/?ProductId=23915573) – SIAM (2013) 310 | - H.Rutishause. Contrib. II/1: *The Jacobi method for real symmetric matrices* – J.H.Wilkinson, C.Reinsch. [*Handbook for automatic computation. Vol. II: Linear algebra*](https://www.springer.com/gp/book/9783642869426) (1971) 311 | 312 | --- 313 | 314 | ## Wavelets 315 | 316 | :movie_camera: 317 | 318 | - G.Strang. [*Multiresolution, wavelet transform and scaling function*](https://www.youtube.com/watch?v=LtNVodIs1dI) – MIT 18.085 *Computational science and engineering I* (2008?) 319 | - G.Strang. [*Splines and orthogonal wavelets: Daubechies construction*](https://www.youtube.com/watch?v=LeafEHx9d0c) – MIT 18.085 *Computational science and engineering I* (2008?) 320 | 321 | :book: 322 | 323 | - Sec. 11.1: *Jacobi transformations of a symmetric matrix* – W.H.Press et al. [*Numerical recipes: The art of scientific computing*](http://numerical.recipes/) (2007) 324 | 325 | 330 | 331 | --- 332 | 333 | ## Applications 334 | 335 | ### Finite elements and finite volume methods 336 | 337 | :movie_camera: 338 | 339 | - D.Arnold. [*The fundamental theorem of numerical analysis*](https://www.youtube.com/watch?v=mmIrLgCFFhM) – Annual conference of the Great Lakes section of the SIAM (2015) 340 | - P.Roe. [*Colorful fluid dynamics: Behind the scenes*](https://www.youtube.com/watch?v=uaH91P665PI) – AE585 Seminar lecture series (2014) 341 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/optimization.md: -------------------------------------------------------------------------------- 1 | # Optimization algorithms 2 | 3 | ## Table of contents 4 | 5 | - [Linear programming](#linear-programming) 6 | - [Dynamic programming](#dynamic-programming) 7 | - [Knapsack](#knapsack) 8 | - [Linear partition](#linear-partition) 9 | - [Longest increasing subsequence](#longest-increasing-subsequence) 10 | 11 | --- 12 | 13 | ### Linear programming 14 | 15 | :link: 16 | 17 | - [*Linear programming*](https://en.wikipedia.org/wiki/Linear_programming) – Wikipedia 18 | 19 | :movie_camera: 20 | 21 | - S.Devadas. [*Linear programming: LP, reductions, simplex*](https://www.youtube.com/watch?v=WwMz2fJwUCg) – MIT OCW 6.046J: [Design and analysis of algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-design-and-analysis-of-algorithms-spring-2015/) (2015) 22 | 23 | --- 24 | 25 | ### Dynamic programming 26 | 27 | > Dynamic programming is a method of solving optimization problems by breaking them into sub-problems and then recursively finding the optimal solutions to the sub-problems. All problems amenable to dynamic programming solution share the following two properties: *optimal substructure* (the optimal solution can be obtained given the optimal solutions of subproblems), and *overlapping subproblems* (sub-problems share sub-sub-problems). 28 | 29 | :link: 30 | 31 | - [*Dynamic programming*](https://en.wikipedia.org/wiki/Dynamic_programming) – Wikipedia 32 | - [*Weak NP-completeness*](https://en.wikipedia.org/wiki/Weak_NP-completeness) – Wikipedia 33 | 34 | :grey_question: 35 | 36 | - [*Knapsack problem — NP-complete despite dynamic programming solution?*](https://cs.stackexchange.com/q/909) – Computer Science 37 | 38 | :movie_camera: 39 | 40 | - *Dynamic programming.* [Part I](https://www.youtube.com/watch?v=OQ5jsbhAv_M), [Part II](https://www.youtube.com/watch?v=ENyox7kNKeY), [Part III](https://www.youtube.com/watch?v=ocZMDMZwhCY), [Part IV](https://www.youtube.com/watch?v=tp4_UXaVyx8) – MIT 6.006: [Introduction to algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/index.htm) (2011) 41 | 42 | :book: 43 | 44 | - Ch. 8: *Dynamic programming* – S.S.Skiena. [*The algorithm design manual*](http://www.algorist.com/) (2008) 45 | 46 | --- 47 | 48 | #### Knapsack 49 | 50 | 51 | 52 | 53 | 54 | --- 55 | 56 | #### Linear partition 57 | 58 | > Problem: partition (without reordering) a set of non-negative integral numbers into `k` ranges such that the maximum sum over all the ranges is minimized. 59 | 60 | :memo: 61 | 62 | - This problem has another solution based on binary searching the answer in the space of possible answers that is obtained using a greedy approach. 63 | 64 | :book: 65 | 66 | - Sec. 8.5: *The partition problem* – S.S.Skiena. [*The algorithm design manual*](http://www.algorist.com/) (2008) 67 | - Sec. 8.4.1: *Two components: Binary search the answer and other* – S.Halim, F.Halim. [*Competitive programming*](https://cpbook.net/) (2013) 68 | 69 | --- 70 | 71 | #### Longest increasing subsequence 72 | 73 | See [Sequence algorithms – Longest increasing subsequence](sequence_algorithms.md#longest-increasing-subsequence). 74 | 75 | 76 | 84 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/parsing.md: -------------------------------------------------------------------------------- 1 | # Parsers and compilers 2 | 3 | ## Table of contents 4 | 5 | - [Parsers](#parsers) 6 | - [Bottom-up](#bottom-up) 7 | - [Shunting yard algorithm](#shunting-yard-algorithm) 8 | - [Parsing XML](#parsing-xml) 9 | - [Compilers](#compilers) 10 | - [Introduction and overview](#introduction-and-overview) 11 | - [Optimizations](#optimizations) 12 | 13 | --- 14 | 15 | ## Parsers 16 | 17 | ### Bottom-up 18 | 19 | #### Shunting yard algorithm 20 | 21 | :link: 22 | 23 | - [*Shunting-yard algorithm*](https://en.wikipedia.org/wiki/Shunting-yard_algorithm) – Wikipedia 24 | - [*Shunting yard algorithm*](https://web.archive.org/web/20180807214703/http://wcipeg.com/wiki/Shunting_yard_algorithm) – PEGWiki 25 | - T.Norvell. [*Parsing expressions by recursive descent*](https://www.engr.mun.ca/~theo/Misc/exp_parsing.htm#shunting_yard) 26 | - N.Reed. [*The shunting-yard algorithm*](http://www.reedbeta.com/blog/the-shunting-yard-algorithm/) – N.Reed blog 27 | - Z.Nasibov. [*Inside the mathematical expressions evaluator*](https://www.codeproject.com/Articles/21137/Inside-the-Mathematical-Expressions-Evaluator) – CodeProject 28 | - B.Miller, D.Ranum. [*General infix-to-postfix conversion*](https://interactivepython.org/runestone/static/pythonds/BasicDS/InfixPrefixandPostfixExpressions.html#general-infix-to-postfix-conversion) 29 | 30 | ### Parsing XML 31 | 32 | :link: 33 | 34 | - A.Kapoulkine. [*Parsing XML at the speed of light*](https://www.aosabook.org/en/posa/parsing-xml-at-the-speed-of-light.html) – The Performance of Open Source Applications 35 | 36 | --- 37 | 38 | ## Compilers 39 | 40 | See also [*Optimizations* – Hardware, optimization, and OS internals](../cpp/optimization_and_hardware.md#optimizations). 41 | 42 | ### Introduction and overview 43 | 44 | :link: 45 | 46 | - A.Balaam. [*How to write a programming language: Part 1, The lexer*](https://accu.org/journals/overload/26/145/balaam_2510/) – [Overload **145**](https://accu.org/journals/overload/overload145) (2018) 47 | - A.Balaam. [*How to write a programming language: Part 2, The parser*](https://accu.org/journals/overload/26/146/balaam_2532/) – [Overload **146**](https://accu.org/journals/overload/overload146) (2018) 48 | - A.Balaam. [*How to write a programming language: Part 3, The evaluator*](https://accu.org/journals/overload/26/147/balaam_2565/) – [Overload **147**](https://accu.org/journals/overload/overload147) (2018) 49 | 50 | ### Optimizations 51 | 52 | See also 53 | 54 | - G.Horváth. [*Algorithms from a compiler developer’s toolbox*](https://www.youtube.com/watch?v=eeS1WP7FK-A) – C++Now (2021 55 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/random.md: -------------------------------------------------------------------------------- 1 | # Randomized algorithms and probabilistic data structures 2 | 3 | ## Table of contents 4 | 5 | - [Probability theory](#probability-theory) 6 | - [Random numbers generation](#random-numbers-generation) 7 | - [Distributions](#distributions) 8 | - [Uniform distribution](#uniform-distribution) 9 | - [Normal distribution](#normal-distribution) 10 | - [Marsaglia polar method](#marsaglia-polar-method) 11 | - [Sampling](#sampling) 12 | - [Selection sampling](#selection-sampling) 13 | - [Reservoir sampling](#reservoir-sampling) 14 | - [Shuffling](#shuffling) 15 | - [Fisher–Yates algorithm](#fisheryates-algorithm) 16 | - [Probabilistic data structures](#probabilistic-data-structures) 17 | - [Skip lists](#skip-lists) 18 | - [HyperLogLog](#hyperloglog) 19 | 20 | --- 21 | 22 | ## Probability theory 23 | 24 | :movie_camera: 25 | 26 | - E.Lawrence. *Why use measure theory for probability?* [Part I](https://www.youtube.com/watch?v=RjPXfUT7Odo), [Part II](https://www.youtube.com/watch?v=Q9KOeP-nrYQ), [Part III](https://www.youtube.com/watch?v=rAYA2Mu51bw) (2012) 27 | 28 | --- 29 | 30 | ## Random numbers generation 31 | 32 | For cryptographically secure random number generation see [*Random numbers generation* – Cryptographic algorithms and data structures](cryptographic.md#random-numbers-generation). 33 | 34 | :link: 35 | 36 | - M.Marini. [*A class hierarchy for random number generation*](https://github.com/eugnsp/CUJ/blob/master/14.10/marini/marini.md) – C/C++ Users Journal **14** (1996) 37 | 38 | :movie_camera: 39 | 40 | - R.Michaels. [*Fast, high-quality pseudo-random numbers for non-cryptographers*](https://www.youtube.com/watch?v=I5UY3yb0128) – CppCon (2022) 41 | 42 | :anchor: 43 | 44 | - [*Xorshift*](https://en.wikipedia.org/wiki/Xorshift) – Wikipedia 45 | 46 | --- 47 | 48 | ## Distributions 49 | 50 | ### Uniform distribution 51 | 52 | - D.Lemire. [*Nearly divisionless random integer generation on various systems*](https://lemire.me/blog/2019/06/06/nearly-divisionless-random-integer-generation-on-various-systems/) (2019) 53 | 54 | :anchor: 55 | 56 | - [*`std::uniform_int_distribution`*](https://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution) – C++ reference 57 | - [*`std::uniform_real_distribution`*](https://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution) – C++ reference 58 | 59 | ### Normal distribution 60 | 61 | :anchor: 62 | 63 | - [*`std::normal_distribution`*](https://en.cppreference.com/w/cpp/numeric/random/normal_distribution) – C++ reference 64 | 65 | #### Marsaglia polar method 66 | 67 | > This method is used in some implementations (e.g., in `libstdc++` and `MSVC STL`) of `std::normal_distribution`. 68 | 69 | :anchor: 70 | 71 | - [*Marsaglia polar method*](https://en.wikipedia.org/wiki/Marsaglia_polar_method) – Wikipedia 72 | 73 | --- 74 | 75 | ## Sampling 76 | 77 | :book: 78 | 79 | - Sec. 3.4.2: *Random sampling and shuffling* – D.E.Knuth. [*The art of computer programming.*](https://www-cs-faculty.stanford.edu/~knuth/taocp.html) *Vol. 2: Seminumerical algorithms* (1997) 80 | - Col. 12: *A sample problem* – J.Bentley. [*Programming pearls*](https://www.oreilly.com/library/view/programming-pearls-second/9780134498058/) (1999) 81 | 82 | ### Selection sampling 83 | 84 | :link: 85 | 86 | - [*Knuth’s algorithm S*](https://rosettacode.org/wiki/Knuth%27s_algorithm_S) – Rosetta Code 87 | - B.Rieck. [*A technique for selection sampling (sampling without replacement)*](http://bastian.rieck.me/blog/posts/2017/selection_sampling/) 88 | 89 | :page_facing_up: 90 | 91 | - J.S.Vitter. [*An efficient algorithm for sequential random sampling*](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.94.1689&rep=rep1&type=pdf) – [ACM Transactions on Mathematical Software **13**, 58](https://doi.org/10.1145/23002.23003) (1987) 92 | 93 | ### Reservoir sampling 94 | 95 | :link: 96 | 97 | - [*Reservoir sampling*](https://en.wikipedia.org/wiki/Reservoir_sampling) – Wikipedia 98 | 99 | :movie_camera: 100 | 101 | - N.Ormrod. [*Fantastic algorithms and where to find them: Reservoir sampling*](https://www.youtube.com/watch?v=YA-nB2wjVcI&t=1268) – CppCon (2017) 102 | 103 | --- 104 | 105 | ## Shuffling 106 | 107 | :link: 108 | 109 | - J.Atwood. [*The danger of naïveté*](https://blog.codinghorror.com/the-danger-of-naivete/) (2007) 110 | 111 | :book: 112 | 113 | - Sec. 3.4.2: *Random sampling and shuffling* – D.E.Knuth. [*The art of computer programming.*](https://www-cs-faculty.stanford.edu/~knuth/taocp.html) *Vol. 2: Seminumerical algorithms* (1997) 114 | 115 | ### Fisher–Yates algorithm 116 | 117 | :link: 118 | 119 | - [*Fisher–Yates shuffle*](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle) – Wikipedia 120 | - [*Knuth shuffle*](https://www.rosettacode.org/wiki/Knuth_shuffle) – Rosetta Code 121 | 122 | --- 123 | 124 | ## Probabilistic data structures 125 | 126 | ### Skip lists 127 | 128 | :grey_question: 129 | 130 | - [*How does a skip list work?*](https://softwareengineering.stackexchange.com/q/287254) – Software Engineering 131 | 132 | :movie_camera: 133 | 134 | - [*Randomization: Skip lists*](https://www.youtube.com/watch?v=2g9OSRKJuzM) – MIT OCW 6.046J/18.410J: [Design and analysis of algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-design-and-analysis-of-algorithms-spring-2015/) (2015) 135 | 136 | :book: 137 | 138 | - Sec. 3.4: *Skip lists* – Drozdek A. *Data structures and algorithms in C++* – Cengage Learning (2012) 139 | 140 | :page_facing_up: 141 | 142 | - W.Pugh. [*A skip list cookbook*](http://cglab.ca/~morin/teaching/5408/refs/p90b.pdf) – Tech. Rep. UMIACS-TR-89-72.1 (1990) 143 | 144 | --- 145 | 146 | ## HyperLogLog 147 | 148 | :link: 149 | 150 | - [*HyperLogLog*](https://en.wikipedia.org/wiki/HyperLogLog) – Wikipedia 151 | 152 | :movie_camera: 153 | 154 | - N.Ormrod. [*Fantastic algorithms and where to find them: HyperLogLog*](https://www.youtube.com/watch?v=YA-nB2wjVcI&t=1653) – CppCon (2017) 155 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/sequence.md: -------------------------------------------------------------------------------- 1 | # Sequence data structures and algorithms 2 | 3 | ## Table of contents 4 | 5 | - [Arrays and vectors](#arrays-and-vectors) 6 | - [Rotation (cyclic shift)](#rotation-cyclic-shift) 7 | - [Three reverses rotation algorithm](#three-reverses-rotation-algorithm) 8 | - [Gries–Mills algorithm](#griesmills-algorithm) 9 | - [Dolphin (juggling) algoirithm](#dolphin-juggling-algoirithm) 10 | - [Circular buffer](#circular-buffer) 11 | - [Longest increasing subsequence](#longest-increasing-subsequence) 12 | - [Maximum subsequence](#maximum-subsequence) 13 | - [Kadane’s algorithm](#kadanes-algorithm) 14 | - [Majority element](#majority-element) 15 | - [Boyer–Moore majority vote algorithm](#boyermoore-majority-vote-algorithm) 16 | - [Sqrt decomposition](#sqrt-decomposition) 17 | 18 | --- 19 | 20 | ## Arrays and vectors 21 | 22 | See also [*Sequence containers* – The standard library, Boost, and proposals](../cpp/std_library.md#sequence-containers). 23 | 24 | :movie_camera: 25 | 26 | - D.Stone. [*Faster, easier, simpler vectors*](https://www.youtube.com/watch?v=MfFzr9qqPDw) – CppCon (2021) 27 | - D.Stone. [*Implementing `static_vector`: How hard could it be?*](https://www.youtube.com/watch?v=I8QJLGI0GOE) – CppCon (2021) 28 | 29 | ## Rotation (cyclic shift) 30 | 31 | > A `K`-rotation (or a `K`-cyclic shift) of a sequence {a0a2...aN-1} is a sequence {aP(1)aP(2)...aP(N-1)}, where the index permutation is `P(i) = (i + K) % N`. Any non-zero rotation has no trivial cycles. The number of (non-trivial) cycles is `gcd(K, N)`. 32 | 33 | :link: 34 | 35 | - [*Benchmarking block-swapping algorithms* – Dr. Dobb’s Journal](http://www.drdobbs.com/parallel/benchmarking-block-swapping-algorithms/232900395) 36 | 37 | :book: 38 | 39 | - Sec. 11.3: *Rotation* – A.A.Stepanov, D.E.Rose. [*From mathematics to generic programming*](http://www.fm2gp.com/) (2014) 40 | - Sec. 10.4: *Rotate algorithms* – A.A.Stepanov, P.McJones. [*Elements of programming*](http://elementsofprogramming.com/) (2009) 41 | - Sec. 2.3: *The power of primitives* – J.Bentley. *Programming pearls* (1999) 42 | 43 | :page_facing_up: 44 | 45 | - C.A.Furia. [*Rotation of sequences: Algorithms and proofs*](https://arxiv.org/abs/1406.5453) – Preprint (2014) 46 | - D.Gries, H.Mills. [*Swapping sections*]((https://hdl.handle.net/1813/6292)) – Technical report 81-452, Department of computer science, Cornell University (1981) 47 | 48 | ### Three reverses rotation algorithm 49 | 50 | > Gist of the algorithm: reverse the subsequences {a0...aK-1} and {aK...aN-1}, then reverse the whole sequence {aK-1...a0aN-1...aK}. The total number of swaps is ⌊N/2⌋ + ⌊K/2⌋ + ⌊(N-K)/2⌋ ∼ N. With 3 assignments per swap, the total number of assignments is ∼ 3N. This algorithm is typically used to implement `std::rotate` for bidirectional iterators. 51 | 52 | ### Gries–Mills algorithm 53 | 54 | > Gist of the algorithm: if `K = N - K`, swap the subsequences {a0...aK-1} and {aK...aN-1}; if `K < N - K`, swap the subsequences {a0...aK-1} and {aK...a2K-1}, then proceed recursively for the suffix subsequence {a0...aK-1a2K...aN-1} with `K' = K`; if `K > N - K`, swap the subsequences {a0...aN-K-1} and {ak...aN-1}, then proceed recursively for the suffix subsequence {aN-K...aK-1a0...aN-K-1} with `K' = 2K - N`. The section sizes `(K, N - K)` form the same sequence as that obtained if the subtraction-based Euclidean algorithm is employed to calculate `gcd(K, N)`. The total number of swaps is `N - gcd(K, N)`. With 3 assignments per swap, the total number of assignments is `3[N - gcd(K, N)]`. The Gries–Mills algorithm can be implemented such that it only requires to move one step forward, so this algorithm is typically used to implement `std::rotate` for forward and random access iterators. 55 | 56 | ### Dolphin (juggling) algoirithm 57 | 58 | > Gist of the algorithm: compute the number of cycles, `Nc = gcd(K, N - K)`; for each cycle {aCi(0)aCi(1)aCi(2)...} with `Ci(j) = (i + jK) % N, i = 0, ..., Nc - 1`, make a cyclic shift of all the elements by one position to obtain {aCi(1)aCi(2)...aCi(0)}. The total number of assignments is `N + gcd(K, N)`. However, this algorithm is not cache-friendly and can have poor performance in practice, although it makes much fewer (~2-3 times) memory accesses. This algorithm is sometimes used to implement `std::rotate` for random access iterators. 59 | 60 | :page_facing_up: 61 | 62 | - W.Fletcher, R.Silver. *Algorithm 284: Interchange of two blocks of data* – [Communications of the ACM **9**, 326](https://dx.doi.org/10.1145/355592.365609) (1966) 63 | 64 | --- 65 | 66 | ## Circular buffer 67 | 68 | > A circular buffer (cyclic buffer, ring buffer) is a data structure that uses a single, fixed-size buffer as if it were connected end-to-end. When the buffer is filled, new data is written starting at the beginning of the buffer and overwriting the old. 69 | 70 | :link: 71 | 72 | - [*Circular buffer*](https://en.wikipedia.org/wiki/Circular_buffer) – Wikipedia 73 | - B.Stout. [*“Olympic” filtering for noisy data*](https://github.com/eugnsp/CUJ/blob/master/13.03/stout/stout.md) – C/C++ Users Journal **13** (1995) 74 | 75 | :anchor: 76 | 77 | - [*Boost.Circular Buffer: The circular buffer library*](https://www.boost.org/doc/libs/release/libs/circular_buffer/) 78 | 79 | --- 80 | 81 | ## Longest increasing subsequence 82 | 83 | > Problem: find the longest monotonically increasing subsequence (not necessarily contiguous) within a given sequence. The dynamic programming solution (without additional tricks) has running time O(N2), and is not the most efficient one. The problem can be solved in `O(N log N)` time using an algorithm based on binary search. This algorithm is output-sensitive: if the size of the output, the length `K` of a subsequence, is taken into account, it requires `O(N log K)` time. Any comparison-based algorithm requires at least N log2 N - N log2 log2 N + O(N) comparisons in the worst case. 84 | 85 | :link: 86 | 87 | - [*Longest increasing subsequence*](https://en.wikipedia.org/wiki/Longest_increasing_subsequence) – Wikipedia 88 | - [*Longest increasing subsequence*](https://cp-algorithms.com/sequences/longest_increasing_subsequence.html) – CP-Algorithms 89 | 90 | :movie_camera: 91 | 92 | - [*Dynamic programming*](https://www.youtube.com/watch?v=1ivFSH0ijOM&t=2570) – MIT OCW 6.006: [Introduction to algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/index.htm) (2011) 93 | 94 | :book: 95 | 96 | - Sec. 8.3: *Longest increasing sequence* – S.S.Skiena. [*The algorithm design manual*](http://www.algorist.com/) (2008) 97 | - Sec. 3.5.2 *Classical examples* – S.Halim, F.Halim. [*Competitive programming*](https://cpbook.net/) (2013) 98 | - Sec. 6.5.2: *Finding the kth smallest element*, Sec. 6.11.1: *Longest increasing subsequence* – U.Manber. *Introduction to algorithms: A creative approach* (1989) 99 | 100 | :page_facing_up: 101 | 102 | - M.L.Fredman. [*On computing the length of longest increasing subsequences*](https://core.ac.uk/download/pdf/82290717.pdf) – [Discrete Mathematics **11**, 29](https://dx.doi.org/10.1016/0012-365X(75)90103-X) (1975) 103 | 104 | 105 | 106 | --- 107 | 108 | ## Maximum subsequence 109 | 110 | > Problem: find a contiguous subsequence with the largest sum within a given one-dimensional sequence. 111 | 112 | :book: 113 | 114 | - Col. 8: *Searching* – J.Bentley. [*Algorithm design techniques*](https://www.oreilly.com/library/view/programming-pearls-second/9780134498058/) (1999) 115 | 116 | :page_facing_up: 117 | 118 | - J.Bentley. [*Programming pearls: Algorithm design techniques*](http://akira.ruc.dk/~keld/teaching/algoritmedesign_f03/Artikler/05/Bentley84.pdf) – [Communications of the ACM *27*, 865](https://dx.doi.org/10.1145/358234.381162) (1984) 119 | 120 | ### Kadane’s algorithm 121 | 122 | :page_facing_up: 123 | 124 | - D.Gries. [*A note on a standard strategy for developing loop invariants and loops*](https://core.ac.uk/download/pdf/82596333.pdf) – [Science of computer programming *2*, 207](https://dx.doi.org/10.1016/0167-6423(83)90015-1) (1982) 125 | 126 | --- 127 | 128 | ## Majority element 129 | 130 | ### Boyer–Moore majority vote algorithm 131 | 132 | :link: 133 | 134 | - [*Boyer–Moore majority vote algorithm*](https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_majority_vote_algorithm) – Wikipedia 135 | 136 | --- 137 | 138 | ## Sqrt decomposition 139 | 140 | :link: 141 | 142 | - [*Sqrt decomposition*](https://cp-algorithms.com/data_structures/sqrt_decomposition.html) – CP-Algorithms 143 | - S.Kopeliovich. [*Sqrt decomposition*](http://acm.math.spbu.ru/~sk1/mm/lections/mipt2016-sqrt/mipt-2016-burunduk1-sqrt.en.pdf) – MIPT (2016) 144 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/signal_processing.md: -------------------------------------------------------------------------------- 1 | ## Digital signal processing 2 | 3 | ### Filtering 4 | 5 | - B.Stout. [*“Olympic” filtering for noisy data*](https://github.com/eugnsp/CUJ/blob/master/13.03/stout/stout.md) – C/C++ Users Journal **13** (1995) 6 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/string.md: -------------------------------------------------------------------------------- 1 | # String algorithms 2 | 3 | ## Table of contents 4 | 5 | - [Lexicographically minimal string rotation](#lexicographically-minimal-string-rotation) 6 | - [Duval’s based algorithm](#duvals-based-algorithm) 7 | - [Lyndon factorization](#lyndon-factorization) 8 | - [Duval’s algorithm](#duvals-algorithm) 9 | - [String matching](#string-matching) 10 | - [Exact string matching](#exact-string-matching) 11 | - [Knuth–Morris–Pratt algorithm](#knuthmorrispratt-algorithm) 12 | 13 | --- 14 | 15 | ## Lexicographically minimal string rotation 16 | 17 | > Lexicographically minimal rotation if the rotation of a string possessing the lowest lexicographical order of all its rotations. 18 | 19 | :link: 20 | 21 | - [*Lexicographically minimal string rotation*](https://en.wikipedia.org/wiki/Lexicographically_minimal_string_rotation) – Wikipedia 22 | 23 | ### Duval’s based algorithm 24 | 25 | :memo: 26 | 27 | - This algorithm is also known as the Zhou Yuan’s minimal expression algorithm. 28 | 29 | :link: 30 | 31 | - [*Lyndon factorization*](https://cp-algorithms.com/string/lyndon_factorization.html) – CP-Algorithms 32 | - [*How does the minimum expression algorithm by Zhou Yuan work?*](https://www.quora.com/How-does-the-minimum-expression-algorithm-by-Zhou-Yuan-work) – Quora 33 | 34 | --- 35 | 36 | ## Lyndon factorization 37 | 38 | > Lyndon word is a (non-empty) string that is strictly smaller in lexicographic order than all of its rotations. Lyndon factorization is a decomposition of a string `s` into Lyndon words, s = w1w2...wn, such that w1 ≥ wi ≥ ... ≥ wn. 39 | 40 | 41 | :link: 42 | 43 | - [*Lyndon word*](https://en.wikipedia.org/wiki/Lyndon_word) – Wikipedia 44 | 45 | ### Duval’s algorithm 46 | 47 | :link: 48 | 49 | - [*Lyndon factorization*](https://cp-algorithms.com/string/lyndon_factorization.html) – CP-Algorithms 50 | 51 | :page_facing_up: 52 | 53 | - J.P.Duval. *Factorizing words over an ordered alphabet* – [Journal of algorithms **8**, 363](https://dx.doi.org/10.1016/0196-6774(83)90017-2) (1983) 54 | - S.S.Ghuman, E.Giaquinta, J.Tarhio. [*Alternative algorithms for Lyndon factorization*](https://arxiv.org/abs/1405.4892) – arXiv preprint (2014) 55 | 56 | --- 57 | 58 | ## String matching 59 | 60 | :book: 61 | 62 | - Ch. 32. *String matching* – T.H.Cormen, C.E.Leiserson, R.L.Rivest, C.Stein. [*Introduction to algorithms*](https://mitpress.mit.edu/books/introduction-algorithms-third-edition) (2009) 63 | - Ch. 19: *String searching* – R.Sedgewick. *Algorithms* (1983) 64 | - Ch. 13: *String matching* – Drozdek A. *Data structures and algorithms in C++* – Cengage Learning (2012) 65 | 66 | ### Exact string matching 67 | 68 | :book: 69 | 70 | - Sec. 13.1: *Exact string matching* – Drozdek A. *Data structures and algorithms in C++* – Cengage Learning (2012) 71 | 72 | #### Knuth–Morris–Pratt algorithm 73 | 74 | :link: 75 | 76 | - [*Knuth–Morris–Pratt algorithm*](https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm) – Wikipedia 77 | 78 | :movie_camera: 79 | 80 | - W.Brinkman. [*KMP searching algorithm*](https://www.youtube.com/watch?v=y2b94AxPlF8) (2017) 81 | 82 | :book: 83 | 84 | - Ch. 32. *String matching* – T.H.Cormen, C.E.Leiserson, R.L.Rivest, C.Stein. [*Introduction to algorithms*](https://mitpress.mit.edu/books/introduction-algorithms-third-edition) (2009) 85 | - Ch. 19: *String searching*, Sec.: *Knuth–Morris–Pratt algorithm* – R.Sedgewick. *Algorithms* (1983) 86 | - Sec. 6.4.2: *Knuth–Morris–Pratt’s (KMP) algorithm* – S.Halim, F.Halim. [*Competitive programming*](https://cpbook.net/) (2013) 87 | - Sec. 13.1.2: *The Knuth–Morris–Pratt algorithm* – Drozdek A. *Data structures and algorithms in C++* – Cengage Learning (2012) 88 | 89 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/tools.md: -------------------------------------------------------------------------------- 1 | # Tools 2 | 3 | ## Table of contents 4 | 5 | - [Visualization](#visualization) 6 | 7 | --- 8 | 9 | ## Visualization 10 | 11 | :link: 12 | 13 | - D.Galles. [*Data structure visualizations*](https://www.cs.usfca.edu/~galles/visualization/Algorithms.html) 14 | - [*VisuAlgo: visualising data structures and algorithms through animation*](https://visualgo.net/) 15 | -------------------------------------------------------------------------------- /data_structures_and_algorithms/trees.md: -------------------------------------------------------------------------------- 1 | # Trees 2 | 3 | ## Table of contents 4 | 5 | - [Binary trees](#binary-trees) 6 | - [Binary search trees](#binary-search-trees) 7 | - [Self-balancing binary search trees](#self-balancing-binary-search-trees) 8 | - [AVL (Adelson-Velsky–Landis) trees](#avl-adelson-velskylandis-trees) 9 | - [Other binary trees](#other-binary-trees) 10 | - [Binary indexed trees (Fenwick trees)](#binary-indexed-trees-fenwick-trees) 11 | - [Generation of binary trees](#generation-of-binary-trees) 12 | - [Random binary trees](#random-binary-trees) 13 | - [Optimization of binary trees](#optimization-of-binary-trees) 14 | - [B/B+-trees](#bb-trees) 15 | - [Range trees](#range-trees) 16 | - [Interval trees](#interval-trees) 17 | - [Tries](#tries) 18 | - [Traversal](#traversal) 19 | - [Volumetric trees](#volumetric-trees) 20 | - [OpenVDB](#openvdb) 21 | 22 | --- 23 | 24 | ## Binary trees 25 | 26 | > A binary tree is a tree in which no node can have more than two children. The total number of binary trees with `N` different keys is given by `N! C(N)`, where `C(N)` is the `N`th Catalan number. Asymptotically C(N) ∼ 4N / [N3/2 sqrt π]. 27 | 28 | :grey_question: 29 | 30 | - [*Why does a complete binary tree of `n` leaves have `2n−1` nodes?*](https://math.stackexchange.com/q/180005) – Mathematics 31 | 32 | ### Binary search trees 33 | 34 | > A binary search tree is a binary tree that satisfies the binary search property: the key in each node must be greater than or equal to any key stored in the left subtree, and less than or equal to any key stored in the right subtree. The total number of binary search trees with `N` different keys is given by the `N`th Catalan number `C(N)`. Asymptotically C(N) ∼ 4N / [N3/2 sqrt π]. The average height of a randomly built binary search tree wuth `N` nodes is `O(log N)`. 35 | 36 | :movie_camera: 37 | 38 | - [*Binary search trees*](https://www.youtube.com/watch?v=9Jry5-82I68) – MIT OCW 6.006: [Introduction to algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/index.htm) (2011) 39 | 40 | :book: 41 | 42 | - Sec. 2.3.1: *Binary search trees*, Sec: *Selection sort* – E.Horowitz, S.Sahni, S.Rajasekaran. *Computer algorithms* – W.H.Freeman (1997) 43 | - Sec. 13.3: *Binary search trees* – J.Bentley. [*Programming pearls*](https://www.oreilly.com/library/view/programming-pearls-second/9780134498058/) (1999) 44 | 45 | ### Self-balancing binary search trees 46 | 47 | > A self-balancing binary search tree is a binary search tree that automatically keeps its height small during arbitrary insertions and deletions. 48 | 49 | :memo: 50 | 51 | - For a self-balancing binary search tree containing `N` nodes, lookup, insertion, and removal of an item takes `O(log N)` worst-case time, and ordered enumeration of all nodes takes `O(N)` time. 52 | - Self-balancing binary search trees can be used to implement sorted associative containers. For example, `std::set` and `std::map` are typically implemented using red-black trees. 53 | - Self-balancing binary search can be used to count the number of inversions in an array and the number of smaller/larger elements on the right/left side of each element in an array. 54 | 55 | :link: 56 | 57 | - [Self-balancing binary search tree](https://en.wikipedia.org/wiki/Self-balancing_binary_search_tree) – Wikipedia 58 | 59 | #### AVL (Adelson-Velsky–Landis) trees 60 | 61 | > An AVL tree is a self-balancing binary search tree in which for every node the height of the left and right subtrees can differ by at most one. 62 | 63 | :memo: 64 | 65 | - The height of an AVL tree with `N` nodes lies between log2(N + 1) and 1.4404 log2(N + 2) - 0.3277. 66 | - For insertions, one rotation always suffices. For deletions, `O(log N)` rotations may be required. Non-recursive insertions and deletions are generally faster, but harded to code and read. 67 | - Double rotations can be made more efficient if performed as a single step and not as two single rotations. 68 | - Balance factors, i.e. differences in heights, can be stored instead of heights. This results in faster but more complicated code. If a balance factor is stored as a separate data member, there is no profit in the amount of space used due to data alignment. 69 | - AVL trees require at most 45% more comparisons than optimal binary search trees. 70 | 71 | :link: 72 | 73 | - [AVL tree](https://en.wikipedia.org/wiki/AVL_tree) – Wikipedia 74 | - [C++ AVL tree template](https://www.codeproject.com/Articles/2839/C-AVL-Tree-Template) 75 | - [AVL trees: Tutorial and C++ implementation](https://www.bradapp.com/ftp/src/libs/C++/AvlTrees.html) 76 | - [Simple AVL tree in C++](http://somethingk.com/main/?p=1127) 77 | - [AVL tree implementation in C++](https://gist.github.com/harish-r/097688ac7f48bcbadfa5) 78 | 79 | :book: 80 | 81 | - Sec. 6.2.3: *Balanced trees* – D.E.Knuth. [*The art of computer programming.*](https://www-cs-faculty.stanford.edu/~knuth/taocp.html) *Vol. 3: Sorting and searching* (1998) 82 | - Sec. 4.4: *AVL trees* – M.A.Weiss. [*Data structures and algorithm analysis in C++*](https://www.pearson.com/us/higher-education/program/Weiss-Data-Structures-and-Algorithm-Analysis-in-C-4th-Edition/PGM148299.html) (2014) 83 | - Sec. 4.3.4: *AVL trees* – U.Manber. *Introduction to algorithms: A creative approach* (1989) 84 | 85 | :page_facing_up: 86 | 87 | - G.M.Adelson-Velskiĭ, E.M.Landis. *An algorithm for organization of information.* [In english](https://zhjwpku.com/assets/pdf/AED2-10-avl-paper.pdf), [In russian](http://mi.mathnet.ru/rus/dan/v146/i2/p263) – Doklady Akademii Nauk SSSR **146**, 263 (1962) 88 | 89 | :movie_camera: 90 | 91 | - [*AVL trees, AVL sort*](https://www.youtube.com/watch?v=FNeL18KsWPc) – MIT OCW 6.006: [Introduction to algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/index.htm) (2011) 92 | 93 | :dizzy: **Visualizations** 94 | 95 | - [AVL tree visualization](https://www.cs.usfca.edu/~galles/visualization/AVLtree.html) 96 | 97 | ### Other binary trees 98 | 99 | #### Binary indexed trees (Fenwick trees) 100 | 101 | > A binary indexed tree (Fenwick tree) is a data structure that can efficiently update elements and calculate prefix sums. A Fenwick tree can be built for any cancellative semigroup (e.g. for the set of integers under addition or multiplication); if the cancellation property doesn't hold (e.g. for min(•, •)), a segment tree can be used. Both `0`-based and `1`-based indexing can be used in equally elegant ways. Applications: arithmetic coding, Monte–Carlo simulations. 102 | 103 | 104 | 105 | :link: 106 | 107 | - [*Fenwick tree*](https://en.wikipedia.org/wiki/Fenwick_tree) – Wikipedia 108 | - [*Binary indexed trees*](https://www.topcoder.com/community/competitive-programming/tutorials/binary-indexed-trees/) – Topcoder 109 | - [*Fenwick tree*](https://brilliant.org/wiki/fenwick-tree/) – Brilliant 110 | - [*A JavaScript implementation of binary indexed tree*](https://github.com/Microsoft/fast-binary-indexed-tree-js) – Microsoft @ GitHub 111 | 112 | :grey_question: 113 | 114 | - [What are the advantage of binary indexed tree (BIT or Fenwick tree) over segment tree?](https://www.quora.com/What-are-the-advantage-of-binary-indexed-tree-BIT-or-fenwick-tree-over-segment-tree) – Quora 115 | 116 | :movie_camera: 117 | 118 | - [*Fenwick trees*](https://www.youtube.com/watch?v=kPaJfAUwViY) – Algorithms Live! 119 | - W.Fiset. [*Fenwick tree/Binary indexed tree*](https://www.youtube.com/playlist?list=PLDV1Zeh2NRsCvoyP-bztk6uXAYoyZg_U9) 120 | 121 | :book: 122 | 123 | - Sec. 2.4.4: *Binary indexed (Fenwick) tree* – S.Halim, F.Halim. [*Competitive programming*](https://cpbook.net/) (2013) 124 | 125 | :page_facing_up: 126 | 127 | - P.M.Fenwick. [*A new data structure for cumulative frequency tables*](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.14.8917&rep=rep1&type=pdf) – [Software: Practice and Experience **24**, 327](https://dx.doi.org/10.1002/spe.4380240306) (1994) 128 | 129 | ### Generation of binary trees 130 | 131 | - Sec. 7.2.1.6: [*Generating all trees*](http://www.cs.utsa.edu/~wagner/knuth/fasc4a.pdf) – D.E.Knuth. [*The art of computer programming.*](https://www-cs-faculty.stanford.edu/~knuth/taocp.html) *Vol. 4A: Combinatorial algorithms, Part 1* (2011) 132 | 133 | #### Random binary trees 134 | 135 | :link: 136 | 137 | - E.Mäkinen [*Generating random binary trees – a survey*](https://www.sis.uta.fi/cs/reports/pdf/A-1998-3.pdf) (1998) 138 | 139 | ### Optimization of binary trees 140 | 141 | - D.W.Schwartz. [*An efficient method for optimizing binary trees*](https://github.com/eugnsp/CUJ/blob/master/11.02/schwartz/schwartz.md) – C/C++ Users Journal **11** (1993) 142 | 143 | --- 144 | 145 | ## B/B+-trees 146 | 147 | :grey_question: 148 | 149 | - [*Advantage of B+ trees over BSTs?*](https://stackoverflow.com/q/15485220) – Stack Overflow 150 | 151 | :movie_camera: 152 | 153 | - [*2-3 Trees and B-Trees*](https://www.youtube.com/watch?v=TOb1tuEZ2X4) – MIT OCW 6.046J: [Design and analysis of algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-design-and-analysis-of-algorithms-spring-2015/index.htm) (2015) 154 | 155 | :book: 156 | 157 | - Ch. 18: *B-trees* – T.H.Cormen, C.E.Leiserson, R.L.Rivest, C.Stein. [*Introduction to algorithms*](https://mitpress.mit.edu/books/introduction-algorithms-third-edition) (2009) 158 | 159 | 160 | 161 | --- 162 | 163 | ## Range trees 164 | 165 | :movie_camera: 166 | 167 | - E.Demaine. [*Augmentation: Range trees*](https://www.youtube.com/watch?v=xVka6z1hu-I&t=3553) – MIT OCW 6.046J: [Design and analysis of algorithms](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-design-and-analysis-of-algorithms-spring-2015/index.htm) (2015) 168 | 169 | --- 170 | 171 | ## Interval trees 172 | 173 | :link: 174 | 175 | - Y.Dandass. [*Interval trees*](https://github.com/eugnsp/CUJ/blob/master/18.01/dandass/dandass.md) – C/C++ Users Journal **18** (2000) 176 | 177 | --- 178 | 179 | ## Tries 180 | 181 | :link: 182 | 183 | - J.W.M.Stevens. [*Lexical analysis using search tries*](https://github.com/eugnsp/CUJ/blob/master/10.04/jstevens/jstevens.md) – C/C++ Users Journal **10** (1992) 184 | 185 | --- 186 | 187 | ## Traversal 188 | 189 | See also: [*Traversal* – Graphs](graphs.md#traversal) 190 | 191 | :link: 192 | 193 | - [*Tree traversal*](https://en.wikipedia.org/wiki/Tree_traversal) – Wikipedia 194 | 195 | --- 196 | 197 | ## Volumetric trees 198 | 199 | ### OpenVDB 200 | 201 | :link: 202 | 203 | - [OpenVDB](https://www.openvdb.org/) 204 | - K.Museth. [*OpenVDB: An open source data structure and toolkit for high-resolution volumes*](https://www.youtube.com/watch?v=7hUH92xwODg) – BIDS (2015) 205 | 206 | -------------------------------------------------------------------------------- /distributed_systems.md: -------------------------------------------------------------------------------- 1 | # Distributed systems and computer networks 2 | 3 | ## Table of contents 4 | 5 | - [Introduction and overview](#introduction-and-overview) 6 | - [Metrics and order of magnitude estimations](#metrics-and-order-of-magnitude-estimations) 7 | - [CDN](#cdn) 8 | - [DNS](#dns) 9 | - [Big storage: file systems](#big-storage-file-systems) 10 | - [GFS (Google File System)](#gfs-google-file-system) 11 | - [HDFS (Hadoop Distributed File System)](#hdfs-hadoop-distributed-file-system) 12 | - [Big storage: databases](#big-storage-databases) 13 | - [NoSQL databases](#nosql-databases) 14 | - [Google BigTable](#google-bigtable) 15 | - [Redis](#redis) 16 | - [Memcached](#memcached) 17 | - [Transaction processing](#transaction-processing) 18 | - [Two-phase/three-phase commit protocol](#two-phasethree-phase-commit-protocol) 19 | - [Paxos](#paxos) 20 | - [Computation](#computation) 21 | - [MapReduce](#mapreduce) 22 | - [Unique ID generation](#unique-id-generation) 23 | - [Distributed systems](#distributed-systems) 24 | - [Autocomplete](#autocomplete) 25 | - [Facebook](#facebook) 26 | - [Google Maps](#google-maps) 27 | - [Search](#search) 28 | - [Google Search](#google-search) 29 | - [Elasticsearch](#elasticsearch) 30 | - [Distributed search query execution](#distributed-search-query-execution) 31 | - [Stack Overflow](#stack-overflow) 32 | - [Twitter](#twitter) 33 | - [YouTube](#youtube) 34 | - [Instagram](#instagram) 35 | - [Protocols](#protocols) 36 | - [Layer 4 protocols](#layer-4-protocols) 37 | - [UDP](#udp) 38 | - [TCP](#tcp) 39 | - [Layer 7 protocols](#layer-7-protocols) 40 | - [HTTP](#http) 41 | - [History](#history) 42 | - [WebSocket](#websocket) 43 | - [CAP theorem](#cap-theorem) 44 | - [Load balancing](#load-balancing) 45 | - [Layer 4 load balancing](#layer-4-load-balancing) 46 | - [Layer 7 load balancing](#layer-7-load-balancing) 47 | - [Blockchain](#blockchain) 48 | - [Distributed graphs](#distributed-graphs) 49 | 50 | --- 51 | 52 | ## Introduction and overview 53 | 54 | :link: 55 | 56 | - S.Kozlovski. [*A thorough introduction to distributed systems*](https://accu.org/journals/overload/27/149/kozlovski_2620/) – [Overload **149**](https://accu.org/journals/overload/overload149) (2019) 57 | 58 | :movie_camera: 59 | 60 | - T.Berglund. [*Distributed systems in one lesson*](https://www.youtube.com/watch?v=Y6Ev8GIlbxc) – Devoxx Poland (2017) 61 | - D.Malan. [*Scalability*](https://www.youtube.com/watch?v=-W9F__D3oY4) – Harvard CS75: [Building dynamic websites](http://cs75.tv/2012/summer/)gh (2012) 62 | - J.Dean. [*Building software systems at Google and lessons learned*](https://www.youtube.com/watch?v=modXC5IWTJI) – Stanford (2010) 63 | 64 | ### Metrics and order of magnitude estimations 65 | 66 | :link: 67 | 68 | - S.Ignatchenko. [*The importance of back-of-envelope estimates*](https://accu.org/journals/overload/25/137/ignatchenko_2341/) – [Overload **137**](https://accu.org/journals/overload/overload137) (2017) 69 | 70 | --- 71 | 72 | ## CDN 73 | 74 | :link: 75 | 76 | - [*Content delivery network*](https://en.wikipedia.org/wiki/Content_delivery_network) – Wikipedia 77 | 78 | :movie_camera: 79 | 80 | - S.Keshav. [*DNS and CDN*](https://www.youtube.com/watch?v=7-rxE636opw&t=2172) – CS 436: Distributed Computer Systems (2013) 81 | - A.Bergman. [*What is a CDN and why developers should care about using one*](https://www.youtube.com/watch?v=farO15_0NUQ) – GOTO (2016) 82 | 83 | :page_facing_up: 84 | 85 | - J.Dilley et al. [*Globally distributed content delivery*](https://kilthub.cmu.edu/articles/Globally_distributed_content_delivery/6605972) – [IEEE Internet Computing **6**, 50](https://doi.org/10.1109/MIC.2002.1036038) (2002) 86 | 87 | --- 88 | 89 | ## DNS 90 | 91 | :link: 92 | 93 | - [*Domain Name System*](https://en.wikipedia.org/wiki/Domain_Name_System) – Wikipedia 94 | - [*DNS technical reference*](https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/dd197461%28v=ws.10%29) – Microsoft Docs (2017) 95 | 96 | :movie_camera: 97 | 98 | - S.Keshav. [*DNS and CDN*](https://www.youtube.com/watch?v=7-rxE636opw) – CS 436: Distributed Computer Systems (2013) 99 | 100 | --- 101 | 102 | ## Big storage: file systems 103 | 104 | ### GFS (Google File System) 105 | 106 | :link: 107 | 108 | - [*GFS FAQ*](https://pdos.csail.mit.edu/6.824/papers/gfs-faq.txt) – MIT 6.824: [Distributed systems](https://pdos.csail.mit.edu/6.824/) (2020) 109 | 110 | :movie_camera: 111 | 112 | - R.Morris. [*GFS*](https://www.youtube.com/watch?v=EpIgvowZr00) ([Notes](https://pdos.csail.mit.edu/6.824/notes/l-gfs.txt)) – MIT 6.824: [Distributed systems](https://pdos.csail.mit.edu/6.824/) (2020) 113 | 114 | :page_facing_up: 115 | 116 | - K.McKusick, S.Quinlan. [*GFS: Evolution on fast-forward*](https://queue.acm.org/detail.cfm?id=1594206) – [ACM Queue **7**](https://doi.org/10.1145/1594204.1594206) (2009) 117 | - S.Ghemawat, H.Gobioff, S.-T. Leung. [*The Google file system*](https://static.googleusercontent.com/media/research.google.com/en//archive/gfs-sosp2003.pdf) – [ACM SIGOPS Operating Systems Review **37**, 29](https://doi.org/10.1145/1165389.945450) (2003) 118 | 119 | ### HDFS (Hadoop Distributed File System) 120 | 121 | :page_facing_up: 122 | 123 | - K.Shvachko, H.Kuang, S.Radia, R.Chansler. [*The Hadoop distributed file system*](https://storageconference.us/2010/Papers/MSST/Shvachko.pdf) – [IEEE Symposium on Mass Storage Systems and Technologies](https://doi.org/10.1109/MSST.2010.5496972) (2010) 124 | 125 | --- 126 | 127 | ## Big storage: databases 128 | 129 | ### NoSQL databases 130 | 131 | :link: 132 | 133 | - F.Gessert. [*NoSQL databases: A survey and decision guidance*](https://medium.baqend.com/nosql-databases-a-survey-and-decision-guidance-ea7823a822d) (2016) 134 | 135 | :movie_camera: 136 | 137 | - M.Fowler. [*Introduction to NoSQL*](https://www.youtube.com/watch?v=qI_g07C_Q5I) – GOTO (2012) 138 | 139 | #### Google BigTable 140 | 141 | :link: 142 | 143 | - [*Bigtable*](https://en.wikipedia.org/wiki/Bigtable) – Wikipedia 144 | 145 | :movie_camera: 146 | 147 | - J.Dean. [*BigTable: A distributed structured storage system*](https://www.youtube.com/watch?v=2cXBNQClehA) – [CSE Colloquia](https://www.cs.washington.edu/events/colloquia/details?id=437) (2005) 148 | 149 | 150 | 151 | :page_facing_up: 152 | 153 | - F.Chang et al. [*BigTable: A distributed storage system for structured data*](https://dl.acm.org/doi/pdf/10.1145/1365815.1365816?download=true) – [ACM Transactions on Computer Systems **26**, 4](https://doi.org/10.1145/1365815.1365816) (2008) 154 | 155 | #### Redis 156 | 157 | :link: 158 | 159 | - [*Redis documentation*](https://redis.io/documentation) 160 | - S.Sanfilippo. [*Redis persistence demystified*](http://oldblog.antirez.com/post/redis-persistence-demystified.html) (2012) 161 | 162 | #### Memcached 163 | 164 | :link: 165 | 166 | - [Memcached](https://memcached.org/) 167 | 168 | :movie_camera: 169 | 170 | - R.Nishtala. [*Scaling Memcache at Facebook*](https://www.youtube.com/watch?v=6phA3IAcEJ8) – NSDI (2013) 171 | 172 | ### Transaction processing 173 | 174 | :link: 175 | 176 | :movie_camera: 177 | 178 | - R.Barrett. [*Transactions across datacenters*](https://www.youtube.com/watch?v=srOgpXECblk) – Google I/O (2009) 179 | 180 | #### Two-phase/three-phase commit protocol 181 | 182 | 183 | 184 | :link: 185 | 186 | - [*Two-phase commit protocol*](https://en.wikipedia.org/wiki/Two-phase_commit_protocol) – Wikipedia 187 | 188 | :grey_question: 189 | 190 | - [*How does three-phase commit avoid blocking?*](https://stackoverflow.com/q/21424962) – Stack Overflow 191 | 192 | #### Paxos 193 | 194 | :link: 195 | 196 | - [*Paxos*](https://en.wikipedia.org/wiki/Paxos_%28computer_science%29) – Wikipedia 197 | 198 | :movie_camera: 199 | 200 | - H.Howard. [*Paxos agreement*](https://www.youtube.com/watch?v=s8JqcZtvnsM) – Computerphile (2016) 201 | - C.Colohan. [*Paxos simplified*](https://www.youtube.com/watch?v=SRsK-ZXTeZ0) – Distributed Systems Design (2017) 202 | 203 | 207 | 208 | :grey_question: 209 | 210 | - [*Paxos vs two phase commit*](https://stackoverflow.com/q/27304887) – Stack Overflow 211 | 212 | --- 213 | 214 | ## Computation 215 | 216 | ### MapReduce 217 | 218 | :link: 219 | 220 | - H.Robinson. [*The elephant was a trojan horse: On the death of Map-Reduce at Google*](https://www.the-paper-trail.org/post/2014-06-25-the-elephant-was-a-trojan-horse-on-the-death-of-map-reduce-at-google/) (2014) 221 | 222 | :movie_camera: 223 | 224 | - B.Brumitt. [*MapReduce used on large data sets*](https://www.youtube.com/watch?v=N8FHXgPJEfQ) – Seattle Conference on Scalability (2007) 225 | - S.Ghemawat, J.Dean, J.Zhao, M.Austern. [*Google MapReduce by Google scientists*](https://www.youtube.com/watch?v=NXCIItzkn3E) – Google Technology RoundTable (2008) 226 | - J.Tedesco. [*MapReduce: Simplified data processing on large clusters*](https://www.youtube.com/watch?v=u8h88oPHDMw) (2012) 227 | 228 | :page_facing_up: 229 | 230 | - J.Dean, S.Ghemawat. [*MapReduce: Simplified data processing on large clusters*](https://dl.acm.org/doi/pdf/10.1145/1327452.1327492?download=true) – [Communications of the ACM **51**](https://doi.org/10.1145/1327452.1327492) (2008) 231 | 232 | ### Unique ID generation 233 | 234 | :link: 235 | 236 | - [*Sharding & IDs at Instagram*](https://instagram-engineering.com/sharding-ids-at-instagram-1cf5a71e5a5c) – Instagram Engineering (2012) 237 | - [*Twitter Snowflake* (retired)](https://github.com/twitter-archive/snowflake/tree/b3f6a3c6ca8e1b6847baa6ff42bf72201e2c2231) 238 | 239 | 240 | 241 | :movie_camera: 242 | 243 | - C.Colohan. [*Unique ID*](https://www.youtube.com/watch?v=W6qURtqrldc) – Distributed Systems Design (2019) 244 | 245 | --- 246 | 247 | ## Distributed systems 248 | 249 | ### Autocomplete 250 | 251 | :link: 252 | 253 | - W.Wahed, T.Han, J.Shenk. [*Building Prefixy*](https://prefixy.github.io/) 254 | 255 | ### Facebook 256 | 257 | :movie_camera: 258 | 259 | - H.Fisk. [*Large-scale low-latency storage for the social network*](https://www.youtube.com/watch?v=5RfFhMwRAic) – Data@Scale (2013) 260 | 261 | ### Google Maps 262 | 263 | :movie_camera: 264 | 265 | ### Search 266 | 267 | #### Google Search 268 | 269 | :page_facing_up: 270 | 271 | - S.Brin, L.Page. [*The anatomy of a large-scale hypertextual Web search engine*](https://snap.stanford.edu/class/cs224w-readings/Brin98Anatomy.pdf) – [Computer Networks and ISDN Systems *30*, 107](https://doi.org/10.1016/S0169-7552(98)00110-X) (1998) 272 | - L.A.Barroso, J.Dean, U.Hölzle. [*Web search for a planet: The Google cluster architecture*](https://static.googleusercontent.com/media/research.google.com/en//archive/googlecluster-ieee.pdf) – [IEEE Micro **23**, 22](https://doi.org/10.1109/MM.2003.1196112) (2003) 273 | 274 | #### Elasticsearch 275 | 276 | :link: 277 | 278 | - C.Gormley, Z.Tong. [*Elasticsearch: The definitive guide*](https://www.elastic.co/guide/en/elasticsearch/guide/current/index.html) (2014–2015) 279 | 280 | #### Distributed search query execution 281 | 282 | :link: 283 | 284 | - Sec.: [*Distributed search execution*](https://www.elastic.co/guide/en/elasticsearch/guide/current/distributed-search.html) – C.Gormley, Z.Tong. [*Elasticsearch: The definitive guide*](https://www.elastic.co/guide/en/elasticsearch/guide/current/index.html) (2014–2015) 285 | 286 | ### Stack Overflow 287 | 288 | :link: 289 | 290 | - [*How we do app caching – 2019 edition*](https://nickcraver.com/blog/2019/08/06/stack-overflow-how-we-do-app-caching/) – Stack Overflow blog (2019) 291 | - [*The hardware – 2016 edition*](https://nickcraver.com/blog/2016/03/29/stack-overflow-the-hardware-2016-edition/) – Stack Overflow blog (2016) 292 | - [*The architecture – 2016 edition*](https://stackoverflow.blog/2016/02/17/stack-overflow-the-architecture-2016-edition/) – Stack Overflow blog (2016) 293 | - [*A technical deconstruction*](https://nickcraver.com/blog/2016/02/03/stack-overflow-a-technical-deconstruction/) – Stack Overflow blog (2016) 294 | - [*What it takes to run Stack Overflow*](https://nickcraver.com/blog/2013/11/22/what-it-takes-to-run-stack-overflow/) – Stack Overflow blog (2013) 295 | - [*Stack Exchange Data explorer*](https://data.stackexchange.com/) 296 | 297 | :movie_camera: 298 | 299 | - O.Coster. [*Stack Overflow behind the scenes – how it’s made*](https://www.youtube.com/watch?v=6lbH_rTQrH0) – Codemotion (2017) 300 | - M.Cecconi. [*High performance architecture of Stack Overflow*](https://www.youtube.com/watch?v=zTRd6CoEEqA) – code.talks (2016) 301 | - M.Cecconi. [*High performance architecture of Stack Overflow*](https://www.youtube.com/watch?v=uNVlQ1yPsto) – JSConf.Asia (2016) 302 | - M.Cecconi. [*The architecture of Stack Overflow*](https://www.youtube.com/watch?v=rkVvxgdY9F8) – Infoshare (2014) 303 | - M.Cecconi. [*The architecture of Stack Overflow*](https://www.youtube.com/watch?v=OGi8FT2j8hE) – code.talks (2013) 304 | - M.Cecconi. [*The architecture of Stack Overflow*](https://www.youtube.com/watch?v=t6kM2EM6so4) – Dev Day (2013) 305 | - S.Hanselman. [*StackExchange*](https://channel9.msdn.com/Events/Ch9Live/MIX11/C9L105) – MIX11 (2011) 306 | 307 | ### Twitter 308 | 309 | :link: 310 | 311 | - [*Tutorial: Design and implementation of a simple Twitter clone using PHP and the Redis key-value store*](https://redis.io/topics/twitter-clone) 312 | 313 | ### YouTube 314 | 315 | :movie_camera: 316 | 317 | - C.Do. [*YouTube scalability*](https://www.youtube.com/watch?v=w5WVu624fY8) – Seattle Conference on Scalability (2007) 318 | 319 | ### Instagram 320 | 321 | :link: 322 | 323 | - [*What powers Instagram: Hundreds of instances, dozens of technologies*](https://instagram-engineering.com/what-powers-instagram-hundreds-of-instances-dozens-of-technologies-adf2e22da2ad) – Instagram Engineering (2011) 324 | 325 | :movie_camera: 326 | 327 | - L.Guo. [*Scaling Instagram infrastructure*](https://www.youtube.com/watch?v=hnpzNAPiC0E) – QCon (2017) 328 | - P.Hunt. [*How Instagram.com works*](https://www.youtube.com/watch?v=VkTCL6Nqm6Y) – OSCON (2014) 329 | - R.Branson. [*Messaging at scale at Instagram (Async tasks at Instagram)*](https://www.youtube.com/watch?v=E708csv4XgY) – PyCon (2013) 330 | 331 | --- 332 | 333 | ## Protocols 334 | 335 | ### Layer 4 protocols 336 | 337 | :link: 338 | 339 | - S.Ignatchenko. [*Once again on TCP vs UDP*](https://accu.org/journals/overload/23/130/ignatchenko_2180/) – [Overload **130**](https://accu.org/journals/overload/overload130) (2015) 340 | - S.Ignatchenko. [*TCP/IP explained. A bit*](https://accu.org/journals/overload/21/115/ignatchenko_1858/) – [Overload **115**](https://accu.org/journals/overload/overload115) (2013) 341 | 342 | #### UDP 343 | 344 | :book: 345 | 346 | - Ch. 11: *UDP transport* – P.L.Dordal. [*An introduction to computer networks*](http://intronetworks.cs.luc.edu/1/html/index.html) 347 | 348 | #### TCP 349 | 350 | :link: 351 | 352 | - [*Transmission Control Protocol*](https://en.wikipedia.org/wiki/Transmission_Control_Protocol) – Wikipedia 353 | 354 | :grey_question: 355 | 356 | - [*Why do we need a 3-way handshake? Why not just 2-way?*](https://networkengineering.stackexchange.com/q/24068) – Network Engineering 357 | 358 | :book: 359 | 360 | - Ch. 12: *TCP transport* – P.L.Dordal. [*An introduction to computer networks*](http://intronetworks.cs.luc.edu/1/html/index.html) 361 | 362 | ### Layer 7 protocols 363 | 364 | #### HTTP 365 | 366 | :book: 367 | 368 | - Sec.: *HTTP* – I.Grigorik. [*High performance browser networking*](https://hpbn.co/) 369 | 370 | #### History 371 | 372 | :link: 373 | 374 | - [*Evolution of HTTP*](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Evolution_of_HTTP) – MDN 375 | 376 | ### WebSocket 377 | 378 | :link: 379 | 380 | - [*WebSocket*](https://en.wikipedia.org/wiki/WebSocket) – Wikipedia 381 | - [*When to use a HTTP call instead of a WebSocket (or HTTP 2.0)*](https://blogs.windows.com/windowsdeveloper/2016/03/14/when-to-use-a-http-call-instead-of-a-websocket-or-http-2-0/) – Windows Apps Team (2016) 382 | 383 | 384 | 385 | :grey_question: 386 | 387 | - [*Does HTTP/2 make websockets obsolete?*](https://stackoverflow.com/q/28582935) – Stack Overflow 388 | - [*WebSockets protocol vs HTTP*](https://stackoverflow.com/q/14703627) – Stack Overflow 389 | 390 | 391 | 401 | 402 | 403 | 404 | ## CAP theorem 405 | 406 | > It is impossible for a distributed data store to simultaneously provide more than two out of the following three guarantees: *consistency* (every read receives the most recent write or an error), *availability* (every request receives a non-error response, without the guarantee that it contains the most recent write), and *partition tolerance* (the system continues to operate despite an arbitrary number of messages being dropped or delayed by the network between nodes). 407 | 408 | :link: 409 | 410 | - H.Robinson. [*The CAP FAQ*](https://github.com/henryr/cap-faq) (2013) 411 | 412 | :movie_camera: 413 | 414 | - C.Colohan. [Lec. 16: *The CAP theorem*](https://www.youtube.com/watch?v=k-Yaq8AHlFA) – Distributed Systems Design (2019) 415 | 416 | ## Load balancing 417 | 418 | ### Layer 4 load balancing 419 | 420 | > Layer 4 load balancing operates at the intermediate transport layer (Layer 4), which deals with delivery of messages with no regard to the content of the messages (a load-balancing decision is based on the source and destination IP addresses and ports recorded in the packet header). Nowadays, CPU and memory are sufficiently fast and cheap that the performance advantage for Layer 4 load balancing has become negligible or irrelevant in most situations. 421 | 422 | :link: 423 | 424 | - [*What is layer 4 load balancing?*](https://www.nginx.com/resources/glossary/layer-4-load-balancing/) 425 | 426 | ### Layer 7 load balancing 427 | 428 | > Layer 7 load balancing operates at the high‑level application layer (Layer 7), which deals with the actual content of each message (a load‑balancing decision is based on the content of the message, like a URL or cookie). 429 | 430 | :link: 431 | 432 | - [*What is layer 7 load balancing?*](https://www.nginx.com/resources/glossary/layer-7-load-balancing/) 433 | 434 | --- 435 | 436 | ## Blockchain 437 | 438 | :movie_camera: 439 | 440 | - C.Colohan. [*What is a blockchain*](https://www.youtube.com/watch?v=Jp7T9qtuRIE) – Distributed Systems Design (2018) 441 | 442 | ## Distributed graphs 443 | 444 | 447 | -------------------------------------------------------------------------------- /general_reviews.md: -------------------------------------------------------------------------------- 1 | # General reviews and interviews 2 | 3 | ## Table of contents 4 | 5 | - [Operating systems](#operating-systems) 6 | - [Linux](#linux) 7 | - [Automated theorem proving](#automated-theorem-proving) 8 | - [Algorithms](#algorithms) 9 | - [Natural language processing](#natural-language-processing) 10 | - [Spelling correction](#spelling-correction) 11 | - [Neural networks](#neural-networks) 12 | - [Graph neural networks](#graph-neural-networks) 13 | - [Journals](#journals) 14 | - [Software history](#software-history) 15 | - [Software-related accidents](#software-related-accidents) 16 | - [Patriot Missile failure](#patriot-missile-failure) 17 | - [Therac-25](#therac-25) 18 | - [Soft skills](#soft-skills) 19 | - [Humor, folklore, etc.](#humor-folklore-etc) 20 | 21 | --- 22 | 23 | ## Operating systems 24 | 25 | :movie_camera: 26 | 27 | - D.Zavalishin. [*Beyond Intel and Linux: Uncommon processors and operating systems*](https://www.youtube.com/watch?v=DBOTcG6iJEI) – Demodulation (in Russian, 2019) 28 | - M.Russinovich. [*Windows and Linux: A tale of two kernels*](https://www.youtube.com/watch?v=HdV9QuvgS_w) – Tech-Ed (2004) 29 | 30 | ### Linux 31 | 32 | --- 33 | 34 | ## Automated theorem proving 35 | 36 | :movie_camera: 37 | 38 | - W.T.Gowers. [*What are the prospects for automatic theorem proving?*](https://www.youtube.com/watch?v=VamEGCJozgU) – Microsoft Research (2016) 39 | 40 | --- 41 | 42 | ## Algorithms 43 | 44 | :link: 45 | 46 | - [*The aggregate magic algorithms*](http://aggregate.org/MAGIC/) 47 | 48 | --- 49 | 50 | ## Natural language processing 51 | 52 | ### Spelling correction 53 | 54 | :link: 55 | 56 | - P.Norvig. [*How to write a spelling corrector*](https://norvig.com/spell-correct.html) (2007–2016) 57 | 58 | --- 59 | 60 | ### Neural networks 61 | 62 | #### Graph neural networks 63 | 64 | :movie_camera: 65 | 66 | - M.Allamanis. [*An introduction to graph neural networks: Models and applications*](https://www.youtube.com/watch?v=zCEYiCxrL_0) – MSR Cambridge Lecture Series (2019) 67 | 68 | --- 69 | 70 | ## Journals 71 | 72 | - [*Dr. Dobb’s journal*](http://www.6502.org/documents/publications/dr_dobbs_journal/) (1976–1990) 73 | - [*Informatics and education*](http://publ.lib.ru/ARCHIVES/I/%27%27Informatika_i_obrazovanie%27%27/_%27%27Informatika_i_obrazovanie%27%27.html) (in Russian, 1986–2013) 74 | 75 | --- 76 | 77 | ## Software history 78 | 79 | - M.Steil. [Bill Gates’ personal easter eggs in 8-bit BASIC](https://www.pagetable.com/?p=43) 80 | 81 | --- 82 | 83 | ## Software-related accidents 84 | 85 | :link: 86 | 87 | - T.Huckle. [*Collection of software bugs*](https://www5.in.tum.de/~huckle/bugse.html) 88 | - D.N.Arnold. [*Some disasters attributable to bad numerical computing*](https://www-users.cse.umn.edu/~arnold/disasters/) 89 | - M.Lake. [*Epic failures: 11 infamous software bugs*](https://www.computerworld.com/article/2515483/epic-failures-11-infamous-software-bugs.html) – Computerworld 90 | 91 | 92 | ### Patriot Missile failure 93 | 94 | :link: 95 | 96 | - D.N.Arnold. [*The Patriot Missile failure*](https://www-users.cse.umn.edu/~arnold/disasters/patriot.html) 97 | 98 | ### Therac-25 99 | 100 | :link: 101 | 102 | - [*Therac-25*](https://en.wikipedia.org/wiki/Therac-25) – Wikipedia 103 | 104 | --- 105 | 106 | ## Soft skills 107 | 108 | :movie_camera: 109 | 110 | - D.Sankel. [*Rules for radical engineers: Make a difference in your code, team, and organization*](https://www.youtube.com/watch?v=ady2mUIQpt4) – CppCon (2022) 111 | 112 | --- 113 | 114 | ## Humor, folklore, etc. 115 | 116 | :link: 117 | 118 | - [*Greenspun’s tenth rule*](https://en.wikipedia.org/wiki/Greenspun's_tenth_rule) – Wikipedia 119 | - [*C++23: `fullptr` to replace `nullptr`*](https://codingtidbit.com/2019/04/01/c22-fullptr-to-replace-nullptr/) (2019, April 1) 120 | - E.Siegel. [*Educational computer science songs*](http://www.cs.columbia.edu/~evs/songs/) 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /hardware.md: -------------------------------------------------------------------------------- 1 | # Hardware and hardware history 2 | 3 | ## Table of contents 4 | 5 | - [Overview](#overview) 6 | - [Computers](#computers) 7 | - [Apollo Guidance Computer (AGC)](#apollo-guidance-computer-agc) 8 | - [BESM-6](#besm-6) 9 | - [BBC B](#bbc-b) 10 | - [CPUs](#cpus) 11 | - [Intel 8086 CPU](#intel-8086-cpu) 12 | - [Intel 80386 CPU](#intel-80386-cpu) 13 | - [MOS 6502 CPU](#mos-6502-cpu) 14 | - [Flash memory](#flash-memory) 15 | - [Interfaces](#interfaces) 16 | - [USB](#usb) 17 | - [RS-232](#rs-232) 18 | 19 | --- 20 | 21 | ## Overview 22 | 23 | :anchor: 24 | 25 | - [*Vintage Computer Federation*](https://www.youtube.com/channel/UCKdBVD2wVUkuJQZhxGvVr0Q) (YouTube channel) 26 | - [*The National Museum of Computing*](https://www.youtube.com/user/tnmoc) (YouTube channel) 27 | - [*The National Museum of Computing*](https://www.tnmoc.org/) 28 | 29 | --- 30 | 31 | ## Computers 32 | 33 | ### Apollo Guidance Computer (AGC) 34 | 35 | :movie_camera: 36 | 37 | - R.Wills. [*Light years ahead: The 1969 Apollo guidance computer (revisited)*](https://www.youtube.com/watch?v=VYI0Kf_1wqk) (2021) 38 | - R.Wills. [*Light years ahead: The 1969 Apollo guidance computer*](https://www.youtube.com/watch?v=B1J2RMorJXM) – The National Museum of Computing (2019) 39 | 40 | ### BESM-6 41 | 42 | :movie_camera: 43 | 44 | - A.Tomilin. *About BESM-6*. [Part I](https://www.youtube.com/watch?v=66VBKeGAmfs), [Part II](https://www.youtube.com/watch?v=pL4wGV_ui4o), [Part III](https://www.youtube.com/watch?v=F9IQ357YwdU) (in Russian) 45 | - A.Tomilin. [*About BESM-6 and AS-6*](https://www.youtube.com/watch?v=VvDl9HmVx5U) (in Russian) 46 | 47 | ### BBC B 48 | 49 | :movie_camera: 50 | 51 | - R.Hill. [*BBC B microcomputer*](https://www.youtube.com/watch?v=do6xydtcVPk), [*Original Elite on the BBC B*](https://www.youtube.com/watch?v=owz7XExO-Wk) – Computerphile (2013) 52 | 53 | --- 54 | 55 | ## CPUs 56 | 57 | ### Intel 8086 CPU 58 | 59 | :link: 60 | 61 | - K.Shirriff. [*A bug fix in the 8086 microprocessor, revealed in the die’s silicon*](https://www.righto.com/2022/11/a-bug-fix-in-8086-microprocessor.html) (2022) 62 | 63 | ### Intel 80386 CPU 64 | 65 | :link: 66 | 67 | - K.Shirriff. [*Examining the silicon dies of the Intel 386 processor*](https://www.righto.com/2023/10/intel-386-die-versions.html) (2023) 68 | 69 | ### MOS 6502 CPU 70 | 71 | :link: 72 | 73 | - [*Visual transistor-level simulation of the 6502 CPU*](http://visual6502.org/) 74 | - K.Shirriff. [*The 6502 CPU’s overflow flag explained at the silicon level*](https://www.righto.com/2013/01/a-small-part-of-6502-chip-explained.html) (2013) 75 | - K.Shirriff. [*The 6502 overflow flag explained mathematically*](https://www.righto.com/2012/12/the-6502-overflow-flag-explained.html) (2012) 76 | 77 | :movie_camera: 78 | 79 | - D.Murray. [*The 6502 CPU powered a whole generation!*](https://www.youtube.com/watch?v=acUH4lWe2NQ) – The 8-Bit Guy (2024) 80 | - S.Edwards, B.Mensch. [*The genesis of the 6502 microprocessor*](https://www.youtube.com/watch?v=mEhvfJaPTlI) – Vintage Computer Federation (2020) 81 | - M.Steil. [*Reverse engineering the MOS 6502 CPU](https://www.youtube.com/watch?v=fWqBmmPQP40) – 27C3 (2011) 82 | 83 | :anchor: 84 | 85 | - [*MOS Technology 6502*](https://en.wikipedia.org/wiki/MOS_Technology_6502) – Wikipedia 86 | 87 | --- 88 | 89 | ## Flash memory 90 | 91 | :link: 92 | 93 | - bunnie, Xobs. [*The exploration and exploitation of an SD memory card*](https://www.youtube.com/watch?v=ruEn7TE4YMM) – 27C3 (2014) 94 | 95 | --- 96 | 97 | ## Interfaces 98 | 99 | ### USB 100 | 101 | :movie_camera: 102 | 103 | - B.Eater. [*How does a USB keyboard work?*](https://www.youtube.com/watch?v=wdgULBpRoXk) (2021) 104 | 105 | ### RS-232 106 | 107 | :movie_camera: 108 | 109 | - B.Eater. [*The RS-232 protocol*](https://www.youtube.com/watch?v=AHYNxpqKqwo) (2022) -------------------------------------------------------------------------------- /low_level.md: -------------------------------------------------------------------------------- 1 | # Assembly, low-level programming, and OS internals 2 | 3 | ## Table of contents 4 | 5 | - [Introduction and overview](#introduction-and-overview) 6 | - [CPU](#cpu) 7 | - [CPU word size](#cpu-word-size) 8 | - [Endianness and NUXI problem](#endianness-and-nuxi-problem) 9 | - [x87](#x87) 10 | - [CPU vulnerabilities](#cpu-vulnerabilities) 11 | - [Spectre](#spectre) 12 | - [Tricks](#tricks) 13 | - [Memory](#memory) 14 | - [Memory addressing](#memory-addressing) 15 | - [Operating systems](#operating-systems) 16 | - [Libraries](#libraries) 17 | - [Linux](#linux) 18 | - [Windows](#windows) 19 | - [Device drivers](#device-drivers) 20 | 21 | --- 22 | 23 | ## Introduction and overview 24 | 25 | :movie_camera: 26 | 27 | - D.Sankel. [*Under the hood: Assembly, system calls, and hardware*](https://www.youtube.com/watch?v=0iXRRCnurvo) – C++Now (2023) 28 | 29 | 30 | 31 | 32 | --- 33 | 34 | ## CPU 35 | 36 | :link: 37 | 38 | - B.Wagstaff. [*A journey through the CPU pipeline*](https://www.gamedev.net/articles/programming/general-and-gameplay-programming/a-journey-through-the-cpu-pipeline-r3115/) (2013) 39 | 40 | ### CPU word size 41 | 42 | :link: 43 | 44 | - S.Ignatchenko. [*Size matters*](https://accu.org/journals/overload/22/120/ignatchenko_1895/) – [Overload **120**](https://accu.org/journals/overload/overload120) (2014) 45 | - E.Musayev. [*A brief history of the road to 64 bits*](https://web.archive.org/web/20191222085303/http://www.eldar.com/node/262) (in Russian, 2009) 46 | 47 | :page_facing_up: 48 | 49 | - J.Mashey. [*The long road to 64 bits*](https://cacm.acm.org/magazines/2009/1/15667-the-long-road-to-64-bits/fulltext) – [Communications of the ACM **52**, 45-53](https://doi.org/10.1145/1435417.1435431) (2009) 50 | 51 | ### Endianness and NUXI problem 52 | 53 | :link: 54 | 55 | - [*Endianness*](https://en.wikipedia.org/wiki/Endianness) – Wikipedia 56 | 57 | :book: 58 | 59 | - Essay 1: *You must be joking* – P.J.Plauger. [*Programming on purpose III: Essays on software technology*](https://www.pearson.com/us/higher-education/program/Plauger-Programming-on-Purpose-III-Essays-on-Software-Technology/PGM133229.html) (1994) 60 | 61 | ### x87 62 | 63 | See also [*Numeric data structures and algorithms*](../data_structures_and_algorithms/numeric.md). 64 | 65 | :link: 66 | 67 | - [*Pentium `FDIV` bug*](https://en.wikipedia.org/wiki/Pentium_FDIV_bug#cite_note-halfhill-199503-3) – Wikipedia 68 | - B.Dawson. [*Intel underestimates error bounds by 1.3 quintillion](https://randomascii.wordpress.com/2014/10/09/intel-underestimates-error-bounds-by-1-3-quintillion/) (2014) 69 | - S.Duplichan. [*Intel overstates FPU accuracy*](http://notabs.org/fpuaccuracy/index.htm) (2013) 70 | - T.R.Halfhill. [*The truth behind the Pentium bug*](https://web.archive.org/web/20060209005434/http://www.byte.com/art/9503/sec13/art1.htm) – BYTE.com (1995) 71 | 72 | :grey_question: 73 | 74 | - [*Extended (80-bit) double floating point in x87, not SSE2 – we don’t miss it?*](https://stackoverflow.com/q/3206101) – Stack Overflow 75 | - [*Did any compiler fully use Intel x87 80-bit floating point?*](https://retrocomputing.stackexchange.com/q/9751) – Retrocomputing 76 | 77 | :anchor: 78 | 79 | - [*Programming with the x87 floating-point unit*](http://www.infophysics.net/x87.pdf) – Intel 80 | 81 | ### CPU vulnerabilities 82 | 83 | #### Spectre 84 | 85 | :movie_camera: 86 | 87 | - Z.Bridges, D.Jeanpierre. [*Spectre/C++*](https://www.youtube.com/watch?v=ehNkhmEg0bw) – CppCon (2019) 88 | 89 | ### Tricks 90 | 91 | :movie_camera: 92 | 93 | - C.Domas. [*The M/o/Vfuscator – Turning `mov` into a soul-crushing RE nightmare*](https://www.youtube.com/watch?v=R7EEoWg6Ekk) – Derbycon (2015) 94 | 95 | :page_facing_up: 96 | 97 | - S.Dolan. [*`mov` is Turing-complete*](https://drwho.virtadpt.net/files/mov.pdf) (2013) 98 | 99 | --- 100 | 101 | ## Memory 102 | 103 | :link: 104 | 105 | - E.Martin. [*Some things I’ve learned about memory*](http://neugierig.org/software/blog/2011/05/memory.html) (2011) 106 | - U.Drepper. [*What every programmer should know about memory*](https://people.freebsd.org/~lstewart/articles/cpumemory.pdf) (2007) 107 | - [*Simple benchmark for memory throughput and latency*](https://github.com/ssvb/tinymembench) 108 | - L.Maranget, S.Sarkar, P.Sewell. [*A tutorial introduction to the ARM and POWER relaxed memory models*](https://www.cl.cam.ac.uk/~pes20/ppc-supplemental/test7.pdf) (2012) 109 | 110 | 111 | :movie_camera: 112 | 113 | - U.Drepper. [*C++ and memory: Between correctness and performance*](https://www.youtube.com/watch?v=LXfSXzxDY_M) – code::dive (2018) 114 | 115 | ### Memory addressing 116 | 117 | :link: 118 | 119 | - D.A.Rusling. [Ch. 3: *Memory management*](http://www.tldp.org/LDP/tlk/mm/memory.html) – [The Linux kernel](http://www.tldp.org/LDP/tlk/tlk-title.html) 120 | - C.Santili. [*x86 paging tutorial*](https://cirosantilli.com/x86-paging) 121 | - [*How does x86 paging work?*](https://stackoverflow.com/q/18431261) – Stack Overflow 122 | - [*What are near, far and huge pointers?*](https://stackoverflow.com/q/3575592) – Stack Overflow 123 | 124 | :movie_camera: 125 | 126 | - JF Bastien. [*`*(char*)0 = 0;`*](https://www.youtube.com/watch?v=dFIqNZ8VbRY) – C++ on Sea (2023) 127 | - C.Terman. *Virtual memory.* [Part I](https://www.youtube.com/watch?v=3akTtCu_F_k), [Part II](https://www.youtube.com/watch?v=DelO8tZFMrc) – MIT 6.004: Computation structures (2013) 128 | 129 | :book: 130 | 131 | - Essay 1: *You must be joking* – P.J.Plauger. [*Programming on purpose III: Essays on software technology*](https://www.pearson.com/us/higher-education/program/Plauger-Programming-on-Purpose-III-Essays-on-Software-Technology/PGM133229.html) (1994) 132 | 133 | 134 | 135 | 140 | 141 | --- 142 | 143 | ## Operating systems 144 | 145 | ### Libraries 146 | 147 | :movie_camera: 148 | 149 | - O.Shilon. [*Linkers, loaders and shared libraries in Windows, Linux, and C++*](https://www.youtube.com/watch?v=_enXuIxuNV4) – CppCon (2023) 150 | 151 | #### Linux 152 | 153 | :link: 154 | 155 | - I.Wienand. [*Position independent code and x86-64 libraries*](https://www.technovelty.org/c/position-independent-code-and-x86-64-libraries.html) (2013) 156 | - E.Bendersky. [*Library order in static linking*](https://eli.thegreenplace.net/2013/07/09/library-order-in-static-linking) (2013) 157 | - E.Bendersky. [*Load-time relocation of shared libraries*](https://eli.thegreenplace.net/2011/08/25/load-time-relocation-of-shared-libraries) (2011) 158 | - E.Bendersky. [*Position independent code (PIC) in shared libraries*](https://eli.thegreenplace.net/2011/11/03/position-independent-code-pic-in-shared-libraries) (2011) 159 | - E.Bendersky. [*Position independent code (PIC) in shared libraries on x64*](https://eli.thegreenplace.net/2011/11/11/position-independent-code-pic-in-shared-libraries-on-x64) (2011) 160 | 161 | #### Windows 162 | 163 | :link: 164 | 165 | - S.Ignatchenko. [*To DLL or not to DLL*](https://accu.org/journals/overload/18/99/ignatchenko_1704/) – [Overload **163**](https://accu.org/journals/overload/overload99) (2010) 166 | 167 | :movie_camera: 168 | 169 | - J.McNellis. [*Everything you ever wanted to know about DLLs*](https://www.youtube.com/watch?v=JPQWQfDhICA) – CppCon (2017) 170 | 171 | ### Device drivers 172 | 173 | :movie_camera: 174 | 175 | - D.Saks. [*Memory-mapped devices as objects*](https://www.youtube.com/watch?v=uwzuAGtAEFk) – CppCon (2020) 176 | 177 | --- 178 | 179 | -------------------------------------------------------------------------------- /people.md: -------------------------------------------------------------------------------- 1 | # People in computer science 2 | 3 | ## Table of contents 4 | 5 | - [Georgy Adelson-Velsky](#georgy-adelson-velsky) 6 | - [Howard Aiken](#howard-aiken) 7 | - [John Conway](#john-conway) 8 | - [Robert W Floyd](#robert-w-floyd) 9 | - [Margaret Hamilton](#margaret-hamilton) 10 | - [Alan Kay](#alan-kay) 11 | - [John Kemeny](#john-kemeny) 12 | - [Brian Kernighan](#brian-kernighan) 13 | - [Donald Knuth](#donald-knuth) 14 | - [Thomas Kurtz](#thomas-kurtz) 15 | - [John McCarthy](#john-mccarthy) 16 | - [Peter Norvig](#peter-norvig) 17 | - [Robert Sedgewick](#robert-sedgewick) 18 | - [Bjarne Stroustrup](#bjarne-stroustrup) 19 | - [Alexander Stepanov](#alexander-stepanov) 20 | - [Ken Thompson](#ken-thompson) 21 | - [Linus Torvalds](#linus-torvalds) 22 | - [Niklaus Wirth](#niklaus-wirth) 23 | - [Blogs](#blogs) 24 | 25 | --- 26 | 27 | :link: 28 | 29 | - [*Mikhail Donskoy: Programmer’s course of life*](https://polit.ru/article/2008/08/20/programmist/) (in Russian, 2008) 30 | 31 | :movie_camera: 32 | 33 | - G.Booch. [*John Backus*](https://www.youtube.com/watch?v=dDsWTyLEgbk) (2013) 34 | - J.Schiefer. [*Larry Wall*](https://www.youtube.com/watch?v=aNAtbYSxzuA) (2013) 35 | 36 | :book: 37 | 38 | - S.Tempus. *Programmers at work: Interviews with 19 programmers who shaped the computer industry* (1989) 39 | 40 | ## Georgy Adelson-Velsky 41 | 42 | > Georgy Adelson-Velsky (Georgii Adelson-Velskii) was a Soviet and Israeli mathematician and computer scientist. He began working in artificial intelligence and other applied topics in the late 1950s. Along with Evgenii Landis, he invented the [AVL tree](data_structures_and_algorithms/trees.md#avl-adelson-velskylandis-trees) in 1962 – the first known balanced binary search tree data structure.Beginning in 1963, Adelson-Velsky headed the development of a computer chess program at the Institute for Theoretical and Experimental Physics in Moscow. His innovations included the first use of bitboards (a now-common method for representing game positions) in computer chess. The program evolved into Kaissa, the first world computer chess champion. 43 | 44 | :movie_camera: 45 | 46 | - [*An interview with Georgy Adelson-Velsky*](https://www.youtube.com/watch?v=cE4Zb9wWf7g) (in Russian, 2002) 47 | 48 | :book: 49 | 50 | - G.M.Adelson-Velsky, V.L.Arlazarov, A.R.Bitman, M.V.Donskoy. [*Computer plays chess*](https://www.computer-museum.ru/books/kaissa.pdf) (in Russian, 1983) 51 | 52 | :anchor: 53 | 54 | - [*Georgy Adelson-Velsky*](https://en.wikipedia.org/wiki/Georgy_Adelson-Velsky) – Wikipedia 55 | 56 | ## Howard Aiken 57 | 58 | :link: 59 | 60 | - *History of informatics: Howard Aiken* (in Russian) – [Informatics and education](http://publ.lib.ru/ARCHIVES/I/%27%27Informatika_i_obrazovanie%27%27/_%27%27Informatika_i_obrazovanie%27%27.html) [**6**](http://publ.lib.ru/ARCHIVES/I/%27%27Informatika_i_obrazovanie%27%27/%27%27Informatika_i_obrazovanie%27%27%2C1994%2CN06.[djv-fax].zip), 3 (1994) 61 | 62 | :movie_camera: 63 | 64 | - H.Lewis. [*Harvard Mark I computer*](https://www.youtube.com/watch?v=4ObouwCHk8w) 65 | 66 | ## John Conway 67 | 68 | :movie_camera: 69 | 70 | - [*Inventing Game of Life*](https://www.youtube.com/watch?v=R9Plq-D1gEk) – Numberphile (2014) 71 | 72 | ## Robert W Floyd 73 | 74 | :movie_camera: 75 | 76 | - D.Knuth. [*Robert W Floyd, In memoriam*](https://www.youtube.com/watch?v=OJsMXu3EPCw) – Stanford Lecture (2002) 77 | 78 | :page_facing_up: 79 | 80 | - Robert W. Floyd. [*The paradigms of programming*](https://dl.acm.org/doi/pdf/10.1145/359138.359140) – [Communications of the ACM **22**, 455](https://doi.org/10.1145/359138.359140) (1979) 81 | 82 | ## Margaret Hamilton 83 | 84 | > Margaret Hamilton was director of the Software Engineering Division of the MIT Instrumentation Laboratory, which developed on-board flight software for NASA’s Apollo program. She has published more than 130 papers, proceedings, and reports, about sixty projects, and six major programs. She coined the term “software engineering”, stating “I began to use the term *software engineering* to distinguish it from hardware and other kinds of engineering, yet treat each type of engineering as part of the overall systems engineering process”. 85 | 86 | :movie_camera: 87 | 88 | - M.Hamilton. [*The language as a software engineer*](https://www.youtube.com/watch?v=ZbVOF0Uk5lU) – ICSE (2018) 89 | 90 | :anchor: 91 | 92 | - [*Margaret Hamilton*](https://en.wikipedia.org/wiki/Margaret_Hamilton_(software_engineer)) – Wikipedia 93 | 94 | ## Alan Kay 95 | 96 | > Alan Kay is best known for his pioneering work on object-oriented programming and windowing graphical user interface (GUI) design. At Xerox PARC he led the design and development of the first modern windowed computer desktop interface. There he also led the development of the influential object-oriented programming language [Smalltalk](programming.md#smalltalk), both personally designing most of the early versions of the language and coining the term “object-oriented”. 97 | 98 | :movie_camera: 99 | 100 | - A.Kay. [*The computer revolution hasn’t happened yet*](https://www.youtube.com/watch?v=oKg1hTOQXoY) – OOPSLA (1997) 101 | 102 | :anchor: 103 | 104 | - [*Alan Kay*](https://en.wikipedia.org/wiki/Alan_Kay) – Wikipedia 105 | 106 | ## John Kemeny 107 | 108 | > John Kemeny is best known for co-developing the BASIC programming language in 1964 with [Thomas E. Kurtz](#thomas-kurtz). Kemeny served as the 13th President of Dartmouth College from 1970 to 1981 and pioneered the use of computers in college education. He chaired the presidential commission that investigated the Three Mile Island accident in 1979. 109 | 110 | :link: 111 | 112 | - K.King. [*The computer and the campus: An interview with John Kemeny*](https://www.youtube.com/watch?v=HHi3VFOL-AI) – Dartmouth (1991) 113 | 114 | :anchor: 115 | 116 | - [*John G. Kemeny*](https://en.wikipedia.org/wiki/John_G._Kemeny) – Wikipedia 117 | 118 | ## Brian Kernighan 119 | 120 | :link: 121 | 122 | - [*Quotes by Brian Kernighan*](https://www.azquotes.com/author/38835-Brian_Kernighan) – AZQuotes 123 | 124 | :movie_camera: 125 | 126 | - J.R.Mashey. [*Oral history of Brian Kernighan*](https://www.youtube.com/watch?v=bTWv-l0JhAc) (2017) 127 | - *Questions and answers.* [Part I](https://www.youtube.com/watch?v=zmYhR8cUX90), [Part II](https://www.youtube.com/watch?v=VVpRj3Po6K4), [Part III](https://www.youtube.com/watch?v=E6vtRm5M8I0) – Computerphile 128 | - [*Where `grep` came from*](https://www.youtube.com/watch?v=NTfOnGZUZDk) – Computerphile 129 | - [*Associative arrays*](https://www.youtube.com/watch?v=qTZJLJ3Gm6Q) – Computerphile 130 | - [*The factory of ideas: Working at Bell Labs*](https://www.youtube.com/watch?v=QFK6RG47bww) – Computerphile 131 | 132 | ## Donald Knuth 133 | 134 | :link: 135 | 136 | - [*Twenty questions for Donald Knuth*](https://www.informit.com/articles/article.aspx?p=2213858) (2014) 137 | 138 | :movie_camera: 139 | 140 | - L.Fridman. [*An interview with Donald Knuth: Algorithms, complexity, life, and The art of computer programming*](https://www.youtube.com/watch?v=2BdBfsXbST8) (2019) 141 | - [*Donald Knuth on P = NP*](https://www.youtube.com/watch?v=Ph4hlOzq_pE) (2014) 142 | 143 | :book: 144 | 145 | - D.E.Knuth. [*The art of computer programming*](https://www-cs-faculty.stanford.edu/~knuth/taocp.html) 146 | 147 | ## Thomas Kurtz 148 | 149 | > Thomas Kurtz was a Dartmouth professor of mathematics and computer scientist, who along with his colleague [John G. Kemeny](#john-kemeny) set in motion the then revolutionary concept of making computers as freely available to college students as library books were, by implementing the concept of time-sharing at Dartmouth College. In his mission to allow non-expert users to interact with the computer, he co-developed the BASIC programming language and the Dartmouth Time Sharing System during 1963 to 1964. 150 | 151 | :anchor: 152 | 153 | - [*Thomas E. Kurtz*](https://en.wikipedia.org/wiki/Thomas_E._Kurtz) – Wikipedia 154 | 155 | ## John McCarthy 156 | 157 | > John McCarthy was an American computer scientist who was one of the founders of the discipline of artificial intelligence. He co-authored the document that coined the term “artificial intelligence”, developed the programming language family Lisp, significantly influenced the design of the language ALGOL, popularized time-sharing, and invented garbage collection. 158 | 159 | :movie_camera: 160 | 161 | - J.Mishlove. [*John McCarthy: Artificial intelligence*](https://www.youtube.com/watch?v=Ozipf13jRr4) – Thinking Allowed (1989) 162 | 163 | :anchor: 164 | 165 | - [*John McCarthy*](https://en.wikipedia.org/wiki/John_McCarthy_(computer_scientist)) – Wikipedia 166 | 167 | ## Peter Norvig 168 | 169 | :movie_camera: 170 | 171 | - L.Fridman. [*Artificial intelligence: A modern approach*](https://www.youtube.com/watch?v=_VPxEcT_Adc) (2019) 172 | 173 | ## Robert Sedgewick 174 | 175 | :link: 176 | 177 | - [*Robert Sedgewick*](https://sedgewick.io/) 178 | 179 | ## Bjarne Stroustrup 180 | 181 | :link: 182 | 183 | - C.Allison. [*C++: The making of a standard*](https://github.com/eugnsp/CUJ/blob/master/14.10/allison/allison.md) – C/C++ Users Journal **14** (1996) 184 | - [*Quotes by Bjarne Stroustrup*](https://www.azquotes.com/author/14260-Bjarne_Stroustrup) – AZQuotes 185 | 186 | :movie_camera: 187 | 188 | - L.Fridman. [*An interview with Bjarne Stroustrup: C++*](https://www.youtube.com/watch?v=uTxRF5ag27A) 189 | - P.McJones. [*Oral history of Bjarne Stroustrup*](https://www.youtube.com/watch?v=ZO0PXYMVGSU) (2015) 190 | - A.Stepanov. [*A.Stepanov introduces Bjarne Stroustrup*](https://www.youtube.com/watch?v=-n8FP7Ncq8A) (2014) 191 | - [*What is the difference between C and C++? Is C obsolete?*](https://www.youtube.com/watch?v=KlPC3O1DVcg) (2011) 192 | 193 | ## Alexander Stepanov 194 | 195 | :link: 196 | 197 | - [*Collected papers*](http://stepanovpapers.com/) 198 | - [*The short canon: A short list of materials for civilizing programmers*](https://psoberoi.github.io/stepanov-civilization/canon.html) 199 | - A.Stevens. [*An interview with Alex Stepanov*](http://stepanovpapers.com/drdobbs-interview.html) – Dr.Dobb’s Journal (1995) 200 | - G.L.Russo. [*An interview with Alex Stepanov*](http://www.stlport.org/resources/StepanovUSA.html) 201 | 202 | :movie_camera: 203 | 204 | - [*Programming conversations*](https://www.youtube.com/watch?v=k-meLQaYP5Y) – A9 (2014) 205 | - [*Efficient programming with components*](https://www.youtube.com/watch?v=aIHAEYyoTUc) – A9 (2013) 206 | - [*Elements of programming*](https://www.youtube.com/watch?v=Ih9gpJga4Vc) – Stanford (2010) 207 | - *Transformations and their orbits.* [Part I](https://www.youtube.com/watch?v=QmuMHtbO4ug), [Part II](https://www.youtube.com/watch?v=uCGifwlgAQg) – Yandex (in Russian, 2010) 208 | - *Greatest common measure: The last 2500 years.* [Part I](https://www.youtube.com/watch?v=NfGeVRebiio), [Part II](https://www.youtube.com/watch?v=zwucsB2EfXc) – Yandex (in Russian, 2010) 209 | - [*Educating programmers: A customer perspective*](https://www.youtube.com/watch?v=I_diUagUxGM) – Workshop on Quality Software (2012) 210 | 211 | :book: 212 | 213 | - A.A.Stepanov, P.McJones. [*Elements of programming*](http://elementsofprogramming.com/) (2009) 214 | - A.A.Stepanov, D.E.Rose. [*From mathematics to generic programming*](http://www.fm2gp.com/) (2014) 215 | 216 | ## Ken Thompson 217 | 218 | :movie_camera: 219 | 220 | - B.Kernighan. [*An interview with Ken Thompson*](https://www.youtube.com/watch?v=EY6q5dv_B-o) – VCF East (2019) 221 | 222 | ## Linus Torvalds 223 | 224 | :link: 225 | 226 | - R.A.Ghosh. [*Interview with Linus Torvalds: What motivates software developers*](https://firstmonday.org/ojs/index.php/fm/article/view/1475/1390) – First Monday (1998) 227 | - [*Linus Torvalds on C++*](http://harmful.cat-v.org/software/c++/linus) (2007) 228 | - [*Quotes by Linus Torvalds*](https://www.azquotes.com/author/14737-Linus_Torvalds) – AZQuotes 229 | 230 | :movie_camera: 231 | 232 | - W.Cardwell. [*A talk with Linus Torvalds*](https://www.youtube.com/watch?v=MShbP3OpASA) – Aalto Center for Entrepreneurship (2012) 233 | - [*Do you see any other language other than C for OS development?*](https://www.youtube.com/watch?v=CYvJPra7Ebk) 234 | 235 | ## Niklaus Wirth 236 | 237 | :movie_camera: 238 | 239 | - E.Trichina. [*Interview with Niklaus Wirth, 1984 ACM Turing award recipient*](https://www.youtube.com/watch?v=SUgrS_KbSI8) (2018) 240 | 241 | --- 242 | 243 | ## Blogs 244 | 245 | - [Simon Brand](https://blog.tartanllama.xyz/) 246 | - [Eli Bendersky](http://eli.thegreenplace.net/) 247 | - [Jonathan Boccara](http://www.fluentcpp.com/) 248 | - [Andreas Fertig](https://andreasfertig.blog/) 249 | - [Bartlomiej Filipek](http://www.bfilipek.com/) 250 | - [Kevlin Henney](https://kevlinhenney.medium.com/) 251 | - [Stephanie Hurlburt](http://stephaniehurlburt.com/blog-archive/) 252 | - [Andrzej Krzemieński](https://akrzemi1.wordpress.com/author/akrzemi1/) 253 | - [KrzaQ](https://dev.krzaq.cc/) 254 | - [Arne Mertz](http://arne-mertz.de/) 255 | - [Jonathan Müller](http://foonathan.net/) 256 | - [Arthur O’Dwyer](https://quuxplusone.github.io/blog/) 257 | - [Vittorio Romeo](https://vittorioromeo.info/) 258 | - [Filip Roséen](http://b.atch.se/) 259 | - [Adi Shavit](https://adishavit.github.io/#blog) 260 | - [Ken Shirriff](https://www.righto.com/) 261 | - [Bob Steagall](https://bobsteagall.com/) 262 | - [Philip Trettner](https://artificial-mind.net/) 263 | - [Krister Walfridsson](https://kristerw.blogspot.com/) 264 | - [Anthony Williams](https://www.justsoftwaresolutions.co.uk/blog/) 265 | -------------------------------------------------------------------------------- /programming.md: -------------------------------------------------------------------------------- 1 | # General reviews and interviews 2 | 3 | ## Table of contents 4 | 5 | - [Programming](#programming) 6 | - [Programming languages](#programming-languages) 7 | - [Algol](#algol) 8 | - [BASIC](#basic) 9 | - [C](#c) 10 | - [Pascal](#pascal) 11 | - [Procedural programming](#procedural-programming) 12 | - [Functional programming](#functional-programming) 13 | - [Lambda calculus](#lambda-calculus) 14 | - [Y combinator](#y-combinator) 15 | - [Monads](#monads) 16 | - [Generic programming](#generic-programming) 17 | 18 | --- 19 | 20 | ## Programming 21 | 22 | :movie_camera: 23 | 24 | - R.Campbell. [*The next decade of software development*](https://www.youtube.com/watch?v=ND_AjF_KTD8) – NDC London (2023) 25 | 26 | ## Programming languages 27 | 28 | :movie_camera: 29 | 30 | - [*The languages*](https://www.youtube.com/watch?v=xnCgoEyz31M) – Unix50 - Unix Today and Tomorrow (2019) 31 | 32 | :book: 33 | 34 | - Essay 4: *The central folly* – P.J.Plauger. [*Programming on purpose III: Essays on software technology*](https://www.pearson.com/us/higher-education/program/Plauger-Programming-on-Purpose-III-Essays-on-Software-Technology/PGM133229.html) (1994) 35 | 36 | ### Algol 37 | 38 | :link: 39 | 40 | - D.James. [*Algol 68 – a retrospective*](https://accu.org/journals/overload/26/148/james_2586/) – [Overload **148**](https://accu.org/journals/overload/overload148) (2018) 41 | 42 | :movie_camera: 43 | 44 | - D.Brailsford. [*Algol 60 at 60*](https://www.youtube.com/watch?v=T-NTEc8Ag-I) – Computerphile 45 | 46 | ### BASIC 47 | 48 | > Beginner’s All-Purpose Symbolic Instruction Code 49 | 50 | :link: 51 | 52 | - [*BASIC at 50*](https://www.dartmouth.edu/basicfifty/) – Dartmouth 53 | - H.McCracken. [*Fifty years of BASIC, the programming language that made computers personal*](https://time.com/69316/basic/) – Time (2014) 54 | 55 | :movie_camera: 56 | 57 | - [*Birth of BASIC*](https://www.youtube.com/watch?v=T-NTEc8Ag-I) – Dartmouth (2014) 58 | - [*The basics of BASIC, the programming language of the 1980s*](https://www.youtube.com/watch?v=seM9SqTsRG4) – The 8-Bit Guy (2017) 59 | 60 | :book: 61 | 62 | - M.J.Lorenzo. *Endless loop: The History of the BASIC programming language* (2017) 63 | 64 | ### C 65 | 66 | :movie_camera: 67 | 68 | - B.Kernighan. [*C programming language*](https://www.youtube.com/watch?v=de2Hsvxaf8M) – Computerphile 69 | - D.Brailsford. [*Why C is so influential*](https://www.youtube.com/watch?v=ci1PJexnfNE) - Computerphile 70 | 71 | ### Pascal 72 | 73 | :page_facing_up: 74 | 75 | - B.W.Kernighan. [*Why Pascal is not my favorite programming language*](https://www.lysator.liu.se/c/bwk-on-pascal.html) – Computer Science Technical Report **100** (1981) 76 | - A.N.Habermann. [*Critical comments on the programming language Pascal*](https://figshare.com/articles/journal_contribution/Critical_comments_on_the_programming_language_PASCAL/6604568/files/12094973.pdf) – [Acta Informatica **3**, 47](https://doi.org/10.1007/BF00288652) (1973) 77 | 78 | :anchor: 79 | 80 | - N.Wirth. [*Recollections about the development of Pascal*](http://www.math.bas.bg/bantchev/place/pascal/recollections.pdf) – History of programming languages II (1996) 81 | 82 | --- 83 | 84 | ## Procedural programming 85 | 86 | :link: 87 | 88 | - [*Procedural programming*](https://en.wikipedia.org/wiki/Procedural_programming) – Wikipedia 89 | 90 | :movie_camera: 91 | 92 | - K.Henney. [*Procedural programming: It’s back? It never went away*](https://www.youtube.com/watch?v=SvxBvSK4i4k) – ACCU (2018) 93 | 94 | ## Functional programming 95 | 96 | :movie_camera: 97 | 98 | - G.Lebec. *λas.js, or a flock of functions*. [Part I](https://www.youtube.com/watch?v=3VQ382QG-y4) – Fullstack Academy 99 | 100 | ### Lambda calculus 101 | 102 | :movie_camera: 103 | 104 | - [*Lambda calculus*](https://www.youtube.com/watch?v=eis11j_iGMs) – Computerphile 105 | 106 | #### Y combinator 107 | 108 | :movie_camera: 109 | 110 | - [*Functional programming’s Y combinator*](https://www.youtube.com/watch?v=9T8A89jgeTI) – Computerphile 111 | 112 | ### Monads 113 | 114 | :grey_question: 115 | 116 | - [*What is a monad?*](https://stackoverflow.com/q/44965) – Stack Overflow 117 | 118 | :movie_camera: 119 | 120 | - [*What is a monad?*](https://www.youtube.com/watch?v=t1e8gqXLbsU) – Computerphile 121 | 122 | --- 123 | 124 | ## Generic programming 125 | 126 | :movie_camera: 127 | 128 | - W.E.Brown. [*A medley of C++*](https://www.youtube.com/watch?v=dRClYjASTvA): [*What does C++20 owe to...*](https://www.youtube.com/watch?v=dRClYjASTvA&t=3385s) – C++ on Sea (2022) 129 | --------------------------------------------------------------------------------