CPP Module 09 — Mert İlhan
The last C++ module: choosing the right STL container for each problem and paying for that choice in performance.
Three exercises, each about picking the right container rather than writing one. After four modules spent building classes and templates by hand, the last one hands you the STL and makes the choice of data structure — and the cost of that choice — the actual difficulty. Every exercise must use a different container.
Bitcoin exchange — lookup by nearest earlier date
A CSV of historical prices is loaded into a std::map keyed by date, because the query is not 'find this date' but 'find the most recent date at or before this one'. An ordered container answers that with lower_bound in logarithmic time; a hash map cannot answer it at all, which is what makes the container choice the exercise.
Input validation is most of the work
The input file is deliberately hostile: badly formed dates, dates that do not exist, negative values, values above the allowed maximum, missing separators and empty lines. Each one needs its own message and none of them may abort the run — the program reports the bad line and carries on.
Reverse Polish Notation with a stack
Tokens are read left to right; operands are pushed and each operator pops two and pushes the result. The interesting part is the failure modes — an operator with too few operands beneath it, leftover operands at the end, division by zero, and tokens that are neither — all of which have to be caught before the expression is evaluated.
Ford-Johnson merge insertion sort
The final exercise implements merge-insertion sort, which is close to optimal in the number of comparisons it uses. Elements are paired and the larger of each pair sorted recursively, then the smaller ones are inserted into that sorted chain — and crucially the insertion order follows the Jacobsthal sequence, so every insertion lands in a range whose size is a power of two and binary search never wastes a comparison.
The same algorithm in two containers
The sort is written twice, over two different containers, and the program times both on the same input. The comparison count is identical; the wall clock is not. That gap — contiguous storage and cache behaviour versus chunked storage and cheaper insertion — is the lesson the module ends on.
C++98 throughout
No auto, no range-based for, no initialiser lists, no unordered containers. Everything is built from iterators and the containers the 1998 standard provides, which is what forces the container choice to be deliberate rather than habitual.
Technologies: C++98, STL, Containers, Algorithms
Other Projects by Mert İlhan
- MediScan AI — AI powered health platform that recognises medicine from a photo of its box, blister or the pill itself, then rewrites the official leaflet in language anyone can understand.
- This Portfolio — The site you are reading. A React single page app deployed to GitHub Pages, with a projects section that reads its own statistics and documentation from the GitHub API at runtime.
- Employee Retention Model — Capstone of the Google Advanced Data Analytics certificate: predicting which employees are about to leave a company, and identifying what is actually driving them out.
- Born2beroot — A hardened Debian server built from a blank virtual machine: encrypted LVM partitions, a strict sudo and password policy, a firewall, a scheduled monitoring script — and, for the bonus, a WordPress site served by lighttpd and MariaDB.
- NetPractice — A networking exercise: repair ten broken TCP/IP topologies by working out the addressing, masks and routes each one needs.
- ft_transcendence — The final project of the common core: a real time multiplayer Pong website with accounts, chat and matchmaking.
- Webserv — A non blocking HTTP/1.1 server written from scratch in C++98. Parses its own nginx style config, serves static files, handles CGI and keeps many clients alive on a single event loop.
- CPP Modules 05-08 — The advanced half of the 42 C++ track: exception hierarchies, type casting and serialisation, templates, and finally container and iterator work on top of the STL.
- Inception — A small infrastructure built entirely from hand written Dockerfiles: NGINX with TLS, WordPress on PHP-FPM and MariaDB, wired together with docker-compose and persistent volumes.
- miniRT — A ray tracer in C. Parses a scene description, then renders spheres, planes and cylinders with ambient and diffuse lighting, hard shadows and 2×2 supersampling.
- minishell — A working shell in C. Lexer and parser for quotes, redirections and pipes, plus its own builtins, environment handling and signal behaviour that matches bash.
- Philosophers — The dining philosophers problem solved with threads and mutexes. No philosopher starves and no data race survives, which is the entire difficulty of the exercise.
- push_swap — Sorting a stack with a restricted instruction set, using a radix sort to keep the instruction count low. Graded purely on how short the output sequence is.
- fract-ol — Real time fractal explorer built on MiniLibX, rendering the Mandelbrot and Julia sets with interactive zoom deep into the boundary.
- minitalk — A client and server that exchange whole strings using nothing but the two UNIX user signals, encoding each character one bit at a time.
- get_next_line — Reads one line at a time from any file descriptor, keeping the leftover bytes in a static buffer between calls so nothing is read twice or lost.
- ft_printf — A reimplementation of printf with variadic arguments, handling the conversion specifiers of the original and returning the same character count.
- libft — The first project of the cursus: a static library rebuilding the parts of the C standard library that every later project depends on.