Skip to Content
  • Loading menu bar
  • Loading menu bar
  • Search
    Search
Codecademy Logo
  1. Cheatsheets/
  2. CS102: Data Structures and Algorithms

Greedy Algorithms

Topics

  • Nodes
  • Linked Lists
  • Doubly Linked Lists
  • Queues
  • Stacks
  • Hash Maps
  • Recursion
  • Asymptotic Notation
  • Pattern Searching
  • Sorting Algorithms
  • Brute Force Algorithms
  • Trees
  • Tree Traversal: Breadth-First Search and Depth-First Search
  • Divide and Conquer
  • Heaps and Heapsort
  • Graphs and Graph Search
  • Greedy Algorithms
  • Dynamic Programming

Greedy Algorithms

  • A greedy algorithm solves an optimization problem by making the best decision at each step. This is known as the locally optimal decision.
  • Greedy algorithms are simple and efficient but are NOT always correct.
  • In order for a greedy algorithm to work, a problem must satisfy:
    • The optimal substructure property
    • The greedy property
Greedy solution to the largest path problem.
Previous
Next

Learn more on Codecademy

  • Course

    Learn Data Structures and Algorithms with Python

    Learn what data structures and algorithms are, why they are useful, and how you can use them effectively in Python.
    Checker Dense
    With Certificate
    Checker Dense
    Intermediate
    26 hours
  • Career path

    Computer Science

    Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    Checker Dense
    Includes 6 Courses
    Checker Dense
    With Professional Certification
    Checker Dense
    Beginner Friendly
    75 hours

Company

  • About
  • Careers
  • Affiliates
  • Partnerships

Resources

  • Articles
  • Blog
  • Cheatsheets
  • Code challenges
  • Docs
  • Projects
  • Videos
  • Workspaces

Support

  • Help Center

Resources

  • Articles
  • Blog
  • Cheatsheets
  • Code challenges
  • Docs
  • Projects
  • Videos
  • Workspaces

Support

  • Help Center

Plans

  • For individuals
  • For students
  • For business
  • Discounts

Community

  • Visit community
  • Code Crew
  • Events
  • Learner Stories
Codecademy from Skillsoft
Codecademy from Skillsoft

Subjects

  • AI
  • Cloud computing
  • Code foundations
  • Computer science
  • Cybersecurity
  • Data analytics
  • Data science
  • Data visualization
  • Developer tools
  • DevOps
  • Game development
  • IT
  • Machine learning
  • Math
  • Mobile development
  • Web design
  • Web development

Languages

  • Bash
  • C
  • C++
  • C#
  • Go
  • HTML & CSS
  • Java
  • JavaScript
  • Kotlin
  • PHP
  • Python
  • R
  • Ruby
  • SQL
  • Swift

Career building

  • Career paths
  • Career Center
  • Interview prep
  • Professional certification
  • Compare to bootcamps
  • —
  • Full catalog
  • Beta content
  • Roadmap

Mobile

  • Download on the App Store
  • Get it on Google Play

Mobile

  • Download on the App Store
  • Get it on Google Play
  • Privacy Policy
  • Cookie Policy
  • Do Not Sell My Personal Information
  • Terms
Made with ❤️in NYC © 2025 Codecademy