DSA1 | Week 1

Data Structures: Just Some Structured Data

Logistics

Classes
10:05 - 11:00 AM on Tuesdays and Wednesdays at (1/103)

 

Lab
16:05 – 18:00 Wednesdays at (7/108 and 7/109)

 

Office Hours
Open door policy (i.e, catch me if you can at AB 4/305)

Logistics

Materials
Slides and (usually) notes → Moodle

Classes will not be recorded.
 

Lab & Theory Assignments
repl.it & Moodle (autograded*)

 

Lab & Theory Quizzes

repl.it & offline (pen and paper)
 

Announcements & Discussions

Email & Moodle

Grading policy

Weekly Assignments on Moodle: 2 * [top 10] = 20
Lab Assignments on repl.it: 1 * [top 10] = 10
Class participation via Mentimeter: 0.5 points per class capped at 10

Midsem Exam: 10 (lab) + 10 (theory) = 20
Final Exam: 10 (lab) + 15 (theory) = 25

 

Four quizzes (two theory, two lab & top 3 outcomes counted): 3 * 5 = 15

Timelines

Lab Assignments are due by noon on Thursdays.

Weekly assignments will be released by noon on Thursdays and are due by midnight on Sundays.

Self-assessment (ungraded) quiz: 10th August

Theory Quiz 1: 06 Sep 2022

Lab Quiz 1: 07 Sep 2022

Theory Quiz 2: 25 Oct 2022

Lab Quiz 2: 26 Oct 2022

The last lab before the exam weeks will be an exam lab.

TAs

  1. Progyan Das

  2. Nipun Mahajan

  3. Harshil Mittal

  4. Yash More

  5. Saraswati Nanoti

Labs & Theory

TOPICS OVerview

Week 1. Introduction

Week 2. Familiarize yourself with C & self-assessment quiz

Weeks 3 & 4: BFS/DFS + stacks/queues

Weeks 5 & 6: Spanning Trees & Disjoint Set Union

Weeks 7 & 8: Shortest Paths & Priority Queues

Weeks 9, 10 & 11: Trees, Tries, Suffix Trees/Arrays

Weeks 12 & 13: Sorting and Searching

Weeks 14 & 15: Balanced BSTs

Data Structures

Structured Data

You may remember some so-called primitive data types from your programming courses.

Booleans (true/false)

Numbers (integers, floating point, etc.)

Characters and Strings

Etc.

You may also remember combining and manipulating these values for getting things done.

Expressions

Conditionals

Loops

Etc.

Structured Data

We are going to be doing more of this!

Start out with goals: things you want to do.

Think through the mechanics what you want to do.

Work out what would be the most useful way to store information to aid the mechanics.

Structured Data

We are going to be doing more of this!

Goal: Ace this class

Think through the mechanics what you want to do.

Work out what would be the most useful way to store information to aid the mechanics.

Structured Data

We are going to be doing more of this!

Goal: Ace this class

Study the night of the exam.

Work out what would be the most useful way to store information to aid the mechanics.

Structured Data

We are going to be doing more of this!

Goal: Ace this class

Study the night of the exam.

Maintain notes that will help you digest several weeks of material in a few hours.

Structured Data

We are going to be doing more of this!

Goal: Enjoy college life, YOLO

Study the night of the exam.

Maintain notes that will help you digest several weeks of material in a few hours.

Structured Data

We are going to be doing more of this!

Goal: Enjoy college life, YOLO

Never look at notes 👀

Maintain notes that will help you digest several weeks of material in a few hours.

Structured Data

We are going to be doing more of this!

Goal: Enjoy college life, YOLO

Never look at notes 👀

[Nothing to do.]

Structured Data

We are going to be doing more of this!

Goal: Enjoy college life, YOLO

Never look at notes 👀

[Nothing to do.]

Structured Data

We are going to be doing more of this!

Goal: Enjoy college life, YOLO

Never look at notes 👀

[Nothing to do.]

Structured Data

How you store data depends on what you want to do with it!

Clothes in your cupboard

Structured Data

Suppose you want to represent the polynomial

\(x^2 - 7x + 12\)

Polynomials

How will you talk to your program

about this object?

I pick a number from 1-10.

The Game of 100

You pick a number from the next 10 numbers.

We go on like this until someone reaches 100.

First player to reach 100 wins.

Suppose you have 52 cards.

Storing a hand from a deck

You want to maintain a hand of five cards.

Given a card you want to know if it is in the hand.

You want to be able to add/remove/replace cards in the hand.

A Rubik Cube has six sides, and 9 squares on each side.

Solving a Cube

8 corner cubes, 12 edge cubes, 6 more cubes:
one in the center of each face,
and 1 cube (which doesn't actually exist

Given a shuffled state, you want to solve the cube.

The Game of Trust

my_points = 0
user_points = 0

user_move_1 = input("Input 1 for Cooperate and 0 for Cheat.")

#Sanity check input:
if(user_move_1 != 1 and user_move_1 != 0):
	express disappointment and abort

##My first move is to cooperate:
my_points += -1
user_points += 3

if(user_move_1):
	my_points += 3
	user_points -= 1

Majority Mover

This player looks at your entire game history, and:

  • cooperates if you have cooperated more than you have cheated,

  • cheats if you have cheated more than you have cooperated,

  • and acts randomly otherwise.

Random Player

This one chooses a number K between 1 and N uniformly at random,

(where N is the number of rounds played so far)

and mimics the other player's Kth move.

Some more logistics

Notes: https://dsanotes.netlify.app/

Email: neeldhara.m@iitgn.ac.in

Slides: https://slides.com/neeldhara/dsa1-wXX

XX = 01,02,...,15

Please send me a note if you have NOT received a notification from Moodle.

Sets & Sequential Data

The atomic types have served us well,

but it is now time to build on them.

Say you are a real estate agent &

need to reserve some houses in a new

apartment complex.

The builder can block any contiguous chunk

of N houses for you.

Your list of clients may evolve over time.

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

⛔️

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

⛔️

👇

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

🔑

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

🔑

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

🔑

🔑

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

🔑

🔑

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

🔑

🔑

🔑

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

🔑

🔑

🔑

Say you are a real estate agent &

need to reserve some houses in a new apartment complex.

🔑

🔑

🔑

🔑

Representing Graphs

DSA1 | Week 1

By Neeldhara Misra

DSA1 | Week 1

Data Structures: Just some Structured Data

  • 1,089