https://github.com/kibet-rotich/c-learning
A deep dive into C and C++ fundamentals, documenting my journey through K&R C, manual memory management, and custom data structures like BSTs.
https://github.com/kibet-rotich/c-learning
binary-search-tree c cpp data-structures memory-management pointers
Last synced: 27 days ago
JSON representation
A deep dive into C and C++ fundamentals, documenting my journey through K&R C, manual memory management, and custom data structures like BSTs.
- Host: GitHub
- URL: https://github.com/kibet-rotich/c-learning
- Owner: Kibet-Rotich
- Created: 2025-11-23T21:20:28.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2026-03-07T11:12:13.000Z (4 months ago)
- Last Synced: 2026-03-07T17:56:06.050Z (4 months ago)
- Topics: binary-search-tree, c, cpp, data-structures, memory-management, pointers
- Language: C
- Homepage:
- Size: 14.7 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🌟 Low-Level Programming & Data Structures Journey
Welcome to my learning repository. While I initially started with **C++**, I decided to take a step back into **C** to build a rock-solid understanding of memory management, pointers, and the "under-the-hood" mechanics that make C++ so powerful.
This repo documents my path through the **K&R (Kernighan & Ritchie)** curriculum and my implementation of fundamental data structures from scratch.
---
## 📁 Project Roadmap
### 🏛️ The C Foundation (K&R Progress)
- **Basic Syntax & Types:** Operators, loops, and control flow.
- **Functions & Program Structure:** External variables and scope.
- **Pointers & Arrays:** Deep dive into pointer arithmetic and memory addresses.
- **Structures:** Building custom data types and complex models.
- **Input/Output:** Mastering `stdio.h` and file streams.
### 🏗️ Data Structures from Scratch
- **Binary Search Trees (BST):** Alphabetical Contact Management System with `malloc` and recursion.
- **Dynamic Lists:** Custom implementations of resizable arrays.
- **Memory Management:** Safe allocation/deallocation using `malloc`, `free`, `new`, and `delete`.
---
## 🧱 Key Projects
### 📈 [Linear Regression with C & Python Interface](./Linear%20regression/README.md)
A hybrid project showcasing a **linear regression algorithm implemented in C** with a Python test script for interfacing.
- **Features:** Train a linear regression model and predict outcomes using the compiled C code.
- **Interoperability:** Includes a `test.py` script demonstrating how to call the C functions from Python, combining C performance with Python flexibility.
### 📱 [BST Phonebook (C)](./C/phonebook.c)
A command-line application using a **Binary Search Tree** to store and search contacts.
- **Complexity:** $O(\log n)$ average time for search and insertion.
- **Features:** Alphabetical insertion using `strcmp`, In-order DFS traversal for listing, and manual Post-order heap memory cleanup.
### 📝 [Student Ledger (C)](./C/student%20ledger.c)
A persistent storage application demonstrating the use of the **Standard I/O Library** (`stdio.h`).
- **Features:** File stream management using `fopen`, `fprintf`, and `getc`.
- **Persistence:** Appends records to a `.txt` database, allowing data to survive between program executions.
### 🔢 [Vector Simulation (C++)](./C++/vector%20simulation.cpp)
A custom implementation of a dynamic array, mimicking the behavior of `std::vector` to understand how the STL manages capacity and resizing.
## 🛠 Toolset & Workflow
- **Compiler:** `gcc` for C, `g++` for C++.
- **Environment:** Linux/Unix-based CLI.
- **Memory Safety:** Manual tracking of heap allocations to prevent memory leaks (checked via `freeTree` logic).
```bash
# To compile the C Phonebook
gcc phonebook.c -o phonebook
./phonebook
```
## 🎯 The Vision
> "To understand C++ at a deeper level, one must first respect the power of C."
My goal is to complete the K&R curriculum and then transition those low-level skills into Modern C++ (C++11/14/17/20), focusing on:
- **RAII** (Resource Acquisition Is Initialization)
- **Smart Pointers** (Unique, Shared)
- **Templates & Meta-programming**
- **The STL Architecture**
## 🙌 Contributions & Learning
This is a living documentation of my computer science journey at JKUAT. Feedback on my pointer logic or memory management is always appreciated!
⭐ If you find this helpful, consider starring the repo!