Lecture 01: Course Introduction

Welcome to the Spring 2022 edition of COSC 211: Data Structures!!


  1. Motivation
  2. Course Structure and Expectations
  3. Course Overview
  4. First Task: The List ADT
  5. List Implementations

Motivating Example

3 Tasks

Task 1

Sort a list of numbers.

Task 2

Play chess well.

Task 3

Identify pictures of faces.


Consider the following three tasks:

  1. Sort a list of numbers
  2. Play chess well
  3. Identify pictures of faces

Question 1. Which tasks can computers effectively perform?

Question 2. In what ways are the tasks fundamentally different?

Which Tasks Can a Computer Do?

  1. Sort a list of numbers
  2. Play chess well
  3. Identify pictures of faces

How Are These Tasks Different?

  1. Sort a list of numbers
  2. Play chess well
  3. Identify pictures of faces

Task Formalizability

Task 1 (sorting) is formalizable

  • task can be specified symbolically
    • $[a_1, a_2, \ldots, a_n]$ is sorted if $a_1 \leq a_2 \leq \cdots \leq a_n$
  • purported solution can be verified mechanically
  • we can mathematically prove that a procedure will sort any list of numbers
    • must assume basic operations (read/write/compare) are performed faithfully
  • task can be performed efficiently
    • my computer can sort millions of numbers in a second!

Question: Is Face Detection Formalizable?

Is Face Detection Formalizable?

Not really…

  • task is ambiguous
  • can argue about whether or not an image is an image of a face


Computers can detect faces well…

  • e.g. Snapchat lenses
  • face swap

… most of the time

Treachery of Images I

Treachery of Images II

Treachery of Images III

Is “Play Chess Well” Formalizable?

Is “Play Chess Well” Formalizable?

The game of chess is formalizable:

  • specify
    • initial board setup
    • legal moves
    • gameplay (alternate turns)
    • winning/draw configurations
  • computer can verify that a sequence of moves is legal and win/loss/draw

“Play chess well” is ambigious

  • “well” is underspecified

Empirical vs Formal Chess

Play chess well empirically

  • chess program beats every human opponent

Play chess well formally

  • if game reaches a state from which player can force a win/draw, then player will do so
    • exhaustive search possible in principle
    • not practical with current technology

(Compare to tic-tac-toe)

Situation with Chess

  • best AI beats best humans at chess
  • still unknown: can player 1 or player 2 always force a win
    • known: at least one player can force a draw or win

Perfect chess play is possible in principle, not practical with current technology

  • no known efficient procedure to generate “perfect” next move

Tasks, Revisited

  1. Sort a list of numbers
    • solvable in practice
    • formalizable: provable correctness and efficiency
  2. Play chess well
    • solvable in practice
    • formalizable, but formal solutions are impractical
  3. Identify pictures of faces
    • solvable in practice
    • not formalizable, can never guarantee correctness


How certain is “certain?”

  • What tasks must a computer perform correctly & efficiently?

This Course

In this course we study “elementary” tasks and their solutions

  • basic building blocks
  • understand their correctness and efficiency from first principles

Why Study Data Structures?

  • Power tools of programming
  • Foundation for computing systems
  • Generic solutions to common problems
  • Understand efficiency
  • Reason formally about tasks

Course Structure and Expectations


  • Twice Weekly, 80 minute meetings
  • Guided discussion style
    • part lecture
    • part discussion
    • questions always welcomed
  • Lectures focus on conceptual material
  • Assignments express material from lectures in code


  • Weekly homework assignments
    • write and test code
    • apply code to solve a problem
    • answer conceptual questions
  • Occasional quizzes (take-home)
  • 3 Exams (take-home)

Homework collaboration

  • On a conceptual level, yes!
  • Do not share code solutions
    • MOSS

Opportunities for Help

  1. Asking questions:
    • during lecture
    • my office hours
    • TA office hours (drop-in evening sessions, by appointment)
  2. Talk to each other!
  3. Peer tutors


  • All assignments in the Java programming language
  • Course is not intended to teach basic programming
  • Expectation: you are already comfortable with object oriented programming
    • familiar w/ Java or ready to port knowledge of another language

Course Overview

Life Cycle of a Problem

  1. Formally specify task to be performed
  2. Devise a procedure to perform the task
  3. Reason about correctness and performance of the procedure
  4. Implement the procedure in code
  5. Test your implementation for correctness and performance

Levels of Abstraction

  1. Abstract Data Type (ADT)
    • formally specifies the problem to be solved
  2. Data Structure (DS)
    • way of representing the ADT
    • “strategy” for doing task specified by ADT
  3. Implementation
    • code that represents the DS
  4. Execution
    • investigate what program actually does

Topics Covered

  1. Linear data structures and abstract data types (ADTs); program correctness and analysis
  2. tree-based data structures
  3. randomized data structures
  4. graphs, advanced data structures, and applications

Coda: A 4th Task

A “Meta” Task


  • a formal task
  • a program that claims to perform the task


  • does the program perform the task?

Question. Can computers perform this meta-task?


Task: on input n, return 1


int mystery(long n) {
    if (n <= 1) return 1;
    if (n % 2 == 0) return mystery(n / 2);
    return mystery(3 * n + 1);

Amazing fact: it is unknown whether mystery performs the task!


Determine: does a program perform a given task?

Observe. If the task is formally defined, so is the meta-task.

Remarkable Fact. No computer/automated procedure can perform the meta-task!

  • In 1937, Alan Turing proved that it is impossible for a computer to (always) determine whether or not a given program will terminate.