SlideShare a Scribd company logo
Problem Solving
Dr. Kuppusamy .P
Associate Professor / SCOPE
Dr. Kuppusamy P
Problem Statement 1: Design an algorithm and
draw the flow chart to exchange two values.
• Let’s consider two glasses denoted A and B with 30 ml
mango juice and 50 ml orange juice. Find out the way to
exchange the juice in A and B.
Dr. Kuppusamy P
• Declare variables
• Initialize the values
Problem Statement 1: Design an algorithm and
draw the flow chart to exchange two values.
Dr. Kuppusamy P
Problem Statement 1: Design an algorithm and
draw the flow chart to exchange two values.
Move Glass A value 30 to Glass
Temp
Move Glass B value 50 to
Glass A
Dr. Kuppusamy P
Problem Statement 1: Design an algorithm and
draw the flow chart to exchange two values.
Move Glass Temp value 30 to
Glass B
Dr. Kuppusamy P
Problem Statement 1: Design an algorithm and
draw the flow chart to exchange two values.
Algorithm
Step 1. Start
Step 2. Declare two variables A, B and one more variable temp
Step 3. Read the positive numbers to A and B
Step 3. temp ← A
Step 4. A ← B
Step 5. B ← temp
Step 6. Display interchanged numbers in A , B
Step 7. Stop
Dr. Kuppusamy P
Problem Statement 1: Design an algorithm and
draw the flow chart to exchange two values.
Algorithm
Step 1. Start
Step 2. Declare two variables A, B and one more variable temp
Step 3. Read the positive numbers to A and B
Step 3. temp ← A
Step 4. A ← B
Step 5. B ← temp
Step 6. Display interchanged numbers in A , B
Step 7. Stop
Read the positive
numbers to A and B
temp ← A
A ← B
B ← temp
Display
interchanged
numbers in A , B
Stop
Start
Declare variables A, B,
temp
Dr. Kuppusamy P
Problem Statement 2: Design an algorithm
and draw the flow chart to exchange two
values without using temporary variable.
Algorithm
Step 1. Start
Step 2. Declare two variables A, B
Step 3. Read the positive numbers as A and B
Step 3. A ← A + B
Step 4. B ← A - B
Step 5. A ← A - B
Step 6. Display interchanged numbers in A , B
Step 7. Stop
E.g. A = 7, B= 5
A = 7 + 5 =12
B = 12-5 =7
A= 12 - 7 =5
Dr. Kuppusamy P
Problem Statement 2: Design an algorithm
and draw the flow chart to exchange two
values without using temporary variable.
Algorithm
Step 1. Start
Step 2. Declare two variables A, B
Step 3. Read the positive numbers as A and B
Step 3. A ← A + B
Step 4. B ← A - B
Step 5. A ← A - B
Step 6. Display interchanged numbers in A , B
Step 7. Stop
E.g. A = 7, B= 5
A = 7 + 5 =12
B = 12-5 =7
A= 12 - 7 =5
Read the positive
numbers to A and B
A ← A + B
B ← A - B
A ← A - B
Display
interchanged
numbers in A , B
Stop
Start
Declare variables A, B
Dr. Kuppusamy P
Problem Statement 3: Design an algorithm and draw
the flow chart to find the sum of individual digits for
the given non negative integer.
Step 1. Start
Step 2. Declare variable n
Step 3. Read non negative integer (n)
Step 4. Initialize result ← 0
Step 5. Repeat until n > 0
Step 5.1 result ← result + (n % 10)
Step 5.2 n ← n / 10
Step 6. Display result
Step 7. Stop
E.g. Iteration: 1
n = 76
result = 0 + (76 % 10)
n = 76/10
Iteration: 2
n = 7
result = 6 + (7 % 10)
n = 7/10
Dr. Kuppusamy P
Repeat
Yes No
Problem Statement 3: Design an algorithm and draw
the flow chart to find the sum of individual digits for
the given non negative integer.
Step 1. Start
Step 2. Declare variable n
Step 3. Read non negative integer (n)
Step 4. Initialize result ← 0
Step 5. Repeat until n > 0
Step 5.1 result ← result + (n % 10)
Step 5.2 n ← n / 10
Step 6. Display result
Step 7. Stop
Read the positive
number n
result ← result + (n % 10)
n ← n / 10
Display the result
Stop
Start
Declare variable n
Repeat until n >0
Dr. Kuppusamy P
Problem Statement 4: Design an algorithm and draw
the flow chart to find the sum of given set of n positive
integer.
Step 1. Start
Step 2. Declare variables n, sum, a, i
Step 3. Read total numbers value (n) and ‘n’ positive integers in array ‘a’
Step 4. Initialize sum ← 0 , i ← 0
Step 5. Repeat until i < n
Step 5.1 sum ← sum + a[i]
Step 5.2 i ← i + 1
Step 6. Display sum
Step 7. Stop
n = 3
a[] = {2, 3, 4}
sum = 0 , i=0
Iteration: 1
sum = 0 + 2
i = i +1
Iteration: 2
sum = 2 + 3
i = i +1
Iteration: 3
sum = 5 + 4
i = i +1
Dr. Kuppusamy P
Problem Statement 4: Design an algorithm and draw
the flow chart to find the sum of given set of n positive
integer.
Step 1. Start
Step 2. Declare variables n, sum, a
Step 3. Read total numbers value (n)
and ‘n’ positive integers in
array ‘a’
Step 4. Initialize sum ← 0, i ← 0,
Step 5. Repeat until i < n
Step 5.1 sum ← sum + a[i]
Step 5.2 i ← i + 1
Step 6. Display sum
Step 7. Stop
Repeat
Yes No
Read total numbers value (n)
and ‘n’ integers in array ‘a’
sum ← sum + a[i]
i ← i + 1
Display the sum
Stop
Start
Declare variable n, sum, a
Repeat until i <n
Dr. Kuppusamy P
Problem Statement 5: Design an algorithm and draw
the flow chart to find the number of digits in given
number
Sample Input 1: 4582
Sample Output 1: The number of digits in 4582 is 4
Algorithm
Step 1. Start
Step 2. Declare variables
Step 3. Read the input
Step 4. Initialize count ← 0
Step 4. Repeat until n !=0
Step 5.1 count ← count + 1
Step 5.2 n ← n / 10
Step 6. Display count
Step 7. End
Iteration: 1
count = 0 + 1
n= 4582 /10
Iteration: 2
count = 1 + 1
n= 458 /10
Iteration: 3
count = 2 + 1
n= 45 /10
Iteration: 4
count = 3 + 1
n= 4 /10
Iteration: 5
n != 0 → False
Dr. Kuppusamy P
Problem Statement 6: Design an algorithm and draw
the flow chart to find Factorial computation
of given number
Sample Input 1: 4!
Sample Output 1: 24
Step 1. Begin
Step 2. Declare variables
Step 3. Read the decimal number n
Step 4. Initialize fact ← 1, i ← 1
Step 4. if (n != 0)
Step 4.1. Repeat until 1 to n
Step 4.1.1 fact ← fact * i
Step 4.1.2 increment i
Step 5. Display fact
Step 7. End
Iteration: 1
fact = 1 * 1
i = i +1
Iteration: 2
fact = 1 * 2
i = i +1
Iteration: 3
fact = 2 *3
i = i +1
Iteration: 4
fact = 6 * 4
i = i +1
Iteration: 5
i < =n → False
Dr. Kuppusamy P
Problem Statement 7: Design an algorithm and draw
the flow chart to find Sine function computation
Step 1. Begin.
Step 2. Read the input x and n
Step 3. Convert x value to radius using rad ← 3.14/180*x.
Step 4. Initialize sum ← rad, sign ← -1.
Step 5. Repeat for i ← 3 to n in increment by 2.
Step 5.1 power ← pow(rad, i).
Step 5.2 factorial ← factorial*(i-1)*i.
Step 5.3 result ← power / factorial.
Step 5.4 sum ← sum + (sign * result).
Step 5.5 k ← k*(-1).
Step 6. Display the sum as sine series result.
Step 7. End.
Dr. Kuppusamy P
Repeat
Yes No
Read the input x and n
power ← pow(rad, i).
factorial ← factorial*(i-1)*i.
result ← power / factorial.
sum ← sum + (sign * result).
k ← k*(-1)
Display the sum
Stop
Start
Declare variable
Repeat until i <n
Initialize sum, sign
Problem Statement 8: Design an algorithm and draw
the flow chart to generate Fibonacci sequence
Step 1. Begin
Step 2. Get Non-negative decimal limit n
Step 3. Initialize num1 ← 0, num2 ← 1
Step 4. Display num1 and num2
Step 5. Repeat until 1 to n- 2
Step 5.1 num3 ← num1 + num2
Step 5.2 Display num3
Step 5.3 num1 ← num2
Step 5.4 num2 ← num3
Step 6. End
Dr. Kuppusamy P
Input : 5
Output: 0, 1, 1, 2, 3, 5
Problem Statement 9: Design an algorithm and draw
the flow chart to Reverse the digits of an integer
Step 1. Begin
Step 2. Get Non-negative integer num
Step 3. Initialize reversed ← 0
Step 4. Repeat until num > 0
Step 4.1 digit ← n % 10
Step 4.2 reversed ← (reversed * 10) + digit;
Step 4.3 num ← num / 10
Step 5. Display reversed
Step 6. End
Dr. Kuppusamy P
Input : 598
Output: 895
Problem Statement 10: Design an algorithm and draw the flow chart to
Decimal to Binary conversion
Step 1. Begin
Step 2. Get a Positive decimal number (n)
Step 3. Initialize result as null
Step 4. if (n > 1)
Step 4.1. Repeat until n < 2
Step 4.1.1 Remainder ← n % 2
Step 4.1.2 Append remainder with result
Step 4.1.3 n ← n / 2
Step 5. Append n with result
Step 6. Display the reverse of result
Step 7. End
Dr. Kuppusamy P
Input : 3
Output: 011
Repeat
Yes No
Read integer n
Remainder ← n % 2
Append remainder with result
n ← n / 2
Append n with result
Display the reverse of
result
Stop
Start
Declare variable
Initialize result as null
Repeat until n<2
References
Dr. Kuppusamy P
• Herbert Schildt, “Java: The Complete Reference”, McGraw-Hill Education, Tenth
edition, 2017.
• https://www.sitesbay.com

More Related Content

What's hot

Ch 6: The Wild World of Windows
Ch 6: The Wild World of WindowsCh 6: The Wild World of Windows
Ch 6: The Wild World of Windows
Sam Bowne
 
Algorithm and Flowcharts
Algorithm and FlowchartsAlgorithm and Flowcharts
Algorithm and Flowcharts
SURBHI SAROHA
 
CNIT 127: L9: Web Templates and .NET
CNIT 127: L9: Web Templates and .NETCNIT 127: L9: Web Templates and .NET
CNIT 127: L9: Web Templates and .NET
Sam Bowne
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
Ahmed El-Arabawy
 
9: OllyDbg
9: OllyDbg9: OllyDbg
9: OllyDbg
Sam Bowne
 
How Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protectionsHow Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protections
Jonathan Salwan
 
CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)
Sam Bowne
 
AlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfAlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdf
SusieMaestre1
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
Sridhar P
 
File upload-vulnerability-in-fck editor
File upload-vulnerability-in-fck editorFile upload-vulnerability-in-fck editor
File upload-vulnerability-in-fck editor
Paolo Dolci
 
2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQL2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQL
Scott Sutherland
 
PHP unserialization vulnerabilities: What are we missing?
PHP unserialization vulnerabilities: What are we missing?PHP unserialization vulnerabilities: What are we missing?
PHP unserialization vulnerabilities: What are we missing?
Sam Thomas
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in CJeya Lakshmi
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDB
Hengki Sihombing
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesHacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sites
Mikhail Egorov
 
Lightweight static code analysis with semgrep
Lightweight static code analysis with semgrepLightweight static code analysis with semgrep
Lightweight static code analysis with semgrep
Null Bhubaneswar
 
Unit 3 Foc
Unit  3 FocUnit  3 Foc
Unit 3 Foc
JAYA
 
Practical Malware Analysis Ch13
Practical Malware Analysis Ch13Practical Malware Analysis Ch13
Practical Malware Analysis Ch13
Sam Bowne
 
The pseudocode
The pseudocodeThe pseudocode
The pseudocode
Asha Sari
 
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programsAEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
Mikhail Egorov
 

What's hot (20)

Ch 6: The Wild World of Windows
Ch 6: The Wild World of WindowsCh 6: The Wild World of Windows
Ch 6: The Wild World of Windows
 
Algorithm and Flowcharts
Algorithm and FlowchartsAlgorithm and Flowcharts
Algorithm and Flowcharts
 
CNIT 127: L9: Web Templates and .NET
CNIT 127: L9: Web Templates and .NETCNIT 127: L9: Web Templates and .NET
CNIT 127: L9: Web Templates and .NET
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
 
9: OllyDbg
9: OllyDbg9: OllyDbg
9: OllyDbg
 
How Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protectionsHow Triton can help to reverse virtual machine based software protections
How Triton can help to reverse virtual machine based software protections
 
CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)
 
AlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfAlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdf
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
File upload-vulnerability-in-fck editor
File upload-vulnerability-in-fck editorFile upload-vulnerability-in-fck editor
File upload-vulnerability-in-fck editor
 
2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQL2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQL
 
PHP unserialization vulnerabilities: What are we missing?
PHP unserialization vulnerabilities: What are we missing?PHP unserialization vulnerabilities: What are we missing?
PHP unserialization vulnerabilities: What are we missing?
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDB
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesHacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sites
 
Lightweight static code analysis with semgrep
Lightweight static code analysis with semgrepLightweight static code analysis with semgrep
Lightweight static code analysis with semgrep
 
Unit 3 Foc
Unit  3 FocUnit  3 Foc
Unit 3 Foc
 
Practical Malware Analysis Ch13
Practical Malware Analysis Ch13Practical Malware Analysis Ch13
Practical Malware Analysis Ch13
 
The pseudocode
The pseudocodeThe pseudocode
The pseudocode
 
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programsAEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
 

Similar to Problem solving using Programming

UNIT I - Algorithmic Problem Solving.pptx
UNIT I - Algorithmic Problem Solving.pptxUNIT I - Algorithmic Problem Solving.pptx
UNIT I - Algorithmic Problem Solving.pptx
Pradeepkumar964266
 
Algorithm
AlgorithmAlgorithm
Algorithm
Md Angkon
 
Lecture 7.pptx
Lecture 7.pptxLecture 7.pptx
Lecture 7.pptx
Arul Jothi Yuvaraja
 
Two step equations
Two step equationsTwo step equations
Two step equations
devsmith07
 
Chapter2.8
Chapter2.8Chapter2.8
Chapter2.8nglaze10
 
Algorithmsandflowcharts2
Algorithmsandflowcharts2Algorithmsandflowcharts2
Algorithmsandflowcharts2Darlene Interno
 
Computer basics
Computer basicsComputer basics
Computer basics
Kailas Sree Chandran
 
New ways of multiplying numbers
New ways of multiplying numbersNew ways of multiplying numbers
New ways of multiplying numbers
iosrjce
 
25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual
kamesh dagia
 
PSP LAB MANUAL.pdf
PSP LAB MANUAL.pdfPSP LAB MANUAL.pdf
PSP LAB MANUAL.pdf
Selvaraj Seerangan
 
4. algorithm
4. algorithm4. algorithm
4. algorithm
SHIKHA GAUTAM
 
Multiplying Decimals
Multiplying DecimalsMultiplying Decimals
Multiplying Decimals
Lea Perez
 
Whole Numbers std 6.ppt
Whole Numbers std 6.pptWhole Numbers std 6.ppt
Whole Numbers std 6.ppt
MVHerwadkarschool
 
Chapter 3 - Problem Solving.pdf
Chapter 3 - Problem Solving.pdfChapter 3 - Problem Solving.pdf
Chapter 3 - Problem Solving.pdf
MinaSaflor
 
Chapter1.4
Chapter1.4Chapter1.4
Chapter1.4nglaze10
 
ppt math6 qt3-wk3.pptx
ppt math6 qt3-wk3.pptxppt math6 qt3-wk3.pptx
ppt math6 qt3-wk3.pptx
casafelicemcat04
 
Algebra 1 week 8 learn it 1
Algebra 1 week 8 learn it 1Algebra 1 week 8 learn it 1
Algebra 1 week 8 learn it 1
JessicaBiemiller
 
Solving One Step Equations
Solving One Step Equations Solving One Step Equations
Solving One Step Equations
Kelly Williams
 
Stanford splash spring 2016 basic programming
Stanford splash spring 2016 basic programmingStanford splash spring 2016 basic programming
Stanford splash spring 2016 basic programming
Yu-Sheng (Yosen) Chen
 

Similar to Problem solving using Programming (20)

UNIT I - Algorithmic Problem Solving.pptx
UNIT I - Algorithmic Problem Solving.pptxUNIT I - Algorithmic Problem Solving.pptx
UNIT I - Algorithmic Problem Solving.pptx
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Lecture 7.pptx
Lecture 7.pptxLecture 7.pptx
Lecture 7.pptx
 
Two step equations
Two step equationsTwo step equations
Two step equations
 
Chapter2.8
Chapter2.8Chapter2.8
Chapter2.8
 
Algorithmsandflowcharts2
Algorithmsandflowcharts2Algorithmsandflowcharts2
Algorithmsandflowcharts2
 
Computer basics
Computer basicsComputer basics
Computer basics
 
New ways of multiplying numbers
New ways of multiplying numbersNew ways of multiplying numbers
New ways of multiplying numbers
 
25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual
 
PSP LAB MANUAL.pdf
PSP LAB MANUAL.pdfPSP LAB MANUAL.pdf
PSP LAB MANUAL.pdf
 
4. algorithm
4. algorithm4. algorithm
4. algorithm
 
Module 1 topic 1 notes
Module 1 topic 1 notesModule 1 topic 1 notes
Module 1 topic 1 notes
 
Multiplying Decimals
Multiplying DecimalsMultiplying Decimals
Multiplying Decimals
 
Whole Numbers std 6.ppt
Whole Numbers std 6.pptWhole Numbers std 6.ppt
Whole Numbers std 6.ppt
 
Chapter 3 - Problem Solving.pdf
Chapter 3 - Problem Solving.pdfChapter 3 - Problem Solving.pdf
Chapter 3 - Problem Solving.pdf
 
Chapter1.4
Chapter1.4Chapter1.4
Chapter1.4
 
ppt math6 qt3-wk3.pptx
ppt math6 qt3-wk3.pptxppt math6 qt3-wk3.pptx
ppt math6 qt3-wk3.pptx
 
Algebra 1 week 8 learn it 1
Algebra 1 week 8 learn it 1Algebra 1 week 8 learn it 1
Algebra 1 week 8 learn it 1
 
Solving One Step Equations
Solving One Step Equations Solving One Step Equations
Solving One Step Equations
 
Stanford splash spring 2016 basic programming
Stanford splash spring 2016 basic programmingStanford splash spring 2016 basic programming
Stanford splash spring 2016 basic programming
 

More from Kuppusamy P

Recurrent neural networks rnn
Recurrent neural networks   rnnRecurrent neural networks   rnn
Recurrent neural networks rnn
Kuppusamy P
 
Deep learning
Deep learningDeep learning
Deep learning
Kuppusamy P
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
Kuppusamy P
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
Kuppusamy P
 
Feature detection and matching
Feature detection and matchingFeature detection and matching
Feature detection and matching
Kuppusamy P
 
Image processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filtersImage processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filters
Kuppusamy P
 
Flowchart design for algorithms
Flowchart design for algorithmsFlowchart design for algorithms
Flowchart design for algorithms
Kuppusamy P
 
Algorithm basics
Algorithm basicsAlgorithm basics
Algorithm basics
Kuppusamy P
 
Parts of Computer, Hardware and Software
Parts of Computer, Hardware and Software Parts of Computer, Hardware and Software
Parts of Computer, Hardware and Software
Kuppusamy P
 
Strings in java
Strings in javaStrings in java
Strings in java
Kuppusamy P
 
Java methods or Subroutines or Functions
Java methods or Subroutines or FunctionsJava methods or Subroutines or Functions
Java methods or Subroutines or Functions
Kuppusamy P
 
Java arrays
Java arraysJava arrays
Java arrays
Kuppusamy P
 
Java iterative statements
Java iterative statementsJava iterative statements
Java iterative statements
Kuppusamy P
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
Kuppusamy P
 
Java data types
Java data typesJava data types
Java data types
Kuppusamy P
 
Java introduction
Java introductionJava introduction
Java introduction
Kuppusamy P
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine Learning
Kuppusamy P
 
Anomaly detection (Unsupervised Learning) in Machine Learning
Anomaly detection (Unsupervised Learning) in Machine LearningAnomaly detection (Unsupervised Learning) in Machine Learning
Anomaly detection (Unsupervised Learning) in Machine Learning
Kuppusamy P
 
Machine Learning Performance metrics for classification
Machine Learning Performance metrics for classificationMachine Learning Performance metrics for classification
Machine Learning Performance metrics for classification
Kuppusamy P
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
Kuppusamy P
 

More from Kuppusamy P (20)

Recurrent neural networks rnn
Recurrent neural networks   rnnRecurrent neural networks   rnn
Recurrent neural networks rnn
 
Deep learning
Deep learningDeep learning
Deep learning
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Feature detection and matching
Feature detection and matchingFeature detection and matching
Feature detection and matching
 
Image processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filtersImage processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filters
 
Flowchart design for algorithms
Flowchart design for algorithmsFlowchart design for algorithms
Flowchart design for algorithms
 
Algorithm basics
Algorithm basicsAlgorithm basics
Algorithm basics
 
Parts of Computer, Hardware and Software
Parts of Computer, Hardware and Software Parts of Computer, Hardware and Software
Parts of Computer, Hardware and Software
 
Strings in java
Strings in javaStrings in java
Strings in java
 
Java methods or Subroutines or Functions
Java methods or Subroutines or FunctionsJava methods or Subroutines or Functions
Java methods or Subroutines or Functions
 
Java arrays
Java arraysJava arrays
Java arrays
 
Java iterative statements
Java iterative statementsJava iterative statements
Java iterative statements
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
 
Java data types
Java data typesJava data types
Java data types
 
Java introduction
Java introductionJava introduction
Java introduction
 
Logistic regression in Machine Learning
Logistic regression in Machine LearningLogistic regression in Machine Learning
Logistic regression in Machine Learning
 
Anomaly detection (Unsupervised Learning) in Machine Learning
Anomaly detection (Unsupervised Learning) in Machine LearningAnomaly detection (Unsupervised Learning) in Machine Learning
Anomaly detection (Unsupervised Learning) in Machine Learning
 
Machine Learning Performance metrics for classification
Machine Learning Performance metrics for classificationMachine Learning Performance metrics for classification
Machine Learning Performance metrics for classification
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
 

Recently uploaded

2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 

Recently uploaded (20)

2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 

Problem solving using Programming

  • 1. Problem Solving Dr. Kuppusamy .P Associate Professor / SCOPE Dr. Kuppusamy P
  • 2. Problem Statement 1: Design an algorithm and draw the flow chart to exchange two values. • Let’s consider two glasses denoted A and B with 30 ml mango juice and 50 ml orange juice. Find out the way to exchange the juice in A and B. Dr. Kuppusamy P
  • 3. • Declare variables • Initialize the values Problem Statement 1: Design an algorithm and draw the flow chart to exchange two values. Dr. Kuppusamy P
  • 4. Problem Statement 1: Design an algorithm and draw the flow chart to exchange two values. Move Glass A value 30 to Glass Temp Move Glass B value 50 to Glass A Dr. Kuppusamy P
  • 5. Problem Statement 1: Design an algorithm and draw the flow chart to exchange two values. Move Glass Temp value 30 to Glass B Dr. Kuppusamy P
  • 6. Problem Statement 1: Design an algorithm and draw the flow chart to exchange two values. Algorithm Step 1. Start Step 2. Declare two variables A, B and one more variable temp Step 3. Read the positive numbers to A and B Step 3. temp ← A Step 4. A ← B Step 5. B ← temp Step 6. Display interchanged numbers in A , B Step 7. Stop Dr. Kuppusamy P
  • 7. Problem Statement 1: Design an algorithm and draw the flow chart to exchange two values. Algorithm Step 1. Start Step 2. Declare two variables A, B and one more variable temp Step 3. Read the positive numbers to A and B Step 3. temp ← A Step 4. A ← B Step 5. B ← temp Step 6. Display interchanged numbers in A , B Step 7. Stop Read the positive numbers to A and B temp ← A A ← B B ← temp Display interchanged numbers in A , B Stop Start Declare variables A, B, temp Dr. Kuppusamy P
  • 8. Problem Statement 2: Design an algorithm and draw the flow chart to exchange two values without using temporary variable. Algorithm Step 1. Start Step 2. Declare two variables A, B Step 3. Read the positive numbers as A and B Step 3. A ← A + B Step 4. B ← A - B Step 5. A ← A - B Step 6. Display interchanged numbers in A , B Step 7. Stop E.g. A = 7, B= 5 A = 7 + 5 =12 B = 12-5 =7 A= 12 - 7 =5 Dr. Kuppusamy P
  • 9. Problem Statement 2: Design an algorithm and draw the flow chart to exchange two values without using temporary variable. Algorithm Step 1. Start Step 2. Declare two variables A, B Step 3. Read the positive numbers as A and B Step 3. A ← A + B Step 4. B ← A - B Step 5. A ← A - B Step 6. Display interchanged numbers in A , B Step 7. Stop E.g. A = 7, B= 5 A = 7 + 5 =12 B = 12-5 =7 A= 12 - 7 =5 Read the positive numbers to A and B A ← A + B B ← A - B A ← A - B Display interchanged numbers in A , B Stop Start Declare variables A, B Dr. Kuppusamy P
  • 10. Problem Statement 3: Design an algorithm and draw the flow chart to find the sum of individual digits for the given non negative integer. Step 1. Start Step 2. Declare variable n Step 3. Read non negative integer (n) Step 4. Initialize result ← 0 Step 5. Repeat until n > 0 Step 5.1 result ← result + (n % 10) Step 5.2 n ← n / 10 Step 6. Display result Step 7. Stop E.g. Iteration: 1 n = 76 result = 0 + (76 % 10) n = 76/10 Iteration: 2 n = 7 result = 6 + (7 % 10) n = 7/10 Dr. Kuppusamy P
  • 11. Repeat Yes No Problem Statement 3: Design an algorithm and draw the flow chart to find the sum of individual digits for the given non negative integer. Step 1. Start Step 2. Declare variable n Step 3. Read non negative integer (n) Step 4. Initialize result ← 0 Step 5. Repeat until n > 0 Step 5.1 result ← result + (n % 10) Step 5.2 n ← n / 10 Step 6. Display result Step 7. Stop Read the positive number n result ← result + (n % 10) n ← n / 10 Display the result Stop Start Declare variable n Repeat until n >0 Dr. Kuppusamy P
  • 12. Problem Statement 4: Design an algorithm and draw the flow chart to find the sum of given set of n positive integer. Step 1. Start Step 2. Declare variables n, sum, a, i Step 3. Read total numbers value (n) and ‘n’ positive integers in array ‘a’ Step 4. Initialize sum ← 0 , i ← 0 Step 5. Repeat until i < n Step 5.1 sum ← sum + a[i] Step 5.2 i ← i + 1 Step 6. Display sum Step 7. Stop n = 3 a[] = {2, 3, 4} sum = 0 , i=0 Iteration: 1 sum = 0 + 2 i = i +1 Iteration: 2 sum = 2 + 3 i = i +1 Iteration: 3 sum = 5 + 4 i = i +1 Dr. Kuppusamy P
  • 13. Problem Statement 4: Design an algorithm and draw the flow chart to find the sum of given set of n positive integer. Step 1. Start Step 2. Declare variables n, sum, a Step 3. Read total numbers value (n) and ‘n’ positive integers in array ‘a’ Step 4. Initialize sum ← 0, i ← 0, Step 5. Repeat until i < n Step 5.1 sum ← sum + a[i] Step 5.2 i ← i + 1 Step 6. Display sum Step 7. Stop Repeat Yes No Read total numbers value (n) and ‘n’ integers in array ‘a’ sum ← sum + a[i] i ← i + 1 Display the sum Stop Start Declare variable n, sum, a Repeat until i <n Dr. Kuppusamy P
  • 14. Problem Statement 5: Design an algorithm and draw the flow chart to find the number of digits in given number Sample Input 1: 4582 Sample Output 1: The number of digits in 4582 is 4 Algorithm Step 1. Start Step 2. Declare variables Step 3. Read the input Step 4. Initialize count ← 0 Step 4. Repeat until n !=0 Step 5.1 count ← count + 1 Step 5.2 n ← n / 10 Step 6. Display count Step 7. End Iteration: 1 count = 0 + 1 n= 4582 /10 Iteration: 2 count = 1 + 1 n= 458 /10 Iteration: 3 count = 2 + 1 n= 45 /10 Iteration: 4 count = 3 + 1 n= 4 /10 Iteration: 5 n != 0 → False Dr. Kuppusamy P
  • 15. Problem Statement 6: Design an algorithm and draw the flow chart to find Factorial computation of given number Sample Input 1: 4! Sample Output 1: 24 Step 1. Begin Step 2. Declare variables Step 3. Read the decimal number n Step 4. Initialize fact ← 1, i ← 1 Step 4. if (n != 0) Step 4.1. Repeat until 1 to n Step 4.1.1 fact ← fact * i Step 4.1.2 increment i Step 5. Display fact Step 7. End Iteration: 1 fact = 1 * 1 i = i +1 Iteration: 2 fact = 1 * 2 i = i +1 Iteration: 3 fact = 2 *3 i = i +1 Iteration: 4 fact = 6 * 4 i = i +1 Iteration: 5 i < =n → False Dr. Kuppusamy P
  • 16. Problem Statement 7: Design an algorithm and draw the flow chart to find Sine function computation Step 1. Begin. Step 2. Read the input x and n Step 3. Convert x value to radius using rad ← 3.14/180*x. Step 4. Initialize sum ← rad, sign ← -1. Step 5. Repeat for i ← 3 to n in increment by 2. Step 5.1 power ← pow(rad, i). Step 5.2 factorial ← factorial*(i-1)*i. Step 5.3 result ← power / factorial. Step 5.4 sum ← sum + (sign * result). Step 5.5 k ← k*(-1). Step 6. Display the sum as sine series result. Step 7. End. Dr. Kuppusamy P Repeat Yes No Read the input x and n power ← pow(rad, i). factorial ← factorial*(i-1)*i. result ← power / factorial. sum ← sum + (sign * result). k ← k*(-1) Display the sum Stop Start Declare variable Repeat until i <n Initialize sum, sign
  • 17. Problem Statement 8: Design an algorithm and draw the flow chart to generate Fibonacci sequence Step 1. Begin Step 2. Get Non-negative decimal limit n Step 3. Initialize num1 ← 0, num2 ← 1 Step 4. Display num1 and num2 Step 5. Repeat until 1 to n- 2 Step 5.1 num3 ← num1 + num2 Step 5.2 Display num3 Step 5.3 num1 ← num2 Step 5.4 num2 ← num3 Step 6. End Dr. Kuppusamy P Input : 5 Output: 0, 1, 1, 2, 3, 5
  • 18. Problem Statement 9: Design an algorithm and draw the flow chart to Reverse the digits of an integer Step 1. Begin Step 2. Get Non-negative integer num Step 3. Initialize reversed ← 0 Step 4. Repeat until num > 0 Step 4.1 digit ← n % 10 Step 4.2 reversed ← (reversed * 10) + digit; Step 4.3 num ← num / 10 Step 5. Display reversed Step 6. End Dr. Kuppusamy P Input : 598 Output: 895
  • 19. Problem Statement 10: Design an algorithm and draw the flow chart to Decimal to Binary conversion Step 1. Begin Step 2. Get a Positive decimal number (n) Step 3. Initialize result as null Step 4. if (n > 1) Step 4.1. Repeat until n < 2 Step 4.1.1 Remainder ← n % 2 Step 4.1.2 Append remainder with result Step 4.1.3 n ← n / 2 Step 5. Append n with result Step 6. Display the reverse of result Step 7. End Dr. Kuppusamy P Input : 3 Output: 011 Repeat Yes No Read integer n Remainder ← n % 2 Append remainder with result n ← n / 2 Append n with result Display the reverse of result Stop Start Declare variable Initialize result as null Repeat until n<2
  • 20. References Dr. Kuppusamy P • Herbert Schildt, “Java: The Complete Reference”, McGraw-Hill Education, Tenth edition, 2017. • https://www.sitesbay.com