SlideShare una empresa de Scribd logo
1 de 44
Descargar para leer sin conexión
Software
Architect
Algorithm Analysis & Design
Big-O and Solution Design
by Douglas Crockford
- Principal Software Architect at Telkom Indonesia
- Engineering Lead of Digital Product Engineering Chapter Digital Business & Technology
- Solutions Architect at Online Single Submission System (oss.go.id)
- Head of Engineer at Peduli Lindungi
- Software Architect Lead at Telkom Indonesia
- Professional Mentor at Purwadhika Digital Technology School
- Cloud Computing Instructor at Google Bangkit
- Software Engineer
- Professional Lecture
- Researcher
- Speaker
- Author
Rony Setyawan, S.T., M.Kom., CCP., CSAP.
by Grady Booch
Type of Big-O Big-O Rules Solution Design Q&A
Easy to Maintain (Readability)
Easy to Scale
(Scalability)
Good or Bad Code?
Section One
Theory and Practice of Big-O
Section One
Theory and Practice of Big-O
Big-O Complexity Chart
Section One
Theory and Practice of Big-O
Experiment 1
Section One
Theory and Practice of Big-O
Experiment 2
Section One
Theory and Practice of Big-O
Experiment 3
Section One
Theory and Practice of Big-O
Conclusion Experiment 1, 2, 3
The increase in the amount of data (elements) will be directly proportional to the increase in the time
needed to run the task (number of operations needed).
Within Big O, the main topic of discussion is how do we make our algorithm as good as possible in the
Excellent, Good, or Fair area. And we need to avoid Horrible and Bad areas.
So, this is not a contradiction with Conclusion 1.
An algorithm is said to be Scalable, if the algorithm is O(log n), O(1), or O(n).
Apart from doing some refactoring so that we can enter into one of those areas of Big O notation.
In experiments 1, 2, and 3, the function is in O(n).
Section One
Theory and Practice of Big-O
Linear Time Big-O
For Loop
While Loop
What kind of
implementation?
Section One
Theory and Practice of Big-O
Experiment 4
Section One
Theory and Practice of Big-O
Experiment 5
Section One
Theory and Practice of Big-O
Experiment 6
Section One
Theory and Practice of Big-O
Conclusion Experiment 4, 5, 6
The amount of data we use has no effect at all on the performance of the function
Time is always constant (fixed) even though the amount of data changes whether it's getting smaller or bigger
In experiments 4, 5, and 6, the function is in O(1).
Section One
Theory and Practice of Big-O
Constant Time Big-O
All Single Statement
No Loop Function
What kind of
implementation?
Section One
Theory and Practice of Big-O
Big-O Calculation Example
Section One
Theory and Practice of Big-O
Experiment 7
Section One
Theory and Practice of Big-O
Conclusion Experiment 7
Nested Loop (marked by an indentation) it means that it indicates multiplication (*) not Addition (+)
The number of menus generated is 16 menus, this is obtained from multiplication (foods, drinks)
In experiments 7, the function is in O(n^2).
Section One
Theory and Practice of Big-O
Nested For Loop
Nested While Loop
What kind of
implementation?
Nested Loop
Quadratic Time Big-O
Section One
Theory and Practice of Big-O
Experiment 8
Problem Statement:
● There are several candidates for the presidential candidates for
Indonesia in 2024.
● They will be scheduled to debate the presidential candidates and take
serial numbers for their identities later during the campaign.
● At the meeting, of course, several chairs are needed to be used by these
candidates, then how can we arrange these chairs?
● Please provide an alternative to the seat arrangement for the three
presidential candidates!
Section One
Theory and Practice of Big-O
Experiment 9
Section One
Theory and Practice of Big-O
Result Experiment 9
Section One
Theory and Practice of Big-O
Conclusion Experiment 8 and 9
When we use 3 input data, it produces 6 output data (3! = 6)
When we use 4 input data, it produces 24 output data (4! = 24)
The exact number of operations required will of course depend on the algorithm used
In experiment 8 & 9, use the recursive function approach.
In experiments 8 and 9, the function is in O(n!) or Factorial Big-O.
Section Two
Big-O Rules
Experiment 10
Section Two
Big-O Rules
Big O Rule 1 :
Worst Case Scenario is the most we care about / Drop non-dominant terms
Big O Rule 1 states that we cannot always expect ideal conditions such as for example ideal input
on the contrary we need to pay attention to conditions that are not ideal
so that our program runs in the most inefficient state.
Therefore, in Experiment 10 we can say that the function belongs to O(n).
Experiment 10
● Input 'Telkom' (0), so it only requires 1 search process
● Input 'AT&T' (4), so it only takes 5 searching processes
● Input 'T-Mobile' (10), then it requires 11 searching processes
Section Two
Big-O Rules
Experiment 11
Problem Statement:
● The marketing and product teams have customer
data totaling 100 mobile numbers.
● Approaching the end of the year, there is an
initiative to send promos to all customers using
existing mobile number data.
● Apart from the promo, there is also a special
discount given to only 10 customers selected by
the product team.
Section Two
Big-O Rules
Result Experiment 11
Big O Rule 2 :
Remove Every Constants
Let's take a closer look at Experiment 11, specifically for the SendPromoDiscount function.
In Big O calculations for this function actually consists of O(n) and O(10).
Simplify it then becomes O(n + 10).
Big O Rule 2 states that We Must Remove Every Constant, then ignore the O(10).
Compared to O(n), which is not fixed and can have a very large impact.
Section Two
Big-O Rules
Experiment 12
Section Two
Big-O Rules
Experiment 13
Section Two
Big-O Rules
Experiment 12 and 13
● Based on Big O Rule 1, we can ignore the existing O(2).
● Based on Big O Rule 2, in Experiment 12 we can ignore the
existing Contacts. So, we can simplify O(2n) to only O(n).
● Based on Big O Rule 3, we cannot simplify Experiment 13 so
that the Big O notation we get is O(m + n).
Big O Rule 3 :
Different Terms for Inputs
Big O Rule 3 states that if we find a function/program that uses different input data, then we
can not simplify Big O notation because different input data can significantly affect the
complexity or number of operations required.
Section Two
Big-O Rules
Time Complexity of Big-O
Section Three
Solution Design
Hash Table
https://www.miraclesalad.com/webtools/md5.php
https://www.cs.usfca.edu/~galles/visualization/OpenHash.html
Hash table, also known as hash map, is a data structure that implements an associative array or dictionary.
It is an abstract data type that maps keys to values.
A hash table uses a hash function to compute an index, also called a hash code, into an array of buckets or
slots, from which the desired value can be found.
During lookup, the key is hashed and the resulting hash indicates where the corresponding value is stored.
Hash Function Simulation
Section Three
Solution Design
Hash Table
Section Three
Solution Design
Hash Tables Overview
Section Three
Solution Design
Arrays vs Hash Tables
Hash Tables Implementation
Section Three
Solution Design
Section Three
Solution Design
Dynamic Programming
Can be divided into subproblems
Commonly based on plain recursive solution
Are there repetitive subproblems
Memoize subproblems
Dynamic Programming Implementation
Section Three
Solution Design
Section Three
Solution Design
Recursive vs Dynamic Programming
Any Question?
by Bertrand Meyer
THANK
YOU

Más contenido relacionado

La actualidad más candente

poster-agile framework to implement togaf with lean ix
poster-agile framework to implement togaf with lean ixposter-agile framework to implement togaf with lean ix
poster-agile framework to implement togaf with lean ix
Laurent Nonne
 

La actualidad más candente (9)

Looking for Disruptive Business Models in Higher Education
Looking for Disruptive Business Models in Higher EducationLooking for Disruptive Business Models in Higher Education
Looking for Disruptive Business Models in Higher Education
 
Over 50 Adoption Activities That Have Helped Organizations Get More Out Of Of...
Over 50 Adoption Activities That Have Helped Organizations Get More Out Of Of...Over 50 Adoption Activities That Have Helped Organizations Get More Out Of Of...
Over 50 Adoption Activities That Have Helped Organizations Get More Out Of Of...
 
Approaches to business architecture
Approaches to business architectureApproaches to business architecture
Approaches to business architecture
 
小林敏:ルビの配置方法 1 2_2
小林敏:ルビの配置方法 1 2_2小林敏:ルビの配置方法 1 2_2
小林敏:ルビの配置方法 1 2_2
 
Resume_FLEXCUBE
Resume_FLEXCUBEResume_FLEXCUBE
Resume_FLEXCUBE
 
poster-agile framework to implement togaf with lean ix
poster-agile framework to implement togaf with lean ixposter-agile framework to implement togaf with lean ix
poster-agile framework to implement togaf with lean ix
 
Creating Agile Organizations by Combining Design, Architecture and Agile Thin...
Creating Agile Organizations by Combining Design, Architecture and Agile Thin...Creating Agile Organizations by Combining Design, Architecture and Agile Thin...
Creating Agile Organizations by Combining Design, Architecture and Agile Thin...
 
Normalização - Alexandruk
Normalização - AlexandrukNormalização - Alexandruk
Normalização - Alexandruk
 
Using business rules to make processes simpler, smarter and more agile
Using business rules to make processes simpler, smarter and more agileUsing business rules to make processes simpler, smarter and more agile
Using business rules to make processes simpler, smarter and more agile
 

Similar a Algorithm Analysis & Solution Design.pdf

Measuring Efficiency of Use in a Web-based EMR Developed for Malawi: Lessons ...
Measuring Efficiency of Use in a Web-based EMR Developed for Malawi: Lessons ...Measuring Efficiency of Use in a Web-based EMR Developed for Malawi: Lessons ...
Measuring Efficiency of Use in a Web-based EMR Developed for Malawi: Lessons ...
Gunther Eysenbach
 
Karner resource estimation for objectory projects
Karner   resource estimation for objectory projectsKarner   resource estimation for objectory projects
Karner resource estimation for objectory projects
Ocho08
 

Similar a Algorithm Analysis & Solution Design.pdf (20)

Testing In Production (TiP) Advances with Big Data and the Cloud
Testing In Production (TiP) Advances with Big Data and the CloudTesting In Production (TiP) Advances with Big Data and the Cloud
Testing In Production (TiP) Advances with Big Data and the Cloud
 
Crude-Oil Scheduling Technology: moving from simulation to optimization
Crude-Oil Scheduling Technology: moving from simulation to optimizationCrude-Oil Scheduling Technology: moving from simulation to optimization
Crude-Oil Scheduling Technology: moving from simulation to optimization
 
Cs 568 Spring 10 Lecture 5 Estimation
Cs 568 Spring 10  Lecture 5 EstimationCs 568 Spring 10  Lecture 5 Estimation
Cs 568 Spring 10 Lecture 5 Estimation
 
Using SigOpt to Tune Deep Learning Models with Nervana Cloud
Using SigOpt to Tune Deep Learning Models with Nervana CloudUsing SigOpt to Tune Deep Learning Models with Nervana Cloud
Using SigOpt to Tune Deep Learning Models with Nervana Cloud
 
Cocomo
CocomoCocomo
Cocomo
 
COCOMO MODEL
COCOMO MODELCOCOMO MODEL
COCOMO MODEL
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm Analysis
 
Cocomo models
Cocomo modelsCocomo models
Cocomo models
 
Testing In Production (TiP) Advances with Big Data & the Cloud
Testing In Production (TiP) Advances with Big Data & the CloudTesting In Production (TiP) Advances with Big Data & the Cloud
Testing In Production (TiP) Advances with Big Data & the Cloud
 
OpenPOWER Webinar from University of Delaware - Title :OpenMP (offloading) o...
OpenPOWER Webinar from University of Delaware  - Title :OpenMP (offloading) o...OpenPOWER Webinar from University of Delaware  - Title :OpenMP (offloading) o...
OpenPOWER Webinar from University of Delaware - Title :OpenMP (offloading) o...
 
presentation
presentationpresentation
presentation
 
Symbexecsearch
SymbexecsearchSymbexecsearch
Symbexecsearch
 
CH05.pdf
CH05.pdfCH05.pdf
CH05.pdf
 
Measuring Efficiency of Use in a Web-based EMR Developed for Malawi: Lessons ...
Measuring Efficiency of Use in a Web-based EMR Developed for Malawi: Lessons ...Measuring Efficiency of Use in a Web-based EMR Developed for Malawi: Lessons ...
Measuring Efficiency of Use in a Web-based EMR Developed for Malawi: Lessons ...
 
Python week 6 2019 2020 for grade 10
Python week 6 2019 2020 for grade 10 Python week 6 2019 2020 for grade 10
Python week 6 2019 2020 for grade 10
 
Implementation of Fuzzy-PD for Folding Machine Prototype Using LEGO EV3
Implementation of Fuzzy-PD for Folding Machine Prototype Using LEGO EV3Implementation of Fuzzy-PD for Folding Machine Prototype Using LEGO EV3
Implementation of Fuzzy-PD for Folding Machine Prototype Using LEGO EV3
 
Karner resource estimation for objectory projects
Karner   resource estimation for objectory projectsKarner   resource estimation for objectory projects
Karner resource estimation for objectory projects
 
Thomas Kauders - Agile Test Design And Automation of a Life-Critical Medical ...
Thomas Kauders - Agile Test Design And Automation of a Life-Critical Medical ...Thomas Kauders - Agile Test Design And Automation of a Life-Critical Medical ...
Thomas Kauders - Agile Test Design And Automation of a Life-Critical Medical ...
 
White-box Unit Test Generation with Microsoft IntelliTest
White-box Unit Test Generation with Microsoft IntelliTestWhite-box Unit Test Generation with Microsoft IntelliTest
White-box Unit Test Generation with Microsoft IntelliTest
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 

Último

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Último (20)

WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 

Algorithm Analysis & Solution Design.pdf

  • 1. Software Architect Algorithm Analysis & Design Big-O and Solution Design
  • 3. - Principal Software Architect at Telkom Indonesia - Engineering Lead of Digital Product Engineering Chapter Digital Business & Technology - Solutions Architect at Online Single Submission System (oss.go.id) - Head of Engineer at Peduli Lindungi - Software Architect Lead at Telkom Indonesia - Professional Mentor at Purwadhika Digital Technology School - Cloud Computing Instructor at Google Bangkit - Software Engineer - Professional Lecture - Researcher - Speaker - Author Rony Setyawan, S.T., M.Kom., CCP., CSAP.
  • 5. Type of Big-O Big-O Rules Solution Design Q&A
  • 6. Easy to Maintain (Readability) Easy to Scale (Scalability) Good or Bad Code? Section One Theory and Practice of Big-O
  • 7. Section One Theory and Practice of Big-O Big-O Complexity Chart
  • 8. Section One Theory and Practice of Big-O Experiment 1
  • 9. Section One Theory and Practice of Big-O Experiment 2
  • 10. Section One Theory and Practice of Big-O Experiment 3
  • 11. Section One Theory and Practice of Big-O Conclusion Experiment 1, 2, 3 The increase in the amount of data (elements) will be directly proportional to the increase in the time needed to run the task (number of operations needed). Within Big O, the main topic of discussion is how do we make our algorithm as good as possible in the Excellent, Good, or Fair area. And we need to avoid Horrible and Bad areas. So, this is not a contradiction with Conclusion 1. An algorithm is said to be Scalable, if the algorithm is O(log n), O(1), or O(n). Apart from doing some refactoring so that we can enter into one of those areas of Big O notation. In experiments 1, 2, and 3, the function is in O(n).
  • 12. Section One Theory and Practice of Big-O Linear Time Big-O For Loop While Loop What kind of implementation?
  • 13. Section One Theory and Practice of Big-O Experiment 4
  • 14. Section One Theory and Practice of Big-O Experiment 5
  • 15. Section One Theory and Practice of Big-O Experiment 6
  • 16. Section One Theory and Practice of Big-O Conclusion Experiment 4, 5, 6 The amount of data we use has no effect at all on the performance of the function Time is always constant (fixed) even though the amount of data changes whether it's getting smaller or bigger In experiments 4, 5, and 6, the function is in O(1).
  • 17. Section One Theory and Practice of Big-O Constant Time Big-O All Single Statement No Loop Function What kind of implementation?
  • 18. Section One Theory and Practice of Big-O Big-O Calculation Example
  • 19. Section One Theory and Practice of Big-O Experiment 7
  • 20. Section One Theory and Practice of Big-O Conclusion Experiment 7 Nested Loop (marked by an indentation) it means that it indicates multiplication (*) not Addition (+) The number of menus generated is 16 menus, this is obtained from multiplication (foods, drinks) In experiments 7, the function is in O(n^2).
  • 21. Section One Theory and Practice of Big-O Nested For Loop Nested While Loop What kind of implementation? Nested Loop Quadratic Time Big-O
  • 22. Section One Theory and Practice of Big-O Experiment 8 Problem Statement: ● There are several candidates for the presidential candidates for Indonesia in 2024. ● They will be scheduled to debate the presidential candidates and take serial numbers for their identities later during the campaign. ● At the meeting, of course, several chairs are needed to be used by these candidates, then how can we arrange these chairs? ● Please provide an alternative to the seat arrangement for the three presidential candidates!
  • 23. Section One Theory and Practice of Big-O Experiment 9
  • 24. Section One Theory and Practice of Big-O Result Experiment 9
  • 25. Section One Theory and Practice of Big-O Conclusion Experiment 8 and 9 When we use 3 input data, it produces 6 output data (3! = 6) When we use 4 input data, it produces 24 output data (4! = 24) The exact number of operations required will of course depend on the algorithm used In experiment 8 & 9, use the recursive function approach. In experiments 8 and 9, the function is in O(n!) or Factorial Big-O.
  • 27. Section Two Big-O Rules Big O Rule 1 : Worst Case Scenario is the most we care about / Drop non-dominant terms Big O Rule 1 states that we cannot always expect ideal conditions such as for example ideal input on the contrary we need to pay attention to conditions that are not ideal so that our program runs in the most inefficient state. Therefore, in Experiment 10 we can say that the function belongs to O(n). Experiment 10 ● Input 'Telkom' (0), so it only requires 1 search process ● Input 'AT&T' (4), so it only takes 5 searching processes ● Input 'T-Mobile' (10), then it requires 11 searching processes
  • 28. Section Two Big-O Rules Experiment 11 Problem Statement: ● The marketing and product teams have customer data totaling 100 mobile numbers. ● Approaching the end of the year, there is an initiative to send promos to all customers using existing mobile number data. ● Apart from the promo, there is also a special discount given to only 10 customers selected by the product team.
  • 29. Section Two Big-O Rules Result Experiment 11 Big O Rule 2 : Remove Every Constants Let's take a closer look at Experiment 11, specifically for the SendPromoDiscount function. In Big O calculations for this function actually consists of O(n) and O(10). Simplify it then becomes O(n + 10). Big O Rule 2 states that We Must Remove Every Constant, then ignore the O(10). Compared to O(n), which is not fixed and can have a very large impact.
  • 32. Section Two Big-O Rules Experiment 12 and 13 ● Based on Big O Rule 1, we can ignore the existing O(2). ● Based on Big O Rule 2, in Experiment 12 we can ignore the existing Contacts. So, we can simplify O(2n) to only O(n). ● Based on Big O Rule 3, we cannot simplify Experiment 13 so that the Big O notation we get is O(m + n). Big O Rule 3 : Different Terms for Inputs Big O Rule 3 states that if we find a function/program that uses different input data, then we can not simplify Big O notation because different input data can significantly affect the complexity or number of operations required.
  • 33. Section Two Big-O Rules Time Complexity of Big-O
  • 34. Section Three Solution Design Hash Table https://www.miraclesalad.com/webtools/md5.php https://www.cs.usfca.edu/~galles/visualization/OpenHash.html Hash table, also known as hash map, is a data structure that implements an associative array or dictionary. It is an abstract data type that maps keys to values. A hash table uses a hash function to compute an index, also called a hash code, into an array of buckets or slots, from which the desired value can be found. During lookup, the key is hashed and the resulting hash indicates where the corresponding value is stored. Hash Function Simulation
  • 38. Hash Tables Implementation Section Three Solution Design
  • 39. Section Three Solution Design Dynamic Programming Can be divided into subproblems Commonly based on plain recursive solution Are there repetitive subproblems Memoize subproblems
  • 41. Section Three Solution Design Recursive vs Dynamic Programming