Skip to content

Latest commit

 

History

History
156 lines (118 loc) · 16.4 KB

File metadata and controls

156 lines (118 loc) · 16.4 KB

In the age of AI, Understanding Algorithms and Data Structures, Learning Different Programming Languages | 中文

In the age of AI, you need to understand algorithmic thinking and data structures, and learn different programming languages.

This repository helps you learn data structures and algorithms with different programming languages, including C Java Python JavaScript Go TypeScript, with rich comments and explanations.

In the AI era, AI can replace a lot of basic coding tasks, but it cannot replace human thinking and understanding. Only by deeply understanding the core of programming (data structures + algorithms) can we truly harness AI and make it produce high-value results.

Surface-level APIs, frameworks, and application solutions change rapidly, while data structures, algorithms, and fundamental logic endure. Surface technologies require fast learning and constant updates; fundamental principles require repeated study and reflection to continuously improve understanding.

Project Highlights

  1. Covers numerical computation, string search, tree traversal, sorting, dynamic programming, and more.
  2. Each algorithm has multiple language implementations, helping you understand language features through algorithms and data structures.
  3. Examples are rich and progressive, suitable for students and programmers to learn, analyze, and continuously improve their coding skills.

Learning Value for Students and Engineers

This project connects "concept understanding -> code implementation -> language comparison -> practice and progression" into a clear path, making it a long-term resource for coursework, self-study, interviews, and engineering skill development.

You will gain:

  • A systematic learning path: from fundamentals to classic algorithms, then to problem sets and projects, step by step.
  • Multi-language comparison: the same algorithm implemented in multiple languages to reveal differences and engineering practices.
  • Practical and reusable materials: most directories include runnable code and explanations, useful for coursework, interviews, and real projects.
  • Stronger foundations and thinking: emphasis on complexity analysis and algorithmic ideas to improve efficiency and correctness.

Algorithm Overview

What are common algorithms?

  • Text search: linear search, binary search, tree-based search, longest common subsequence, palindrome computation, mainly for string search.
  • Mathematical computation: base conversion, square roots, Fibonacci sequence, prime factorization, numeric triangles, mainly for numerical computation.
  • Sorting algorithms: bubble, selection, insertion, shell, merge, quick, heap, counting, bucket, radix, used to order data.
  • Other algorithms: dynamic programming, greedy algorithms, divide and conquer, backtracking, graph algorithms (e.g., BFS, DFS, Dijkstra, Kruskal), plus machine learning and AI algorithms like classification, clustering, deep learning, and reinforcement learning.

Algorithm Overview

Common algorithmic paradigms

  • Greedy: chooses the local optimum at each step to reach a global optimum.
  • Divide and conquer: splits a problem into smaller subproblems, solves them independently, then combines results.
  • Dynamic programming: breaks a complex problem into overlapping subproblems and solves them with memoization or tabulation.
  • Backtracking: builds solutions incrementally and abandons those that violate constraints.
  • Graph algorithms: BFS, DFS, Dijkstra, Kruskal, etc., for graph-related problems.
  • Branch and bound: explores a search tree with bounds to prune unnecessary branches.

For details, see: Classic Algorithm Ideas

10 Classic Sorting Algorithms

排序算法 C C++ Java Py JS TS Go Rust Swift 适用场景
冒泡排序 bubble sort C C++ Java Py JS TS Go Rust Swift 适用于小规模数据排序,教学用途
插入排序 insert sort C C++ Java Py JS TS Go Rust Swift 适用于小规模数据,少量元素已基本有序的情况
选择排序 selection sort C C++ Java Py JS TS Go Rust Swift 适用于小规模数据,数据交换次数较少
堆排序 heap sort C C++ Java Py JS TS Go Rust Swift 适用于优先队列、TOP K问题
快速排序 quick sort C C++ Java Py JS TS Go Rust Swift 适用于一般排序场景,性能优异但不稳定
归并排序 merge sort C C++ Java Py JS TS Go Rust Swift 适用于大数据量排序,适合外部排序
计数排序 counting sort C C++ Java Py JS TS Go Rust Swift 适用于数据范围有限的整数排序
基数排序 radix sort C C++ Java Py JS TS Go Rust Swift 适用于大规模整数排序,如身份证号、手机号排序
桶排序 bucket sort C C++ Java Py JS TS Go Rust Swift 适用于数据范围均匀分布的排序
希尔排序 shell sort C C++ Java Py JS TS Go Rust Swift 适用于中等规模数据排序,适合半有序数据

String Search and Lookup

Algorithm C Go JS Python Java TS Time Complexity (Avg/Worst) Space Complexity Use Cases
Naive Search C Go JS Python Java TS O(mn) / O(mn) O(1) Suitable for small-scale text search
Binary Search C Go JS Python Java TS O(log n) / O(log n) O(1) Suitable for searching in sorted arrays
KMP Search C Go JS Python Java TS O(n + m) / O(n + m) O(m) Suitable for large-scale text search

Tree Search and Traversal

Algorithm C JS Python Java TS Time Complexity (Avg/Worst) Space Complexity Use Cases
Binary Tree Traversal C JS Python Java TS O(n) / O(n) O(n) Suitable for tree traversal, e.g., XML parsing or file system traversal

Prime Factorization

Language Code Link Complexity Use Cases
C factor.c O(sqrt(n)) Prime factorization of large integers
C++ factor.cpp O(sqrt(n)) Efficient mathematical computation
JavaScript factor.js O(sqrt(n)) Number theory on the web
TypeScript PrimeFactor.ts O(sqrt(n)) Front-end or Node.js computation
Go factor.go O(sqrt(n)) Backend service computation
Python factor.py O(sqrt(n)) Scientific computing and data analysis
Java Factor.java O(sqrt(n)) Enterprise application computation
Kotlin factor.kt O(sqrt(n)) Android and backend computation
Swift factor.swift O(sqrt(n)) iOS/macOS development
Objective-C factor.m O(sqrt(n)) Legacy iOS/macOS development
Rust factor.rs O(sqrt(n)) High-performance computation

Removing Duplicate Items from Arrays and Lists

Language Code Link Time Complexity Use Cases
C unique.c O(n log n) Embedded development
Go unique.go O(n log n) High-concurrency scenarios
JS unique.js O(n) Front-end data processing
Python unique.py O(n) Data cleaning and analysis
Java UniqueArray.java O(n log n) Enterprise applications
TypeScript UniqueArray.ts O(n) Front-end TypeScript projects
Rust unique.rs O(n) High-performance computation

Recursion

Algorithm Code Link Time Complexity Space Complexity Use Cases
Basic Recursion C O(2^n) O(n) Divide and conquer, tree/graph traversal, backtracking

Mathematical Computation

Algorithm Code Link Time Complexity Space Complexity Use Cases
Mathematical Computation C O(n) O(1) Number theory, addition, multiplication, big integer computation

Date and Calendar

Algorithm Code Link Time Complexity Space Complexity Use Cases
Date and Calendar C O(1) O(1) Date calculation, holiday estimation, date conversion

Data Structures

Data structures organize and store data, enabling efficient processing. Different data structures have different efficiency for access, insertion, and deletion. Choosing the right structure improves performance. See: Overview of Data Structures

Data Structure Description Characteristics Access Complexity Insert/Delete Complexity
Array A collection of elements of the same type, supports random access by index Contiguous memory, linear or non-linear O(1) O(n)
Linked List Nodes connected by pointers; includes singly, doubly, and circular lists Linear, non-contiguous memory O(n) O(1) (head) / O(n) (middle)
Tree Hierarchical data; includes binary tree, BST, balanced trees Non-linear, one root node, multiple children O(log n) O(log n)
Heap Special complete binary tree with heap property Non-linear, efficient for extremes O(1) (peek) O(log n)
Stack LIFO structure Linear, only top operations O(1) O(1)
Queue FIFO structure Linear, enqueue at tail, dequeue at head O(1) O(1)
Graph Nodes (vertices) and edges; adjacency list or matrix Non-linear, many-to-many O(1) (matrix) / O(n) (list) O(1) (matrix) / O(n) (list)
Hash Maps keys to positions via hash functions Linear, key-value mapping O(1) (amortized) O(1) (amortized)
Struct Combines multiple fields into one object Custom, fixed fields, multiple types O(1) O(1)
List Ordered collection allowing duplicates Linear, insertion order O(1) (append), O(n) (middle ops) O(1) (index), O(n) (search)
Set Unordered collection without duplicates Linear, based on hash or tree O(1) (hash) / O(log n) (tree) O(1) (hash) / O(log n) (tree)
Map Stores key-value pairs Associative array, hash or balanced tree O(1) (hash) / O(log n) (tree) O(1) (hash) / O(log n) (tree)

Related Links

Welcome to Contribute

Repository: https://github.com/microwind/algorithms Site: https://microwind.github.io/algorithms

If you are interested in this project, please add me on WeChat. Let’s build it together!

wechat: springbuild

Email: jarryli@gmail.com or lichunping@buaa.edu.cn