← Winnitude! Search  ·  Reader Mode (413 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
REAL PYTHON · Real Python · 144 LINKS

Algorithms Tutorials - Real Python

Algorithms in Python

Build your algorithm skills in Python with hands-on tutorials that cover sorting, searching, graphs, greedy techniques, and dynamic programming. You will learn to think in Big O, pick the right data structures, and turn pseudocode into clean, Pythonic solutions you can ship and discuss in interviews.

Join Now: Click here to join the Real Python Newsletter and you'll never miss another Python tutorial, course, or news update.

Work with battle-tested tools from the standard library to write fast, readable code. Use heapq for priority queues, bisect for binary search, collections.deque for BFS, itertools for combinatorics, and functools.lru_cache for memoization. Measure real performance with timeit and cProfile, and reach for NumPy or NetworkX when vectorization or graph tooling helps.

Browse all resources below, or commit to a guided Learning Path with progress tracking:

Learning Path

Classic Data Structures and Algorithms

19 Resources ⋅ Skills: Python, Data Structures, Stacks, Queues, Linked Lists, Hash Tables, Enums, Search Algorithms, Sorting Algorithms, Collections

Use Big O notation to reason about growth: count loops, focus on dominant terms, and watch nested loops and recursion . Validate runtime with timeit , but remember Big O is about scaling behavior, not specific timings.

Prefer the built-in bisect module for sorted lists. It gives insertion points and supports O(log n) searches. If you write binary search yourself, then maintain two pointers and loop while lo <= hi.

Use collections.deque as the BFS queue and a list or recursion for DFS. Represent graphs as adjacency lists, for example dict[str, set[str]], and track a visited set to avoid repeats.

Pick better data structures, avoid quadratic patterns, and move hot paths to built-ins like sorted, sum, and min. Profile with cProfile , cache results using functools.lru_cache , and consider NumPy for numeric loops.

Use a heap when you need the smallest (or largest with inverted keys) item quickly, or to keep a rolling top-k. heapq.heappush() and heapq.heappop() run in O(log n) and power tasks like Dijkstra and scheduling.

Not sure where to start? Mentor AI can put these tutorials in an order that fits what you already know.

  • Ask Mentor AI
  • Pick a question and Mentor AI takes it from here.
  • Suggest a learning order
  • Is there a learning path for this?

  • Ask something else...

Fourier Transforms With scipy.fft: Python Signal Processing

Dec 06, 2026 advanced algorithms data-science

K-Means Clustering in Python: A Practical Guide

Nov 24, 2026 advanced algorithms data-science machine-learning

How to Do a Binary Search in Python

Nov 14, 2026 intermediate algorithms

Python Coding Interview Practice: Prefix Sums and Binary Search

Nov 10, 2026 intermediate algorithms data-structures

Python Coding Interview Practice: Hashing, Pointers, and Windows

Nov 10, 2026 intermediate algorithms data-structures

Python Coding Interview Practice: Prefix Sums and Binary Search

Nov 10, 2026 intermediate algorithms data-structures

Python Coding Interview Practice: Hashing, Pointers, and Windows

Nov 10, 2026 intermediate algorithms data-structures

Recursion in Python: An Introduction

Nov 01, 2026 intermediate algorithms python

Sorting Algorithms in Python

Sep 23, 2026 intermediate algorithms python

K-Means Clustering in Python: A Practical Guide

Aug 04, 2026 advanced algorithms data-science machine-learning

How to Flatten a List of Lists in Python

May 11, 2026 intermediate algorithms data-science

How to Flatten a List of Lists in Python

May 11, 2026 intermediate algorithms data-science

Python Stacks, Queues, and Priority Queues in Practice

Mar 06, 2026 intermediate algorithms data-structures

Build a Hash Table in Python With TDD

Feb 23, 2026 intermediate algorithms data-structures

Recursion in Python: An Introduction

Dec 23, 2025 intermediate algorithms python

The Real Python Podcast - Episode #257: Comparing Real-World Python Performance Against Big O

Jul 11, 2025 intermediate algorithms best-practices data-science

Flattening a List of Lists in Python

intermediate algorithms data-science

Recursion in Python

intermediate algorithms python

Using k-Nearest Neighbors (kNN) in Python

intermediate algorithms data-science machine-learning

Minimax in Python: Learn How to Lose the Game of Nim

Oct 05, 2022 intermediate algorithms gamedev

Python Stacks, Queues, and Priority Queues in Practice

Jun 29, 2022 intermediate algorithms data-structures

Build a Hash Table in Python With TDD

Mar 16, 2022 intermediate algorithms data-structures

Exploring the Fibonacci Sequence With Python

intermediate algorithms

Draw the Mandelbrot Set in Python

Jan 31, 2022 intermediate algorithms data-viz numpy

A Python Guide to the Fibonacci Sequence

Sep 08, 2021 intermediate algorithms

The k-Nearest Neighbors (kNN) Algorithm in Python

Apr 07, 2021 intermediate algorithms data-science machine-learning

Stochastic Gradient Descent Algorithm With Python and NumPy

Jan 27, 2021 advanced algorithms machine-learning numpy

Introduction to Sorting Algorithms in Python

intermediate algorithms

Sentiment Analysis: First Steps With Python's NLTK Library

Jan 13, 2021 intermediate algorithms data-science machine-learning

Creating a Binary Search in Python

intermediate algorithms

Sorting Algorithms in Python

Apr 15, 2020 intermediate algorithms python

Logistic Regression in Python

Jan 13, 2020 intermediate algorithms data-science machine-learning

Share Feedback