← All courses
Computer Science / Beginner

Data Structures and Algorithms

Learn how common data structures organize information and how algorithms transform it, with an emphasis on choosing a suitable approach and explaining its cost.

▤ 5 modules✓ 5 PDFs✦ 1 researched video lesson
What you’ll learn

Learning objectives

Compare time and space cost using Big-O notation
Choose among arrays, linked lists, stacks, and queues
Explain tree and graph representations
Trace searching and sorting algorithms
Video lesson

Learn with freeCodeCamp.org (taught by Sumit Saha)

Open on YouTube  ↗
▶

Learn Data Structures and Algorithms Visually – Crash Course

freeCodeCamp.org (taught by Sumit Saha) · About 1 hour

Covers: Arrays, linked lists, stacks, queues, heaps, trees, graphs, hash tables, searching, sorting, recursion, and dynamic programming

Course roadmap

Learn it in 5 modules

0 of 5 completed
MODULE 01Ready to learn

Complexity and arrays

Identify input size, count the dominant work, and distinguish time from extra memory. Indexed array access is fast, while inserting in the middle usually shifts later elements. Big-O describes growth, not wall-clock seconds.

View key idea and practice
Key idea

An algorithm is a finite sequence of steps for solving a problem. Big-O notation describes how resource use grows as input size grows, while an array stores indexed elements in contiguous logical order.

Worked example

A one-pass scan for a target visits at most each array item, so its work grows linearly with the number of items.

Try it

Compare scanning an unsorted list with looking up an index in an array. State the assumption behind each cost.

Suggested check

Index access is constant-time under the usual array model. A value search in an unsorted array is linear because the target may be last or absent.

MODULE 02Ready to learn

Linked lists, stacks, and queues

Pick a structure by its operations. Linked lists support local node changes when a reference is known but require traversal for position lookup. Stacks and queues make ordering rules explicit and are useful in parsing, scheduling, and breadth-first search.

View key idea and practice
Key idea

A linked list connects nodes through references. A stack removes the most recently added item; a queue removes the earliest added item.

Worked example

A browser's undo history behaves like a stack: a new action is pushed and undo pops the latest action.

Try it

Choose a queue or stack for processing print jobs in arrival order, then describe an operation that removes the next item.

Suggested check

Use a queue, typically with enqueue and dequeue operations. A stack would reverse the expected processing order.

MODULE 03Ready to learn

Trees, heaps, and ordered search

Search cost in a balanced binary search tree grows with its height; an unbalanced tree can degrade toward a list. A heap maintains a parent-child priority rule and supports efficient access to the highest- or lowest-priority item.

View key idea and practice
Key idea

A tree is a connected hierarchy of nodes with a root and child relationships. A binary search tree orders keys so smaller keys lie on one side and larger keys on the other.

Worked example

A priority queue schedules the next most urgent task by storing tasks in a min-heap keyed by deadline.

Try it

Insert keys 8, 4, and 12 into a binary search tree and describe where each value belongs.

Suggested check

8 becomes the root; 4 is placed in the left subtree because it is smaller; 12 is placed in the right subtree because it is larger.

MODULE 04Ready to learn

Graphs and traversal

Represent sparse graphs with adjacency lists and dense graphs with matrices when their access pattern warrants it. Depth-first search explores deeply before backtracking; breadth-first search explores neighbors in layers and finds shortest paths in unweighted graphs.

View key idea and practice
Key idea

A graph consists of vertices and edges. Edges may be directed or undirected and may carry weights such as distance or cost.

Worked example

A route map models intersections as vertices and roads as weighted edges; Dijkstra's algorithm can find a shortest path when edge costs are nonnegative.

Try it

For an unweighted social network, choose a traversal to find all people within two connections of a starting person.

Suggested check

Breadth-first search visits nodes by increasing number of edges from the start. Track visited vertices to avoid revisiting cycles.

MODULE 05Ready to learn

Searching, sorting, and strategy

Binary search requires sorted data and halves its remaining search interval each step. Merge sort uses divide-and-conquer for predictable O(n log n) time. Use a simple sort for tiny or nearly sorted data when its trade-off is appropriate.

View key idea and practice
Key idea

Searching locates an item; sorting orders items by a comparison rule. Algorithm analysis compares correctness, time growth, space use, and assumptions.

Worked example

A directory sorted by last name can use binary search to narrow the location of an entry.

Try it

List the prerequisite that makes binary search correct, then choose a sort for a large general dataset.

Suggested check

The data must be ordered by the same comparison used in the search. Merge sort or another O(n log n) algorithm is a reasonable general choice; constraints matter.

Take it further

Study materials

5 real PDFs
Data Structures and Algorithms

Course introduction

Complexity and arrays · Linked lists, stacks, and queues · Trees, heaps, and ordered search

8 pages55 KB
Download  ↓
Data Structures and Algorithms

Beginner study notes

Complexity and arrays · Linked lists, stacks, and queues · Trees, heaps, and ordered search

8 pages55 KB
Download  ↓
Data Structures and Algorithms

Practical examples

Complexity and arrays · Linked lists, stacks, and queues · Trees, heaps, and ordered search

8 pages55 KB
Download  ↓
Data Structures and Algorithms

Exercises and practice questions

Complexity and arrays · Linked lists, stacks, and queues · Trees, heaps, and ordered search

8 pages55 KB
Download  ↓
Data Structures and Algorithms

Revision summary

Complexity and arrays · Linked lists, stacks, and queues · Trees, heaps, and ordered search

8 pages55 KB
Download  ↓