Skip to content

Repository files navigation

Computer Science from First Principles

Learn Computer Science the way experienced engineers think about it—by understanding why concepts exist before learning how they work, then reinforcing that knowledge through hands-on implementation.

Most resources teach Computer Science as a collection of disconnected topics:

  • Learn arrays.
  • Learn hash maps.
  • Learn trees.
  • Learn graphs.

While this approach works for passing exams or coding interviews, it often leaves one important question unanswered:

Why do these data structures and algorithms exist in the first place?

This repository takes a different approach.

Every concept starts with the problem it was designed to solve, explains the reasoning behind the solution, explores how it works internally, and finishes with where you'll encounter it in real-world software systems.

The goal isn't to memorize implementations—it's to build intuition through explanation, visualization, and practice.


Who is this repository for?

This repository is for:

  • Computer Science students
  • Self-taught developers
  • Junior software engineers
  • Developers preparing for technical interviews
  • Anyone who wants to strengthen their Computer Science fundamentals

Whether you're learning your first hash map or revisiting memory management after years of programming, this repository aims to help you understand concepts deeply rather than memorize them.


Learning Philosophy

Every concept follows the same learning path.

1. The Problem

What challenge does this concept solve?

Why wasn't the previous solution good enough?


2. The Solution

How does this concept solve the problem?

What is the core idea?


3. How It Works

A step-by-step explanation of the internal mechanics.

Where appropriate, concepts include:

  • Diagrams
  • Visual explanations
  • Pseudocode
  • Implementation walkthroughs

4. Real-World Applications

Where do companies actually use this?

Examples include systems built by companies like:

  • Uber
  • Netflix
  • Google
  • Amazon
  • Meta

5. Advantages & Trade-offs

Every engineering decision has benefits and costs.

Understanding both is what separates memorization from engineering.


6. Interview Questions

Each chapter concludes with common interview questions and concise answers to reinforce understanding and prepare you for technical interviews.


7. Hands-On Practice

Learning doesn't stop at theory.

Every topic includes practical coding exercises such as:

  • Implementing the data structure or algorithm from scratch
  • Solving classic interview problems
  • Exploring edge cases
  • Comparing different implementations
  • Understanding time and space complexity through code

The goal is to bridge the gap between theory and real software engineering.


Repository Structure

Each topic follows the same structure for consistency.

Topic/
│
├── README.md          # Theory and explanations
├── .py                # Implementations



Learning Progress

Foundations


Trees


Graphs

  • Graph Representation
  • Breadth-First Search (BFS)
  • Depth-First Search (DFS)
  • Topological Sorting
  • Dijkstra's Algorithm
  • Minimum Spanning Trees
  • Union Find (Disjoint Set)

Algorithms

  • Sorting Algorithms
  • Searching Algorithms
  • Recursion
  • Divide and Conquer
  • Greedy Algorithms
  • Dynamic Programming
  • Backtracking

Complexity

  • Big O Notation
  • Time Complexity
  • Space Complexity
  • Amortized Analysis

Memory & Systems

  • Memory Layout
  • Stack vs Heap
  • Garbage Collection
  • CPU Cache
  • Locality of Reference
  • Virtual Memory
  • File Systems

Hands-On Learning

Every topic includes practical exercises designed to reinforce the concepts.

Examples include:

  • Building data structures from scratch
  • Implementing algorithms without relying on language libraries
  • Solving interview-style coding problems
  • Comparing multiple implementations
  • Measuring algorithm performance
  • Applying concepts to small real-world projects where appropriate

The objective is not only to understand the theory, but also to gain confidence implementing and using these concepts in real software.


Why This Repository Exists

Modern software engineering isn't just about writing code.

It's about understanding why systems are designed the way they are.

A hash map isn't simply a data structure—it powers caches, databases, and distributed systems.

A heap isn't just used in coding exercises—it powers schedulers, priority queues, and pathfinding algorithms.

A trie isn't just an interview question—it enables autocomplete, spell checkers, and search engines.

The deeper your understanding of these concepts, the easier it becomes to learn databases, operating systems, networking, distributed systems, and system design.


Companion Repository

If you're interested in how these foundational concepts come together to build large-scale applications, check out my companion repository:

System Design from First Principles

Together, these repositories provide a complete learning path from core Computer Science fundamentals to designing scalable, reliable software systems.


Contributing

Contributions, corrections, and suggestions are always welcome.

If you notice an error, have a clearer explanation, or would like to improve an example or exercise, feel free to open an issue or submit a pull request.


License

This repository is licensed under the MIT License.

About

Learn Computer Science from first principles - understand why concepts exist, how they work, and where they're used in real-world software systems.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages