Skip to content

Latest commit

Β 

History

History
111 lines (79 loc) Β· 2.85 KB

File metadata and controls

111 lines (79 loc) Β· 2.85 KB

Data Structures and Algorithms in Java

A comprehensive guide to understanding and implementing data structures and algorithms from scratch using Java, complete with algorithm analysis, Big O notation explanations, and LeetCode problem solutions.

πŸ“š Table of Contents

  • About
  • Getting Started
  • Algorithm Analysis
  • Big O Notation
  • Data Structures
  • Algorithms
  • LeetCode Solutions

🎯 About

This repository is a complete resource for learning data structures and algorithms in Java. Whether you're preparing for technical interviews, strengthening your computer science fundamentals, or solving coding challenges, this repository provides:

  • Theoretical explanations of algorithm analysis and complexity
  • Practical implementations of data structures and algorithms from scratch
  • Real-world applications through LeetCode problem solutions
  • Clear examples with detailed comments and time/space complexity analysis

πŸš€ Getting Started

Prerequisites

  • Java JDK 21
  • An IDE (preferably IntelliJ IDEA)
  • Basic understanding of Java programming

Clone the Repository

git clone https://github.com/miladsade96/Data-Structures-and-Algorithms-in-Java.git
cd data-structures-algorithms-java

Running Examples

Each implementation includes a main method for testing. To run an example:

  1. Open the desired Java package in your IDE.
  2. Locate the Main class.
  3. Run the main method to see the output.

πŸ“Š Algorithm Analysis

Understanding how to analyze algorithms is crucial for writing efficient code. This section covers:

  • What is algorithm analysis?
  • Time complexity analysis
  • Space complexity analysis
  • Best, average, and worst-case scenarios

πŸ“ˆ Big O Notation

Big O notation describes the performance or complexity of an algorithm. This section includes:

Common Time Complexities

Notation Name
O(1) Constant
O(log n) Logarithmic
O(n) Linear
O(n log n) Linearithmic
O(nΒ²) Quadratic

Each complexity includes:

  • Detailed explanation
  • Java examples with code

πŸ—‚οΈ Data Structures

  • Linked List (Singly, Doubly)
  • Stacks
  • Queues
  • Trees
  • Hash Tables
  • Graphs
  • Heaps

Each data structure includes:

  • Complete implementation from scratch
  • Time and space complexity analysis
  • Common operations (insert, delete, search, traverse)
  • Related LeetCode problems

πŸ”§ Algorithms

  • Recursion
  • Tree Traversals
  • Basic Sorting Algorithms (Bubble, Selection, Insertion)
  • Advanced Sorting Algorithms (Merge, Quick)
  • Dynamic Programming

πŸ’‘ LeetCode Solutions

Each data structure and algorithm section includes solutions to related LeetCode problems:

  • Problem statement and link
  • Approach explanation
  • Complete Java solution
  • Time and space complexity analysis
  • Alternative solutions when applicable