SlideShare a Scribd company logo
1 of 34
ALGORITHMS, COMPUTER GRAPHICS,
AND MATHEMATICS FOR GAME
DEVELOPERS & COMPUTER
SCIENTISTS
Class[1]: Introduction to Algorithms, Big-O Notation
Presented by
Dr. Saajid Abuluaih
- May 2021 -
Algorithms, Computer Graphics, and Mathematics
for Game Developers and Computer Scientists
© 2021 arche1.co.jp | jaist.ac.jp
All rights reserved.
2
Agenda
One-Bite Wisdom
On Algorithms
Simple Algorithms
𝑖
Big O Notation
The Class Structure
On Pseudocode
Introduction to the Course
𝑔
𝑛
“The future is not just unwritten - it is unsearched”
-Bruce Sterling
Algorithms, Computer Graphics, and Mathematics
for Game Developers and Computer Scientists
© 2021 arche1.co.jp | jaist.ac.jp
All rights reserved.
3
BEFORE WE START,
I GOT ONE DISCLAIMER
TO ANNOUNCE
This course is not designed for totally beginners …
You need to have some basic knowledge on what Computer Science is all about
HOWEVER,
If you feel like you can’t understand something that you think it is important
Please let me know
© 2021 arche1.co.jp | jaist.ac.jp
All rights reserved.
P A G E 4
One-Bite Wisdom
Monty Hall Problem
5
• Let’s Make a Deal was a very famous game show back in the
70’s & 80’s
• Monty Hall is the host of the show
• There are three doors, one of them has a nice prize, and the
other two have gags (Usually a farm animal)
• You chose a door and then the host will open “Empty” another
• The host then will aske you whether to stick with or switch the
door you picked
MONTY HALL PROBLEM,
THE THREE DOORS GAME
References:
Monty Hall Problem - Wikipedia
Monty Hall Problem - Numberphile - YouTube
Monty Hall show - Let’s make a deal
Is there a good strategy to use in this case?
6
• Mathematicians say: in order to increase your chances to win
the nice prize, you must switch
MONTY HALL PROBLEM,
THE THREE DOORS GAME
References:
Monty Hall Problem - Wikipedia
Monty Hall Problem - Numberphile - YouTube
Monty Hall show - Let’s make a deal
This strategy doesn’t guarantee that you will. But it will increase
your chances 13
1/3 2/3
1/3 2/3
7
Mathematicians say: in order to increase your chances of winning the nice prize, you must switch.
MONTY HALL PROBLEM,
THE THREE DOORS GAME
References:
Monty Hall Problem - Wikipedia
Monty Hall Problem - Numberphile - YouTube
To explain it even better, consider the following scenario. You have six doors. You chose one. The host
open 4 empty doors. Will you prefer then to stick with your early door selection or will you switch.
1/6 5/6
Algorithms, Computer Graphics, and Mathematics
for Game Developers and Computer Scientists
© 2021 arche1.co.jp | jaist.ac.jp
All rights reserved.
WHAT THAT HAS TO DO WITH
OUR CLASS FOR TODAY?
NOTHING
it has nothing to do with today’s class
© 2021 arche1.co.jp | jaist.ac.jp
All rights reserved.
P A G E 9
Introduction
About the Course
This is a course in algorithms and 3D computer graphics that enables enrolled students to learn the theory
of computer graphics along with algorithms implementation for solving real-life problems, specifically that
relates to mathematics and physics of motion in 3D spaces. Ultimately, the course intends to deliver
knowledge that is sufficient to construct an interactive 3D application for simulating the movement of a
controllable entity.
The main topics this course intends to cove is:
10
INTRODUCTION,
WHAT THIS COURSE IS ALL ABOUT
- Algorithms:
- Big-O notation
- Definition, characteristics, usage,
design, optimization
- Programing useful algorithms for
popular problems
- Computer Graphic with Three.js:
- Scene creation:
- Light, camera
- Renderer, animation loop
- 3D Object creation:
- Geometry
- Material
- Mesh
- Mathematica and Physics
- Locations in 2D & 3D spaces
- Raycasting in 3D environments
- Vectors:
- Vector normal form
- Dot product
- Cross Product
- Intersections
- Matrices and Transformations
- Newtons Laws of Motions
Bonus:
- Programing languages: C#, JavaScript, TS
© 2021 arche1.co.jp | jaist.ac.jp
All rights reserved.
P A G E 11
The Class Structure
How the class lectures are going
to look like
The structure of delivering classes:
• One-bite wisdom 15 minutes (Knowledge Sharing Session)
• Algorithms (15 minutes)
• Lecture (45min ~ an hour)
• Quiz
• Homework
• Groups’ discussion 30 minutes (we need four groups for)
12
THE CLASS STRUCTURE,
WHAT THIS COURSE IS ALL ABOUT
© 2021 arche1.co.jp | jaist.ac.jp
All rights reserved.
P A G E 13
ON ALGORITHMS
WHAT WE WILL LEARN
ABOUT ALGORITHMS
Definition:
An algorithm is an unambiguous finite sequence of well-defined step-by-step computer-implementable
instructions, that takes data as an input instance (of a given problem) and produces an output that can be
called a solution to the problem.
But what is a problem:
A problem is a set of instances that all share the same characteristic
What is not an Algorithm:
We don’t call the implementation of an algorithm an algorithm. We call it “code”.
What makes an algorithm better than the other:
Long story short, “the performance” … the smaller number of steps needed to produce the solution the
better the algorithm is.
However!
Although, any type of instructions that handle inputs are considered “algorithms”; algorithmic thinking
always involve loops and conditions.
14
ON ALGORITHMS,
WHAT IS ALGORITHM?
References:
Algorithm
What exactly is an algorithm? Algorithms explained | BBC (Ideas)
A flowchart is the graphical or pictorial representation
of an algorithm with the help of different symbols,
shapes, and arrows to demonstrate a process or a
program.
15
ON ALGORITHMS,
DESIGNING AN ALGORITHM
References:
Explain Algorithm and Flowchart with Examples
Example 1: Print 1 to 20:
Algorithm:
• Step 1: Initialize X as 0,
• Step 2: Increment X by 1,
• Step 3: Print X,
• Step 4: If X is less than 20 then go back to
step 2.
Iterations VS Recursion
The basic idea of using recursion and iteration is to repeat a sequence of instructions. Recursion is a
function call in which the function being called is the same as the one initiating the call, whereas iteration
occurs when a loop is continuously executed until a given condition is met.
16
On Algorithms,
Algorithms implementation
function Function1 (num) {
if (Base) {
return num;
}
return num + Function1(num - 1);
}
function Function1(num) {
var value = 1;
for (var i= num; i>=0; i--) {
value += i;
}
return total;
}
References:
Programming Loops vs Recursion - Computerphile
© 2021 arche1.co.jp | jaist.ac.jp
All rights reserved.
P A G E 17
Simple Algorithms
Let’s Brush our Coding Skills
Factorial of a positive integer 𝑛𝑢𝑚 is product of all 𝑣𝑎𝑙𝑢𝑒𝑠 from 𝑛𝑢𝑚 to 1. For example, the factorial of
𝑛𝑢𝑚 = 5 is 5 ∗ 4 ∗ 3 ∗ 2 ∗ 1 = 120.
18
A SIMPLE ALGORITHM,
CALCULATING THE FACTORIAL VALUE OF A
POSITIVE INTEGER
function factorial(num) {
if (num === 1) {
return 1;
}
return num * factorial(num - 1);
}
function factorial(num) {
var total = 1;
for (var i= num; i>=1; i--) {
total = total * i;
}
return total;
}
© 2021 arche1.co.jp | jaist.ac.jp
All rights reserved.
P A G E 19
Quiz [1]
Answer This Question … IF YOU CAN
• Write the implementation of the following flowchart using your favorite
coding language. [Homework]
• What does the algorithm in the flowchart do?
• What is the output of the algorithm if N was 15?
20
Quiz [1]
What is the output of the following algorithm?
Start
Total = 0
i = 0
Read N
Is count < N
Print N
Total = Total + N
i = i + 1
End
© 2021 arche1.co.jp | jaist.ac.jp
All rights reserved.
P A G E 21
Big O Notation
Let’s Dive a Bit Into the Fundamentals
It is a mathematical notation that describes the limiting behavior of a function when the argument tends
towards a particular value or infinity. In another way, it shows how the code slows as the data grows (Big-
O notation used to measure space as well).
22
BIG-O NOTATION
What is Big-O?
References:
Big O: How Code Slows as Data Grows
Big O notation
Algorithms Notes for Professionals
We can not use the time to measure the performance of an algorithm. So, what to doe?
• Rather than counting seconds, we count the number of steps (operations) that we need to execute
every time to generate the outcome.
• Think of this simple algorithm that does nothing other than printout “hello world” how many steps
we need to execute?
23
BIG-O NOTATION
TIMING OUR ALGORITHMS
References:
Big O: How Code Slows as Data Grows
Algorithms Notes for Professionals
• It is going to be 𝑂 1 .
• Big-O Notation is a way to formalize a fuzzy counting
What is the time complexity for the following algorithms:
24
BIG-O NOTATION
LET’S EXAMINE the number of steps needed in
algorithm THIS FUNCTION [P1]
References:
Big O: How Code Slows as Data Grows
Algorithms Notes for Professionals
How about his one:
It is liner, 𝑂(𝑁)
It is liner, 𝑂(1)
What is the time complexity for the following function:
25
BIG-O NOTATION
LET’S EXAMINE the number of steps needed in
algorithm THIS FUNCTION [P2]
References:
Big O: How Code Slows as Data Grows
Algorithms Notes for Professionals
What do you think this is?
Quadratic 𝑂(𝑁2
)
It is 𝑂(log(𝑁))
We can not use the time to measure the performance of an algorithm. So what to doe?
• 𝑂(1): Constant time
• 𝑂(log(𝑁)): Logarithmic running time
• 𝑂(𝑁): Linear running time
• 𝑂(𝑁2
): Quadratic. Polynomials running time.
• 𝑂(2𝑁
): Exponential running time
• 𝑂(! 𝑁): Factorial running time
26
BIG-O NOTATION
BIG-O COMPLEXITY MOST COMMON PATTERNS
References:
Big O: How Code Slows as Data Grows
Algorithms Notes for Professionals
• How the code slows as the data grows (Big-O notation used to )
• What does the algorithm do?
• What is the output of the
• algorithm if N was 15?
27
Big-O Notation
What is the output of the following algorithm?
References:
Algorithms Notes for Professionals
Big O Cheatsheet
© 2021 arche1.co.jp | jaist.ac.jp
All rights reserved.
P A G E 28
Quiz [2]
Answer This Question … IF YOU CAN
• What is the Big-O notation for the following algorithm?
• Is there anyway to enhance it?
29
Quiz [1]
What is the time complexity of the following?
Start
Total = 0
i = 0
Read N
Is count < N
Print N
Total = Total + N
i = i + 1
End
© 2021 arche1.co.jp | jaist.ac.jp
All rights reserved.
P A G E 30
Pseudocode
Write A Code That Can Be Understood By
Human
31
Definition:
Pseudocode is an artificial and informal language that helps programmers develop algorithms. It is a "text-
based" step-by-step design tool.
Basic common pseudocode:
- Assignment
a ← expression
- Arithmetic operators and numeric procedures
a + b, a – b, a * b, a / b
- Relational and Boolean operators
a = b, a ≠ b, a > b, a < b, a ≥ b, a ≤ b
- Condition
Evaluates to true if condition is true; otherwise evaluates to false.
Evaluates to true if both condition1 and condition2 are true or condition3 is true;
- Iterations
Repeat n Times { < Your logic here > }
Repeat Until (condition) { < Your logic here > }
- Procedures
Procedure name (parameter1, parameter2, ...) { < Your logic here > Return (expression) }
On Algorithms,
Pseudocode
References:
PSEUDOCODE GUIDE
© 2021 arche1.co.jp | jaist.ac.jp
All rights reserved.
P A G E 32
HOMEWORK
Let’s Dive a Bit into Fundamentals
Find any simple problem, and design two different algorithms that lead to the same result:
• Use the flowcharts you learnt about today to present your algorithms
• What is the time complexity (Big-O notation) of the algorithms that you are going to design
• Write the pseudocode of your algorithms
Read Chapter 3 of [Algorithms: Notes for Professional] and:
• Summarize Big-Theta notation
• Summarize Big-Omega Notation
33
DEADLINE 27/5 3/6,
HOMEWORK
Algorithms, Computer Graphics, and Mathematics
for Game Developers and Computer Scientists
© 2021 arche1.co.jp | jaist.ac.jp
All rights reserved.
THANKS FOR YOUR
ATTENTION

More Related Content

What's hot

CS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingCS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingMark Kilgard
 
Image proceesing with matlab
Image proceesing with matlabImage proceesing with matlab
Image proceesing with matlabAshutosh Shahi
 
Computer graphics file
Computer graphics fileComputer graphics file
Computer graphics fileaman1001
 
Basics of Image Processing using MATLAB
Basics of Image Processing using MATLABBasics of Image Processing using MATLAB
Basics of Image Processing using MATLABvkn13
 
Prim algorithm for the implementation of random mazes in videogames
Prim algorithm for the  implementation of random mazes  in videogamesPrim algorithm for the  implementation of random mazes  in videogames
Prim algorithm for the implementation of random mazes in videogamesFélix Santos
 
Computer Graphics Concepts
Computer Graphics ConceptsComputer Graphics Concepts
Computer Graphics ConceptsSHAKOOR AB
 
Digital Image Processing - MATLAB Notes - Akshansh
Digital Image Processing - MATLAB Notes - AkshanshDigital Image Processing - MATLAB Notes - Akshansh
Digital Image Processing - MATLAB Notes - AkshanshAkshansh Chaudhary
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlabAman Gupta
 
CS 354 Pixel Updating
CS 354 Pixel UpdatingCS 354 Pixel Updating
CS 354 Pixel UpdatingMark Kilgard
 
Unit-1 basics of computer graphics
Unit-1 basics of computer graphicsUnit-1 basics of computer graphics
Unit-1 basics of computer graphicsAmol Gaikwad
 
Deep single view 3 d object reconstruction with visual hull
Deep single view 3 d object reconstruction with visual hullDeep single view 3 d object reconstruction with visual hull
Deep single view 3 d object reconstruction with visual hullHanqing Wang
 
Shadow Volumes on Programmable Graphics Hardware
Shadow Volumes on Programmable Graphics HardwareShadow Volumes on Programmable Graphics Hardware
Shadow Volumes on Programmable Graphics Hardwarestefan_b
 
Fundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLABFundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLABAli Ghanbarzadeh
 
Matlab Feature Extraction Using Segmentation And Edge Detection
Matlab Feature Extraction Using Segmentation And Edge DetectionMatlab Feature Extraction Using Segmentation And Edge Detection
Matlab Feature Extraction Using Segmentation And Edge DetectionDataminingTools Inc
 
CS 354 Object Viewing and Representation
CS 354 Object Viewing and RepresentationCS 354 Object Viewing and Representation
CS 354 Object Viewing and RepresentationMark Kilgard
 

What's hot (20)

CS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingCS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and Culling
 
Image Processing Using MATLAB
Image Processing Using MATLABImage Processing Using MATLAB
Image Processing Using MATLAB
 
Image proceesing with matlab
Image proceesing with matlabImage proceesing with matlab
Image proceesing with matlab
 
Computer graphics file
Computer graphics fileComputer graphics file
Computer graphics file
 
Basics of Image Processing using MATLAB
Basics of Image Processing using MATLABBasics of Image Processing using MATLAB
Basics of Image Processing using MATLAB
 
Prim algorithm for the implementation of random mazes in videogames
Prim algorithm for the  implementation of random mazes  in videogamesPrim algorithm for the  implementation of random mazes  in videogames
Prim algorithm for the implementation of random mazes in videogames
 
Graphics Programming in C
Graphics Programming in CGraphics Programming in C
Graphics Programming in C
 
Unit 11. Graphics
Unit 11. GraphicsUnit 11. Graphics
Unit 11. Graphics
 
Ec section
Ec section Ec section
Ec section
 
Computer Graphics Concepts
Computer Graphics ConceptsComputer Graphics Concepts
Computer Graphics Concepts
 
Digital Image Processing - MATLAB Notes - Akshansh
Digital Image Processing - MATLAB Notes - AkshanshDigital Image Processing - MATLAB Notes - Akshansh
Digital Image Processing - MATLAB Notes - Akshansh
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlab
 
CS 354 Pixel Updating
CS 354 Pixel UpdatingCS 354 Pixel Updating
CS 354 Pixel Updating
 
Unit-1 basics of computer graphics
Unit-1 basics of computer graphicsUnit-1 basics of computer graphics
Unit-1 basics of computer graphics
 
Deep single view 3 d object reconstruction with visual hull
Deep single view 3 d object reconstruction with visual hullDeep single view 3 d object reconstruction with visual hull
Deep single view 3 d object reconstruction with visual hull
 
MATLAB & Image Processing
MATLAB & Image ProcessingMATLAB & Image Processing
MATLAB & Image Processing
 
Shadow Volumes on Programmable Graphics Hardware
Shadow Volumes on Programmable Graphics HardwareShadow Volumes on Programmable Graphics Hardware
Shadow Volumes on Programmable Graphics Hardware
 
Fundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLABFundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLAB
 
Matlab Feature Extraction Using Segmentation And Edge Detection
Matlab Feature Extraction Using Segmentation And Edge DetectionMatlab Feature Extraction Using Segmentation And Edge Detection
Matlab Feature Extraction Using Segmentation And Edge Detection
 
CS 354 Object Viewing and Representation
CS 354 Object Viewing and RepresentationCS 354 Object Viewing and Representation
CS 354 Object Viewing and Representation
 

Similar to Class[1][23ed may] [algorithms]

Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm AnalysisMary Margarat
 
DAA-Unit1.pptx
DAA-Unit1.pptxDAA-Unit1.pptx
DAA-Unit1.pptxNishaS88
 
Data Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm AnalysisData Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm AnalysisFerdin Joe John Joseph PhD
 
Blueprints: Introduction to Python programming
Blueprints: Introduction to Python programmingBlueprints: Introduction to Python programming
Blueprints: Introduction to Python programmingBhalaji Nagarajan
 
Meetup 29042015
Meetup 29042015Meetup 29042015
Meetup 29042015lbishal
 
Deep learning from scratch
Deep learning from scratch Deep learning from scratch
Deep learning from scratch Eran Shlomo
 
Algorithm n problem solving x
Algorithm n problem solving xAlgorithm n problem solving x
Algorithm n problem solving xlaraibali21
 
MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...
MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...
MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...Dylan-Wu
 
Why computer programming
Why computer programmingWhy computer programming
Why computer programmingTUOS-Sam
 
complexity analysis.pdf
complexity analysis.pdfcomplexity analysis.pdf
complexity analysis.pdfpasinduneshan
 

Similar to Class[1][23ed may] [algorithms] (20)

Flow charts week 5 2020 2021
Flow charts week 5 2020  2021Flow charts week 5 2020  2021
Flow charts week 5 2020 2021
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm Analysis
 
Flowcharting week 5 2019 2020
Flowcharting week 5  2019  2020Flowcharting week 5  2019  2020
Flowcharting week 5 2019 2020
 
chapter 1
chapter 1chapter 1
chapter 1
 
DAA-Unit1.pptx
DAA-Unit1.pptxDAA-Unit1.pptx
DAA-Unit1.pptx
 
Data Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm AnalysisData Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm Analysis
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
 
Chapter one
Chapter oneChapter one
Chapter one
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Python4HPC.pptx
Python4HPC.pptxPython4HPC.pptx
Python4HPC.pptx
 
Algorithm Design and Analysis
Algorithm Design and AnalysisAlgorithm Design and Analysis
Algorithm Design and Analysis
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
 
Blueprints: Introduction to Python programming
Blueprints: Introduction to Python programmingBlueprints: Introduction to Python programming
Blueprints: Introduction to Python programming
 
Meetup 29042015
Meetup 29042015Meetup 29042015
Meetup 29042015
 
Deep learning from scratch
Deep learning from scratch Deep learning from scratch
Deep learning from scratch
 
Algorithm n problem solving x
Algorithm n problem solving xAlgorithm n problem solving x
Algorithm n problem solving x
 
MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...
MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...
MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...
 
Why computer programming
Why computer programmingWhy computer programming
Why computer programming
 
complexity analysis.pdf
complexity analysis.pdfcomplexity analysis.pdf
complexity analysis.pdf
 

Recently uploaded

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 

Recently uploaded (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

Class[1][23ed may] [algorithms]

  • 1. ALGORITHMS, COMPUTER GRAPHICS, AND MATHEMATICS FOR GAME DEVELOPERS & COMPUTER SCIENTISTS Class[1]: Introduction to Algorithms, Big-O Notation Presented by Dr. Saajid Abuluaih - May 2021 -
  • 2. Algorithms, Computer Graphics, and Mathematics for Game Developers and Computer Scientists © 2021 arche1.co.jp | jaist.ac.jp All rights reserved. 2 Agenda One-Bite Wisdom On Algorithms Simple Algorithms 𝑖 Big O Notation The Class Structure On Pseudocode Introduction to the Course 𝑔 𝑛 “The future is not just unwritten - it is unsearched” -Bruce Sterling
  • 3. Algorithms, Computer Graphics, and Mathematics for Game Developers and Computer Scientists © 2021 arche1.co.jp | jaist.ac.jp All rights reserved. 3 BEFORE WE START, I GOT ONE DISCLAIMER TO ANNOUNCE This course is not designed for totally beginners … You need to have some basic knowledge on what Computer Science is all about HOWEVER, If you feel like you can’t understand something that you think it is important Please let me know
  • 4. © 2021 arche1.co.jp | jaist.ac.jp All rights reserved. P A G E 4 One-Bite Wisdom Monty Hall Problem
  • 5. 5 • Let’s Make a Deal was a very famous game show back in the 70’s & 80’s • Monty Hall is the host of the show • There are three doors, one of them has a nice prize, and the other two have gags (Usually a farm animal) • You chose a door and then the host will open “Empty” another • The host then will aske you whether to stick with or switch the door you picked MONTY HALL PROBLEM, THE THREE DOORS GAME References: Monty Hall Problem - Wikipedia Monty Hall Problem - Numberphile - YouTube Monty Hall show - Let’s make a deal Is there a good strategy to use in this case?
  • 6. 6 • Mathematicians say: in order to increase your chances to win the nice prize, you must switch MONTY HALL PROBLEM, THE THREE DOORS GAME References: Monty Hall Problem - Wikipedia Monty Hall Problem - Numberphile - YouTube Monty Hall show - Let’s make a deal This strategy doesn’t guarantee that you will. But it will increase your chances 13 1/3 2/3 1/3 2/3
  • 7. 7 Mathematicians say: in order to increase your chances of winning the nice prize, you must switch. MONTY HALL PROBLEM, THE THREE DOORS GAME References: Monty Hall Problem - Wikipedia Monty Hall Problem - Numberphile - YouTube To explain it even better, consider the following scenario. You have six doors. You chose one. The host open 4 empty doors. Will you prefer then to stick with your early door selection or will you switch. 1/6 5/6
  • 8. Algorithms, Computer Graphics, and Mathematics for Game Developers and Computer Scientists © 2021 arche1.co.jp | jaist.ac.jp All rights reserved. WHAT THAT HAS TO DO WITH OUR CLASS FOR TODAY? NOTHING it has nothing to do with today’s class
  • 9. © 2021 arche1.co.jp | jaist.ac.jp All rights reserved. P A G E 9 Introduction About the Course
  • 10. This is a course in algorithms and 3D computer graphics that enables enrolled students to learn the theory of computer graphics along with algorithms implementation for solving real-life problems, specifically that relates to mathematics and physics of motion in 3D spaces. Ultimately, the course intends to deliver knowledge that is sufficient to construct an interactive 3D application for simulating the movement of a controllable entity. The main topics this course intends to cove is: 10 INTRODUCTION, WHAT THIS COURSE IS ALL ABOUT - Algorithms: - Big-O notation - Definition, characteristics, usage, design, optimization - Programing useful algorithms for popular problems - Computer Graphic with Three.js: - Scene creation: - Light, camera - Renderer, animation loop - 3D Object creation: - Geometry - Material - Mesh - Mathematica and Physics - Locations in 2D & 3D spaces - Raycasting in 3D environments - Vectors: - Vector normal form - Dot product - Cross Product - Intersections - Matrices and Transformations - Newtons Laws of Motions Bonus: - Programing languages: C#, JavaScript, TS
  • 11. © 2021 arche1.co.jp | jaist.ac.jp All rights reserved. P A G E 11 The Class Structure How the class lectures are going to look like
  • 12. The structure of delivering classes: • One-bite wisdom 15 minutes (Knowledge Sharing Session) • Algorithms (15 minutes) • Lecture (45min ~ an hour) • Quiz • Homework • Groups’ discussion 30 minutes (we need four groups for) 12 THE CLASS STRUCTURE, WHAT THIS COURSE IS ALL ABOUT
  • 13. © 2021 arche1.co.jp | jaist.ac.jp All rights reserved. P A G E 13 ON ALGORITHMS WHAT WE WILL LEARN ABOUT ALGORITHMS
  • 14. Definition: An algorithm is an unambiguous finite sequence of well-defined step-by-step computer-implementable instructions, that takes data as an input instance (of a given problem) and produces an output that can be called a solution to the problem. But what is a problem: A problem is a set of instances that all share the same characteristic What is not an Algorithm: We don’t call the implementation of an algorithm an algorithm. We call it “code”. What makes an algorithm better than the other: Long story short, “the performance” … the smaller number of steps needed to produce the solution the better the algorithm is. However! Although, any type of instructions that handle inputs are considered “algorithms”; algorithmic thinking always involve loops and conditions. 14 ON ALGORITHMS, WHAT IS ALGORITHM? References: Algorithm What exactly is an algorithm? Algorithms explained | BBC (Ideas)
  • 15. A flowchart is the graphical or pictorial representation of an algorithm with the help of different symbols, shapes, and arrows to demonstrate a process or a program. 15 ON ALGORITHMS, DESIGNING AN ALGORITHM References: Explain Algorithm and Flowchart with Examples Example 1: Print 1 to 20: Algorithm: • Step 1: Initialize X as 0, • Step 2: Increment X by 1, • Step 3: Print X, • Step 4: If X is less than 20 then go back to step 2.
  • 16. Iterations VS Recursion The basic idea of using recursion and iteration is to repeat a sequence of instructions. Recursion is a function call in which the function being called is the same as the one initiating the call, whereas iteration occurs when a loop is continuously executed until a given condition is met. 16 On Algorithms, Algorithms implementation function Function1 (num) { if (Base) { return num; } return num + Function1(num - 1); } function Function1(num) { var value = 1; for (var i= num; i>=0; i--) { value += i; } return total; } References: Programming Loops vs Recursion - Computerphile
  • 17. © 2021 arche1.co.jp | jaist.ac.jp All rights reserved. P A G E 17 Simple Algorithms Let’s Brush our Coding Skills
  • 18. Factorial of a positive integer 𝑛𝑢𝑚 is product of all 𝑣𝑎𝑙𝑢𝑒𝑠 from 𝑛𝑢𝑚 to 1. For example, the factorial of 𝑛𝑢𝑚 = 5 is 5 ∗ 4 ∗ 3 ∗ 2 ∗ 1 = 120. 18 A SIMPLE ALGORITHM, CALCULATING THE FACTORIAL VALUE OF A POSITIVE INTEGER function factorial(num) { if (num === 1) { return 1; } return num * factorial(num - 1); } function factorial(num) { var total = 1; for (var i= num; i>=1; i--) { total = total * i; } return total; }
  • 19. © 2021 arche1.co.jp | jaist.ac.jp All rights reserved. P A G E 19 Quiz [1] Answer This Question … IF YOU CAN
  • 20. • Write the implementation of the following flowchart using your favorite coding language. [Homework] • What does the algorithm in the flowchart do? • What is the output of the algorithm if N was 15? 20 Quiz [1] What is the output of the following algorithm? Start Total = 0 i = 0 Read N Is count < N Print N Total = Total + N i = i + 1 End
  • 21. © 2021 arche1.co.jp | jaist.ac.jp All rights reserved. P A G E 21 Big O Notation Let’s Dive a Bit Into the Fundamentals
  • 22. It is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. In another way, it shows how the code slows as the data grows (Big- O notation used to measure space as well). 22 BIG-O NOTATION What is Big-O? References: Big O: How Code Slows as Data Grows Big O notation Algorithms Notes for Professionals
  • 23. We can not use the time to measure the performance of an algorithm. So, what to doe? • Rather than counting seconds, we count the number of steps (operations) that we need to execute every time to generate the outcome. • Think of this simple algorithm that does nothing other than printout “hello world” how many steps we need to execute? 23 BIG-O NOTATION TIMING OUR ALGORITHMS References: Big O: How Code Slows as Data Grows Algorithms Notes for Professionals • It is going to be 𝑂 1 . • Big-O Notation is a way to formalize a fuzzy counting
  • 24. What is the time complexity for the following algorithms: 24 BIG-O NOTATION LET’S EXAMINE the number of steps needed in algorithm THIS FUNCTION [P1] References: Big O: How Code Slows as Data Grows Algorithms Notes for Professionals How about his one: It is liner, 𝑂(𝑁) It is liner, 𝑂(1)
  • 25. What is the time complexity for the following function: 25 BIG-O NOTATION LET’S EXAMINE the number of steps needed in algorithm THIS FUNCTION [P2] References: Big O: How Code Slows as Data Grows Algorithms Notes for Professionals What do you think this is? Quadratic 𝑂(𝑁2 ) It is 𝑂(log(𝑁))
  • 26. We can not use the time to measure the performance of an algorithm. So what to doe? • 𝑂(1): Constant time • 𝑂(log(𝑁)): Logarithmic running time • 𝑂(𝑁): Linear running time • 𝑂(𝑁2 ): Quadratic. Polynomials running time. • 𝑂(2𝑁 ): Exponential running time • 𝑂(! 𝑁): Factorial running time 26 BIG-O NOTATION BIG-O COMPLEXITY MOST COMMON PATTERNS References: Big O: How Code Slows as Data Grows Algorithms Notes for Professionals
  • 27. • How the code slows as the data grows (Big-O notation used to ) • What does the algorithm do? • What is the output of the • algorithm if N was 15? 27 Big-O Notation What is the output of the following algorithm? References: Algorithms Notes for Professionals Big O Cheatsheet
  • 28. © 2021 arche1.co.jp | jaist.ac.jp All rights reserved. P A G E 28 Quiz [2] Answer This Question … IF YOU CAN
  • 29. • What is the Big-O notation for the following algorithm? • Is there anyway to enhance it? 29 Quiz [1] What is the time complexity of the following? Start Total = 0 i = 0 Read N Is count < N Print N Total = Total + N i = i + 1 End
  • 30. © 2021 arche1.co.jp | jaist.ac.jp All rights reserved. P A G E 30 Pseudocode Write A Code That Can Be Understood By Human
  • 31. 31 Definition: Pseudocode is an artificial and informal language that helps programmers develop algorithms. It is a "text- based" step-by-step design tool. Basic common pseudocode: - Assignment a ← expression - Arithmetic operators and numeric procedures a + b, a – b, a * b, a / b - Relational and Boolean operators a = b, a ≠ b, a > b, a < b, a ≥ b, a ≤ b - Condition Evaluates to true if condition is true; otherwise evaluates to false. Evaluates to true if both condition1 and condition2 are true or condition3 is true; - Iterations Repeat n Times { < Your logic here > } Repeat Until (condition) { < Your logic here > } - Procedures Procedure name (parameter1, parameter2, ...) { < Your logic here > Return (expression) } On Algorithms, Pseudocode References: PSEUDOCODE GUIDE
  • 32. © 2021 arche1.co.jp | jaist.ac.jp All rights reserved. P A G E 32 HOMEWORK Let’s Dive a Bit into Fundamentals
  • 33. Find any simple problem, and design two different algorithms that lead to the same result: • Use the flowcharts you learnt about today to present your algorithms • What is the time complexity (Big-O notation) of the algorithms that you are going to design • Write the pseudocode of your algorithms Read Chapter 3 of [Algorithms: Notes for Professional] and: • Summarize Big-Theta notation • Summarize Big-Omega Notation 33 DEADLINE 27/5 3/6, HOMEWORK
  • 34. Algorithms, Computer Graphics, and Mathematics for Game Developers and Computer Scientists © 2021 arche1.co.jp | jaist.ac.jp All rights reserved. THANKS FOR YOUR ATTENTION