SlideShare a Scribd company logo
ASUFE Juniors
Training
Session II
Welcome to The Second Session of ASUFE Juniors
Training
• Session Agenda:
• Note about sharing problem code
• Revision on functions
• Complexity Analysis
• Problem types
• Thinking techniques
• Stack vs Heap
• Local variables vs Global variables
Note about sharing sheet
problems codes
• Do not share a code that got an accepted to the facebook group.
Why?
Revision on functions
• IDE examples
Time Complexity (Big O notation)
Time Complexity (Big O notation)
Time Complexity (Example 1)
Total runtime: O(n) - Constants are neglected
Time Complexity (Example 2)
for (size_t i = 0; i < n; i++) {
/* code */
}
for (size_t i = 0; i < n; i++) {
for (size_t j = 0; j < m; j++) {
/* code */
}
}
for (size_t i = 1; i < n; i *= 2) {
for (size_t j = 0; i < n; j++) {
/* code */
}
}
Time Complexity (Example 3)
for (size_t i = 0; i < n; i++) {
for (size_t j = i; j < n; j++) {
/* code */
}
}
≈ n + (n-1) + (n-2) + ... + 2 + 1
≈ n(n+1) / 2
≈ (n^2 + n) / 2 ≈ O(n^2)
Time Complexity (Example 4)
Task: Search for an element in a sorted array.
Time Complexity (Example 4)
Task: Search for an element in a sorted array.
Runtime Analysis:
Linear Search: O(n)
Binary Search: O(log n)
Space Analysis (Neglecting the original array):
Linear Search: O(1)
Binary Search: O(1)
Time Complexity (Summary)
Time Complexity
Most online judges run between 10^7 ~ 10^8 operation/second
Problem Types
• Brute force
• Greedy
• Ad hocs
• Divide and conquer
Problem statement
• Read the problem statement
• Think in a solution and verify it.
• Coding
• Debugging
• Testing
Problem statement
• Make sure you read the problem statement correctly.
• Reading the problem in hurry may lead that you solve another problem.
• Make sure to output the output format exactly as the problem asks.
• How codeforces and UVA judges handle new lines at the end of the output.
• Make sure to output the precision of the output as the problem asks.
• Make sure to check the problem constraints carefully.
• Don’t assume something not mentioned.
• Sometimes samples are trivial to mislead you.
• Think in papers not on pc.
Stack vs Heap
• Local variables go in the stack.
• Global variables go in the data section.
• Dynamically allocated variables go in the heap.
• Declare your variables locally vs declaring them globally.
ACM ICPC Rules
• More problems higher rank.
• If 2 contestants have the same number of problems then we see who
have a lower penalty time.
• Each problem penalty is added whenever we submit it accepted.
• Every wrong answer adds 20 mins penalty time.
Codeforces problems difficulty
• Div3 problems are the easiest.
• Div2 is harder.
• Div1 is the hardest.
• Each Div is composed of problems distributed from A to E or F
according to the contest.
• A is the easiest.
• As we go up in alphabet the problem becomes harder.
• ICPC problem distribution are different from codeforces.
ASUFE Juniors
Training
Session II

More Related Content

PPT
Kobi_H_2018_JustEnoughTesting_02_TestIL_handout
PDF
20130523 05 - Cyclomatic complexity
PDF
Improving the accuracy and reliability of data analysis code
PPTX
Measurement Metrics for Object Oriented Design
PDF
9 d57206c real time operating systems
PPT
12 boundary value problem
PDF
Algorithms overview
PPT
An introduction to Competitive Programming
Kobi_H_2018_JustEnoughTesting_02_TestIL_handout
20130523 05 - Cyclomatic complexity
Improving the accuracy and reliability of data analysis code
Measurement Metrics for Object Oriented Design
9 d57206c real time operating systems
12 boundary value problem
Algorithms overview
An introduction to Competitive Programming

Similar to Asufe juniors-training session2 (20)

PPT
Acm icpc-briefing-prof-nbv
PPT
Problem solving on acm international collegiate programming contest
PPTX
Introduction to cp
PPT
Data Structure and Algorithms Department of Computer Science
PPTX
Competitive Programming
PPT
CS3114_09212011.ppt
PPTX
FDS Unit I_PPT.pptx
PPTX
uw cse correct style and speed autumn 2020
PPTX
L1_Start_of_Learning_of_Algorithms_Basics.pptx
PPTX
L1_DatabAlgorithm Basics with Design & Analysis.pptx
PDF
guide-t-cp.pdf programming book will help to
PPT
01SoftwEng.pptInnovation technology pptInnovation technology ppt
PDF
Lecture 7 program development issues (supplementary)
PDF
05211201 Advanced Data Structures And Algorithms
PDF
05211201 A D V A N C E D D A T A S T R U C T U R E S A N D A L G O R I...
PPTX
Unit 1.pptx
PDF
Contest Tips and Tricks
PPTX
DAA-Unit1.pptx
PPT
Design and Analysis of algorithms unit 1 notes
Acm icpc-briefing-prof-nbv
Problem solving on acm international collegiate programming contest
Introduction to cp
Data Structure and Algorithms Department of Computer Science
Competitive Programming
CS3114_09212011.ppt
FDS Unit I_PPT.pptx
uw cse correct style and speed autumn 2020
L1_Start_of_Learning_of_Algorithms_Basics.pptx
L1_DatabAlgorithm Basics with Design & Analysis.pptx
guide-t-cp.pdf programming book will help to
01SoftwEng.pptInnovation technology pptInnovation technology ppt
Lecture 7 program development issues (supplementary)
05211201 Advanced Data Structures And Algorithms
05211201 A D V A N C E D D A T A S T R U C T U R E S A N D A L G O R I...
Unit 1.pptx
Contest Tips and Tricks
DAA-Unit1.pptx
Design and Analysis of algorithms unit 1 notes
Ad

Recently uploaded (20)

PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
medical staffing services at VALiNTRY
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Nekopoi APK 2025 free lastest update
PDF
top salesforce developer skills in 2025.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
System and Network Administration Chapter 2
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
assetexplorer- product-overview - presentation
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
Computer Software and OS of computer science of grade 11.pptx
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Design an Analysis of Algorithms II-SECS-1021-03
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
wealthsignaloriginal-com-DS-text-... (1).pdf
medical staffing services at VALiNTRY
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Nekopoi APK 2025 free lastest update
top salesforce developer skills in 2025.pdf
PTS Company Brochure 2025 (1).pdf.......
Navsoft: AI-Powered Business Solutions & Custom Software Development
System and Network Administration Chapter 2
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Digital Systems & Binary Numbers (comprehensive )
assetexplorer- product-overview - presentation
Wondershare Filmora 15 Crack With Activation Key [2025
Which alternative to Crystal Reports is best for small or large businesses.pdf
Upgrade and Innovation Strategies for SAP ERP Customers
Ad

Asufe juniors-training session2

  • 2. Welcome to The Second Session of ASUFE Juniors Training • Session Agenda: • Note about sharing problem code • Revision on functions • Complexity Analysis • Problem types • Thinking techniques • Stack vs Heap • Local variables vs Global variables
  • 3. Note about sharing sheet problems codes • Do not share a code that got an accepted to the facebook group. Why?
  • 5. Time Complexity (Big O notation)
  • 6. Time Complexity (Big O notation)
  • 7. Time Complexity (Example 1) Total runtime: O(n) - Constants are neglected
  • 8. Time Complexity (Example 2) for (size_t i = 0; i < n; i++) { /* code */ } for (size_t i = 0; i < n; i++) { for (size_t j = 0; j < m; j++) { /* code */ } } for (size_t i = 1; i < n; i *= 2) { for (size_t j = 0; i < n; j++) { /* code */ } }
  • 9. Time Complexity (Example 3) for (size_t i = 0; i < n; i++) { for (size_t j = i; j < n; j++) { /* code */ } } ≈ n + (n-1) + (n-2) + ... + 2 + 1 ≈ n(n+1) / 2 ≈ (n^2 + n) / 2 ≈ O(n^2)
  • 10. Time Complexity (Example 4) Task: Search for an element in a sorted array.
  • 11. Time Complexity (Example 4) Task: Search for an element in a sorted array. Runtime Analysis: Linear Search: O(n) Binary Search: O(log n) Space Analysis (Neglecting the original array): Linear Search: O(1) Binary Search: O(1)
  • 13. Time Complexity Most online judges run between 10^7 ~ 10^8 operation/second
  • 14. Problem Types • Brute force • Greedy • Ad hocs • Divide and conquer
  • 15. Problem statement • Read the problem statement • Think in a solution and verify it. • Coding • Debugging • Testing
  • 16. Problem statement • Make sure you read the problem statement correctly. • Reading the problem in hurry may lead that you solve another problem. • Make sure to output the output format exactly as the problem asks. • How codeforces and UVA judges handle new lines at the end of the output. • Make sure to output the precision of the output as the problem asks. • Make sure to check the problem constraints carefully. • Don’t assume something not mentioned. • Sometimes samples are trivial to mislead you. • Think in papers not on pc.
  • 17. Stack vs Heap • Local variables go in the stack. • Global variables go in the data section. • Dynamically allocated variables go in the heap. • Declare your variables locally vs declaring them globally.
  • 18. ACM ICPC Rules • More problems higher rank. • If 2 contestants have the same number of problems then we see who have a lower penalty time. • Each problem penalty is added whenever we submit it accepted. • Every wrong answer adds 20 mins penalty time.
  • 19. Codeforces problems difficulty • Div3 problems are the easiest. • Div2 is harder. • Div1 is the hardest. • Each Div is composed of problems distributed from A to E or F according to the contest. • A is the easiest. • As we go up in alphabet the problem becomes harder. • ICPC problem distribution are different from codeforces.