Recursive List Traversal

Introduction

Recursive list traversal is the idea that a list — whether a JavaScript array or a linked list — can be processed by handling one element and then handing the rest of the structure to the same function again. Instead of writing a loop with an index counter, you define the problem in terms of itself: the first element plus the result of traversing everything after it. The base case is what stops the process, usually an empty list (or an index that has run past the end, or a null node), and it is what keeps the recursion from running forever.

This matters in COP3530 because lists are the structures you will work with constantly, and many of the data structures later in the course — linked lists, trees, graphs — are defined recursively. Once you can see a list as "a head plus a smaller list," recursive solutions for summing, searching, counting, printing, and transforming elements all follow the same shape. You will also see clearly how each call adds a stack frame, which connects list traversal back to the call stack discussion and to the practical limits of recursion on large inputs.

As you watch, pay attention to three things: exactly how each author states the base case, how the "rest of the list" is produced (a slice, an incremented index, or a next pointer), and where the work on the current element happens — before the recursive call or after it returns. Also try to mentally compare each recursive version with the loop you would have written instead, so you can judge which is clearer and which is cheaper.

Video 1: Lists, Slices, & Recursion

John DeNero · 8:44 · 5,929 views · 1y ago · captions — Watch on YouTube

About this video

A lecture from John DeNero on combining lists with recursion, with emphasis on slicing as the mechanism for producing the smaller sub-list that gets passed to the next call. Expect examples where a list is split into a first element and the remaining slice, and where the recursion bottoms out on an empty or very short list. The talk frames recursion as a natural way to express operations over sequences.

Why this video

DeNero is a well-known CS instructor, and this video goes directly at the core mental model of the topic: the base case for a list and the step that shrinks it, which supports the "What Is Recursive List Traversal?" and base-case subtopics.

Video 2: Singly-Linked List: Recursive Operations

Professor Kevin Wortman · 12:31 · 1,187 views · 5y ago · captions — Watch on YouTube

About this video

Professor Kevin Wortman designs and implements recursive operations on a singly-linked list, showing how a node-and-next structure maps onto recursive definitions. The video covers how to write operations that handle the current node, recurse on the rest of the list, and terminate when the end of the list is reached. Accompanying slides walk through the design reasoning as well as the code.

Why this video

It extends the topic beyond arrays to a genuinely recursive data structure, making the base case (an empty or null list) and the per-element processing step especially concrete, and it reinforces recursive versus iterative thinking for lists.

Video 3: Sum an Array Recursively in JavaScript

Learn with Shikaar · 3:08 · 21 views · 1y ago · captions — Watch on YouTube

About this video

A short, focused tutorial that computes the sum of all elements of an array recursively in JavaScript. It should show the function signature, the base case for an exhausted array, and the combination step that adds the current element to the result of the recursive call. The example is small enough to trace by hand, line by line.

Why this video

This is the most direct match to the JavaScript implementation subtopic: it is a compact, classic array-traversal example you can trace through the call stack and adapt to other per-element operations.

How These Videos Support the Learning Outcomes

Together these videos move from concept to code. DeNero's lecture and Wortman's linked-list session make the base case versus recursive case explicit for list structures, supporting MO1, while the JavaScript sum example gives a working implementation of list traversal in the language used in this course (MO2). Tracing the sum or linked-list examples call by call lets you see stack frames accumulate and then resolve as results are combined on the way back up (MO3). Because each video presents a problem you could also solve with a simple loop, they give you material for judging when recursion is the clearer choice and when iteration is cheaper (MO4), and the per-call stack growth they display is exactly the cost that motivates the stack-overflow and efficiency concerns in MO5.

About These Videos

These videos were chosen from YouTube on October 2, 2026. Each has captions; the player turns them on. Videos on YouTube can be changed or removed — if one no longer plays, tell your instructor. If a player does not appear, use its Watch on YouTube link.