Code Lab Module1 (GDSC Elizade University)

OpeoluwaOyedeji 21 views 14 slides May 11, 2024
Slide 1
Slide 1 of 14
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14

About This Presentation

This session teaches two methods for effective problem-solving.


Slide Content

Code Lab Module 1: Introduction to Problem Solving Opeoluwa Daniel Oyedeji GDSC Lead, E.U. Elizade University

What is problem solving?

Problem-solving refers to a systematic approach to analyzing the problem, developing a solution (algorithm), and implementing that solution in code .

Divide and Conquer

Problem-Solving Approaches When tackling coding problems, there are two main approaches you can take to break them down and develop a solution. Top-Down Approach Bottom-Up Approach

Top-Down Approach This approach starts with the big picture and works its way down. Understand the overall problem and break it down into smaller subproblems. Solve each subproblem independently, and then combine the solutions to form the final solution to the larger problem.

Top-Down Approach: Calculating Area Identify the whole shape. Divide it into simpler shapes. Calculate the area of each simple shape. Combine the areas to find the total area.

Top-Down Approach: Calculating Area Identify the whole shape. Divide it into simpler shapes. Calculate the area of each simple shape. Combine the areas to find the total area.

Semicircle Area Rectangle Area Triangle Area Total Area C hart 1

Bottom-Up Approach This approach starts with the building blocks and works its way up. Start with the most basic operations needed to solve the problem. Combine these operations into larger functions to create the overall solution.

Bottom-Up Approach : Counting Vowels Implement a function to i dentify vowels. Implement a function to iterate through the list. Vowels : (a, e, i, o, u) List: (b, d, c, a, z, x, i, l, f)

I dentify vowels // Basic Operation private static boolean isVowel ( char x ) { char [] vowels = { 'a' , 'e' , 'i' , 'o' , 'u' }; for ( int i = ; i < vowels.length; i ++ ) if (vowels[i] == x) return true ; return false ; }

Iterate through list // Larger Function private static int countVowels ( char [] arr ) { int count = ; for ( int i = ; i < arr.length; i ++ ) if ( isVowel (arr[i])) count ++ ; return count; }

Recap Introduction to Problem Solving