Save this video free

CS50 Fall 2025 - Lecture 5 - Data Structures (live, unedited)

CS50 · 2:35:10 · Watch on YouTube

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

CS50's Lecture 5 explores fundamental data structures in C, contrasting arrays with linked lists and introducing abstract data types like stacks and queues. The lecture details memory management with `malloc`, `realloc`, and `free`, demonstrating dynamic array resizing and the implementation of linked lists. It then delves into binary search trees and hash tables, highlighting trade-offs between space, time complexity, and implementation complexity, culminating in a discussion of tries for achieving near-constant time lookups.

Key takeaways

Chapters

14:05 Introduction to Data Structures: Stacks and Queues
16:54 Implementing Queues and Stacks with Arrays
20:00 Dictionaries as Abstract Data Types
20:36 Arrays: Contiguous Memory Allocation
24:30 Dynamic Memory Allocation with `malloc`
26:20 Pointer Arithmetic and Array Equivalence
29:30 Resizing Dynamically Allocated Memory: `realloc`
35:00 Memory Leaks and `free()`
40:15 Linked Lists: Dynamic Data Structures
44:20 Implementing Linked List Nodes
49:00 Building a Linked List: Prepending Nodes
52:15 Traversing and Printing a Linked List
54:20 Linked List Insertion: Appending and Sorted Order
58:20 Handling Insertion Scenarios in Linked Lists
1:02:00 Freeing Linked List Memory
1:09:00 Recap: Arrays vs. Linked Lists
1:17:30 Binary Search Trees (BSTs): Combining Speed and Dynamism
1:20:00 BST Search Algorithm (Recursive)
1:23:20 BST Challenges: Balancing and Degeneration
1:28:00 Hashing: Mapping Infinite to Finite Domains
1:29:00 Hash Function Implementation
1:31:00 Hash Tables: Arrays of Linked Lists
1:34:00 Hash Table Collisions and Trade-offs
1:40:00 Tries: Achieving Constant Time Lookups
1:42:00 Trie Implementation and Lookup
1:44:00 Trie vs. Hash Table: Space vs. Time
1:45:00 Real-World Hashing: Sweetgreen Example
1:46:40 Final Data Structures and Problem Set 5

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

14:45 All right, this is CS 50, and this is week 5 already, uh, wherein we will focus today on data structures, which is a topic we touched on a little bit in in simple form, but today we'll dive all the more deeply and for better or for worse, this is our last week on C. Uh, next week, of course we transition to Python, which is a so-called higher level programming language, which is really frankly just gonna make our lives a lot easier. We're gonna be able to solve a lot of the same problems, but so much more quickly as. Humans, but not necessarily as we'll see as fast when we run the code as the computer might have if we were still using a lower level language like C. So indeed thematic over this week and next is going to be the theme that we've seen before of trade-offs. But before we get there, why don't we focus on a couple of data

15:33 structures that you might encounter in the real world, uh, namely stacks and cues. Let's learn some facts about both of these if we could dim the lights dramatically. Once upon a time there was a guy named Jack. When it came to making friends, Jack did not have the knack. So Jack went to talk to the most popular guy he knew. He went up to the loo and asked, Sorry, can we rewind? I didn't hit the right button. Stuff is happening on the screen that you are not seeing. All right, maybe let's uh bring the lights back up. All right. But first, let's learn the facts about cues and stacks. Once upon a time there was a guy named Jack.

16:20 When it came to making friends, Jack did not have the knack.

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, CS50.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.