# Lecture 01: Course Introduction

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

## Overview

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

# Motivating Example

Sort a list of numbers.

Play chess well.

Identify pictures of faces.

## Questions

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 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!

## Is Face Detection Formalizable?

Not really…

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

## Nonetheless

Computers can detect faces well…

• e.g. Snapchat lenses
• face swap

… most of the time

# 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

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

## Questions

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

# Course Structure and Expectations

## Meetings

• 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

## Coursework

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

Homework collaboration

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

## Opportunities for Help

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

## Programming

• 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

• formally specifies the problem to be solved
2. Data Structure (DS)
• way of representing the 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

Given:

• a program that claims to perform the task

Determine:

• does the program perform the task?

Question. Can computers perform this meta-task?

## Example

Task: on input n, return 1

Program:

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!