01A Introduction

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 33

COR-IS1702: COMPUTATIONAL THINKING

WEEK 1A: INTRODUCTION

Mai Anh Tien


atmai@smu.edu.sg
https://t.me/Tienmai

Useful URLs:
• Telegram Grp for G3 (for announcements): https://t.me/+QjSB5RYNtNk3NTk1
• Padlet for collecting your answers: https://padlet.com/atmai/vl89qwo8wyuu39jl
• eLearn for G3: https://elearn.smu.edu.sg/d2l/home/344463
• eLearn for all CT sections (for exams): https://elearn.smu.edu.sg/d2l/home/348312
2022/23 Term 2
Need to know some "high school Maths"

• Basic algebra
• Logarithms
• Sum of series in AP/GP
Road Map
Algorithm Design and Analysis
✦ Week 1: Introduction, Counting, Programming
✦ Week 2: Programming
Here now
✦ Week 3: Complexity
✦ Week 4: Iteration, Decomposition
✦ Week 5: Recursion

Fundamental Data Structures


(Weeks 6 - 10)

Computational Intractability & Heuristic Reasoning


(Weeks 11 - 13)
Teaching Team for CT (2022/23 T2)
G1 G2 G3 G4 G5 G6 G7 G21 G22
Mon 8:15 Tue 15:30 Mon 3:30 Wed 8:15 Thu 12:00 Fri 8:15 Mon 8:15 Thu 19:00 Fri 12:00
SCIS1 SR 3.1 SCIS1 SR 3.4 SCIS1 SR 2.2 SCIS1 SR 3.1 SOE SR 2.1 SCIS1 SR 3.1 SOE SR 3.9 SCIS1 SR 3.4 SCIS1 SR 3.1

Vivien SOON ZHANG Ce NGUYEN Thi Asankhaya S


MOK Heng CAO Yixin MAI Anh Tie en Duc
n HARMA
Ngee
Faculty

CHAN Enqi Alden NG HUANG Beif Allyne ZHA SAMUEL Jade GOH Benjamin G
Elton TAY Ryan POY OH
ei NG
TA

LIU Huiwen
Senior TA
(Project)
Assessment (2022/23 T2)
• Exams (60%)​ Important: Reserve this slot on your calendar NOW: 
– Midterm Exam (20%)​ 24th Feb 2023 (Wk 7 Friday), 6-7:30pm

– Final Exam (40%)​


• Assignments (20%) 20th Apr 2023, 1-3 pm

– Group Project 20% weeks 10-13​


• Class Participation 20%
– section-specific​, may include quizzes
Assessment: Class Participation (20%)
For Mok's sections:
In-Class Activities: Self-check Quizzes
- Relevant
- week 3 onwards
questions/contribute
- used to determine if you have
meaningfully in discussions
understood the lecture videos
- Evidence of attempts
- to be attempted before each lesson
- Answers to tutorial questions
starts
- attempt as many times as u wish
(preferably until u get a perfect score)

Class Part
Attendance & Punctuality: Score
- Automatic fail for 3 absences
without valid reasons
weekly Kahoot! Quizzes:
- taken sometime during the class,
based on previous & current week's
Homework Labs: content
- 5 labs in all - good revision opportunity
- correct attempts
Admin Issues

• Announcements/reminders:
– Will be sent via Telegram group for this section
• Voice out problems ASAP and seek help
• Walk-in consultation
– Ask for my availabilities
– SCIS1, level 5. Room: 5014
• Attending another section’s class:
– Not encouraged. Occasionally allowed with good reason
– Let me know ASAP if necessary
Make-Up Lesson for Week 3 (G1)
• Week 3 Mon (23 Jan 2023) is a public holiday. 
• From Registrar’s Office:
Affect our Week 3 class

• Makeup for this section scheduled on 28 Jan (Sat) 3:30pm, ZOOM LESSON
Mid-Term Exam
CT merged section: https://elearn.smu.edu.sg/d2l/home/348312

• 24th Feb 2023 (Fri, Week 7) Exam venue:


• Time: 6-7:30 pm
• Will be conducted as a closed-
book eLearn quiz (lockdown
browser) with 1 cheat-sheet
allowed.
• Cheat-sheet is double-sided A4-
sized paper.
• Scope: everything up till, &
including week 6 material
(stacks/queues)
Pedagogy for this Section
• From week 3 onwards, this section will be adopting the "Flipped Classroom"
– What is this all about?  https://ink.library.smu.edu.sg/sis_research/2363/

Comparing the traditional classroom with the flipped classroom. Diagram adapted from Mok (2014)
…Pedagogy

• Some rules for this to work:


– You must prepare for each class by watching all
the assigned video lectures + attempt all the self-
check quizzes (on eLearn)
– Attend a consultation session if you need help
understanding the lectures
– The assumption is that everyone comes to class
with a common knowledge baseline
Academic Integrity
• SMU’s code of academic integrity:
https://oasis.smu.edu.sg/Pages/DOS-WKLSWC/UCSC.aspx (Click on "Code of Academic Integrity")
• Behave ethically and honorably
• No undesirable activities
– Cheating, plagiarism, fabrication, misrepresentation of academic records, facilitating academic
dishonesty, unfair advantage
• For marked assignments (projects):
– Always acknowledge discussions and/or contributions of others
– Do not post solutions or partial solutions (including any discussion forum or public code
repositories such as GitHub)
– However, you are permitted to discuss general ideas and problem-solving approaches, and
not specific answers.
• When in doubt, consult the instructors
Teaching Style
• Integrity is very important to me
– Getting a zero is better than cheating
• I am concerned about the learning experience
– yes, we will focus on answering exam questions nearer to the exams
• This is a very interesting course
– focus on higher-order thinking processes
– may be challenging, but let's do it together!
• It's good to have your work criticized
– It's not personal
• Get help if you need help
– but do your homework first
– supplementary programming lessons
– help others if u can
Problem Solving

• Problem-solving methodology that we will learn in the


course:
– Formulating a real-world problem in computational terms
– Characterizing the difficulty or complexity of the problem
– Finding ways (algorithms) to solve the problem efficiently

• By the end of the course, you are expected to be able to carry


out a similar problem-solving methodology for this and other
problems
What is an Algorithm
• Definition:
– “An algorithm is a finite sequence of precise instructions for
performing a computation or for solving a problem”
~ From Rosen chapter 3 (p.191)

– Algorithms must have the following properties:


• Input and output
• Definiteness: each step must be defined precisely
• Correctness: must produce the correct output values for each set of input values
• Finiteness: will not go on forever
• Generality: applicable for all problems of the desired form, not just for a
particular set of input values
~ From Rosen chapter 3 (p.193)
"Fast hardware does not make good algorithms
unnecessary. On the contrary, faster hardware
magnifies the superiority of better algorithms."
~ From "Foundations of Computer Science" lecture notes
by A Prorok & A Madhavapeddy (Cambridge University)
This Course
• Introduction to:
– Algorithms
– Data Structures
– Coding in Python
• We will:
– Study a few well-known algorithms for certain problems
– Given multiple algorithms, compare them in terms of time
complexity to determine which is “better”
– Given a problem, come up with an algorithm to solve it
– Code & execute your algorithm in Python
Course Emphasis
• This course is NOT:
– A pure Comp Science course on data structures, algorithms, or
discrete mathematics
– A programming course
• What we emphasize:
– Design
– Complexity
– Efficiency and scalability
• What we will learn:
– Problem formulation
– Problem solving methods
– Real-world applications
I enjoyed CT a lot… I enjoyed the topics &
the assignments… very fun & interesting,
allowed me to think a lot more on how I
want to code. I think it’s very interesting
because it goes past just coding, but really
thinking about how you want to make your
code fast and efficient… very applicable for
the real world when dealing with a large
amount of information.

Jazryl Quek
IS major, Year 4
Interned as Algorithm Engineer at Shopee
Example of a Problem
• You are the emcee of a "couple matching" game
show
– There are 8 participants: 4 males and 4 females
– After a series of self introductions, each M ranks each F from 1
(most preferred) to 4 (least preferred). Each woman does the same.
• Objective:
– You need to match them to form 4 "stable" couples
– All matches are stable if, for any one particular couple (M x-Fx),
• there is no F whom Mx prefers (over Fx), and who prefers Mx (over her current
partner)
• There is no M whom Fx prefers (over Mx), and who prefers Fx (over his current
partner)
• In other words, no 2 people of opposite sex who would both rather have each
other than their current partners
Consider the following solutions – are they stable? If not, give an
example of a couple which will elope:
Solution (i): (M1-F1), (M2-F3), (M3-F2), (M4-F4)
Solution (ii): (M1-F3), (M2-F1), (M3-F4), (M4-F2)
Solution (i): (M1-F1), (M2-F3), (M3-F2), (M4-F4)
Solution (ii): (M1-F3), (M2-F1), (M3-F4), (M4-F2)

(i) Is unstable. F1 is matched with M1. But


F1 prefers M2. M2 is matched with F3,
and M2 would prefer F1.
(ii) Is stable
Gale-Shapley Deferred-Choice Algorithm
1. Given: n males and n females.

2. Each unmatched male proposes to his highest ranked female whom he hasn’t proposed to
previously.

3. If the female is not matched yet, she automatically accepts.

4. If she is already matched, she picks her more preferred male and rejects one of them.

5. Repeat steps 2-4 if there is still at least one male who is unmatched. When every man is
matched, the problem is solved.

(The order of which male proposes first is not important.)


Gale-Shapley Deferred-Choice Algorithm
Each person can be in 1 of 2 states at any one time: matched or free
All males and females are initially free

While there exists an unmatched male m who has not proposed to all females:
Let f be the highest ranked female to whom m has not proposed

If f is free:
(m, f) are matched
Else it means that some other pair (m', f) already exists:
If f prefers m to m'
(m, f) are matched
m' becomes free
Else
# do nothing!
(m', f) remain matched
m remains free
End
End
End

• For N males and N females, at most N2 number of proposals


– E.g. if N = 22, there are up to 484 proposals (much more efficient than billions)
• Guarantees: Everyone gets married, and all marriages are stable
Source:
https://www.cs.princeton.edu/~w
ayne/kleinberg-tardos/pdf/01Stab
leMatching.pdf

• Gale-Shapley algorithm and kidney donations. Watch:


https://www.youtube.com/watch?v=GVCBI_DepDE
Problem Solving

• Problem-solving methodology that we will learn in the


course:
– Formulating a real-world problem in computational terms
– Characterizing the difficulty or complexity of the problem
– Finding ways (algorithms) to solve the problem efficiently

• By the end of the course, you are expected to be able to carry


out a similar problem-solving methodology for this and other
problems
Things You Will Learn

How to design algorithms to solve problems?

How to organize data to solve problems more efficiently?

How to deal with complex problems?


Course Outline

How to design algorithms to solve problems?

Algorithm Design and Analysis


(Weeks 1 – 5)

How to organize data to solve problems more efficiently?

Fundamental Data Structures


(Weeks 6 – 9)
How to deal with complex problems?

Computational Intractability and Heuristic Reasoning


(Weeks 10 – 13)
Course Outline

Algorithm Design and Analysis

• Week 1: Introduction, Counting, Programming

• Week 2: Programming

• Week 3: Complexity

• Week 4: Iteration & Decomposition

• Week 5: Recursion
Course Outline

Fundamental Data Structures

• Week 6: Linear Data Structures (Stacks, Queues)

• Week 7: Hierarchical Data Structure (Binary Trees)

• Week 8: Mid-term Break

• Week 9: Networked Data Structure (Graphs)


Course Outline

Computational Intractability and Heuristic Reasoning

• Week 10: Graph Algorithms

• Week 11: Heuristic Reasoning

• Week 12: Project Week (no class, but project is due)

• Week 13: Limits of Computation + Review


References
• Explorations in Computing by John S. Conery (JSC)
– Publisher: Taylor & Francis CRC Press
– Homepage: http://ix.cs.uoregon.edu/~conery/eic/python/index.html
– PDF: ftp://ftp.cs.uoregon.edu/pub/conery/freeman/EiC.Mar.27.pdf

• Discrete Mathematics and its Applications


– Authors: Kenneth H. Rosen (KHR)
– Publisher: McGraw-Hill, 2012
– Edition: 7th
– Chapter 6 on Counting (provided on eLearn)

• Supplementary Handout on Fundamental Data Structures


– Provided by Instructors on eLearn (Handout)
Summary
• Computational thinking is for everyone

• Elements of computational thinking include:


– Abstract and algorithmic thinking.
– Iteration, Decomposition, Complexity, Heuristic reasoning.

• Course emphasizes:
– Conceptual thinking and reasoning, not programming
– Formulating a problem in terms of how it can be computed
– Characterizing the complexity of problems and solutions
– Designing solutions with simplicity and efficiency in mind

• We are here to support your learning journey

You might also like