SlideShare uma empresa Scribd logo
1 de 12
Chapter 1
Problem Solving Algorithms
Ragia A. Ibrahim, Ph.D. Student
1
‫القاهرة‬ ‫جامعة‬
‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬
‫مركز‬‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬
Solving Problem Activities
1. Define The problem.
2. Analyze the problem
Analyze
Define
Develop An Algorithm
Write A program
Test & Debug
3. Develop an algorithm for solving the problem
4. Write program corresponding to the algorithm.
5. Test and Debug the program
By: Ragia Ibrahim 2
‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬
‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
What is an Algorithm?
A Set of instructions that if followed, will produce a
solution for a given problem. Algorithm instructions should
be written in a form that would be easily converted into
computer instructions.
By: Ragia Ibrahim 3
‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬
‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
Computer instructions categories
Input
Processing
Output
Memory
DATA
e.g. Salary
Associated
Memory
Location
e.g. Float S
Insert : cin>>S
Output: cout<<S;
By: Ragia Ibrahim 4
‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬
‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
Flowchart Symbols, Example.
Start OR End
Input Data
Condition
Print output
Process
By: Ragia Ibrahim 5
‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬
‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
Example1
Convert from Square meter to square yard: 1 Square yard=1.196 Square meter
Stop
Start
“Enter Square
Meters”
Store
Value
In M
Y=M*1.196
Print Y
By: Ragia Ibrahim 6
‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬
‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
Example2
Find the Largest
number Among three
Numbers
Stop
Start
“Enter three Numbers”
Store Value In
X, Y, Z
Print L
By: Ragia Ibrahim 7
IF X>Y L=X
IF Z>L
L=Y
L=Z
‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬
‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
Example3
Find the reminder
and quotient upon
dividing non
negative integer by
a positive integer.
Stop
Start
“Enter dividend and divider”
Store Value In
X, Y
Print Value of R, Q
By: Ragia Ibrahim 8
IF
R>=Y
R=X
Q=0
R=R-Y
Q=Q+1
‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬
‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
9
‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬
‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
10
Q1
Start
“Enter pair of integers”
Store Value In
X, Y
IF
y mod
y=x
false
true
End‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬
‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬
‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
11
Q2
A perfect number is a positive integer that is
equal to the sum of its proper positive
divisors, that is, the sum of its positive
divisors excluding the number itself
Example:
Factors of 6 are 1,2,3
1+2+3 = 6
Factors of 28 are 1,2,4,7,14
1+2+4+7+14=28
Stop
Start
“Enter Positive Integer Number”
Store Value In
N
Print “Not perfect”
f<= N/2
Sum=0
f=1
F=f+1
Sum=Sum+f
N mod f=0
s=n
Print “perfect”
‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬
‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
12
Q3 Start
“Enter Positive Integer Number”
Store Value In
N
i<n
i=2
prime= true
i++
prime= false
n mod i = 0
print prime
Stop

Mais conteúdo relacionado

Destaque

R programming Fundamentals
R programming  FundamentalsR programming  Fundamentals
R programming FundamentalsRagia Ibrahim
 
Palm oil processing machine line
Palm oil processing machine linePalm oil processing machine line
Palm oil processing machine lineMarymei
 
Che323 l1.1 palm oil milling &amp; refining mii
Che323 l1.1 palm oil milling &amp; refining miiChe323 l1.1 palm oil milling &amp; refining mii
Che323 l1.1 palm oil milling &amp; refining miisjobli74
 
2016-05-Malaysia Palm Oil Mill Value Map public
2016-05-Malaysia Palm Oil Mill Value Map public2016-05-Malaysia Palm Oil Mill Value Map public
2016-05-Malaysia Palm Oil Mill Value Map publicLennart Nilsson
 
Palm Oil Mill Waste Utilization (biogas, biomass briquette, biomass gasificat...
Palm Oil Mill Waste Utilization (biogas, biomass briquette, biomass gasificat...Palm Oil Mill Waste Utilization (biogas, biomass briquette, biomass gasificat...
Palm Oil Mill Waste Utilization (biogas, biomass briquette, biomass gasificat...Tara F Khaira
 
Sustainable Approach Of Recycling Palm Oil Mill Effluent Using Integrated Bio...
Sustainable Approach Of Recycling Palm Oil Mill Effluent Using Integrated Bio...Sustainable Approach Of Recycling Palm Oil Mill Effluent Using Integrated Bio...
Sustainable Approach Of Recycling Palm Oil Mill Effluent Using Integrated Bio...SAJJAD KHUDHUR ABBAS
 
Palm Oil, Palm Kernel Oil Process - Fractions, Derivatives and Product Uses
Palm Oil, Palm Kernel Oil Process - Fractions, Derivatives and Product UsesPalm Oil, Palm Kernel Oil Process - Fractions, Derivatives and Product Uses
Palm Oil, Palm Kernel Oil Process - Fractions, Derivatives and Product UsesGreenPalm
 
Version Control With GitHub & RStudio
Version Control With GitHub & RStudioVersion Control With GitHub & RStudio
Version Control With GitHub & RStudioRsquared Academy
 
Step by Step Guidance to Study Abroad
Step by Step Guidance to Study AbroadStep by Step Guidance to Study Abroad
Step by Step Guidance to Study AbroadSamaa Hazem Hosny
 
R Programming: First Steps
R Programming: First StepsR Programming: First Steps
R Programming: First StepsRsquared Academy
 
R programming intro with examples
R programming intro with examplesR programming intro with examples
R programming intro with examplesDennis
 
Policy on Protection and Management of Peatland Ecosystem in Indonesia
Policy on Protection and Management of Peatland Ecosystem in IndonesiaPolicy on Protection and Management of Peatland Ecosystem in Indonesia
Policy on Protection and Management of Peatland Ecosystem in IndonesiaGlobalEnvironmentCentre
 
Wiring diagrams and ladder logic
Wiring diagrams and ladder logicWiring diagrams and ladder logic
Wiring diagrams and ladder logicCPX
 
Peatlands, carbon and climate change
Peatlands, carbon and climate changePeatlands, carbon and climate change
Peatlands, carbon and climate changeecosystemsclimate
 
R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to MatricesRsquared Academy
 
Digital Mapping of Peat soils in Indonesia
Digital Mapping of Peat soils in IndonesiaDigital Mapping of Peat soils in Indonesia
Digital Mapping of Peat soils in IndonesiaBudiman Minasny
 
Introduction to palm oil processing
Introduction to palm oil processingIntroduction to palm oil processing
Introduction to palm oil processingCPX
 
Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...
Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...
Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...Revolution Analytics
 

Destaque (20)

R programming Fundamentals
R programming  FundamentalsR programming  Fundamentals
R programming Fundamentals
 
Optimal palm oil mill plant layout
Optimal palm oil mill plant layoutOptimal palm oil mill plant layout
Optimal palm oil mill plant layout
 
Palm oil processing machine line
Palm oil processing machine linePalm oil processing machine line
Palm oil processing machine line
 
Che323 l1.1 palm oil milling &amp; refining mii
Che323 l1.1 palm oil milling &amp; refining miiChe323 l1.1 palm oil milling &amp; refining mii
Che323 l1.1 palm oil milling &amp; refining mii
 
2016-05-Malaysia Palm Oil Mill Value Map public
2016-05-Malaysia Palm Oil Mill Value Map public2016-05-Malaysia Palm Oil Mill Value Map public
2016-05-Malaysia Palm Oil Mill Value Map public
 
Palm Oil Mill Waste Utilization (biogas, biomass briquette, biomass gasificat...
Palm Oil Mill Waste Utilization (biogas, biomass briquette, biomass gasificat...Palm Oil Mill Waste Utilization (biogas, biomass briquette, biomass gasificat...
Palm Oil Mill Waste Utilization (biogas, biomass briquette, biomass gasificat...
 
Sustainable Approach Of Recycling Palm Oil Mill Effluent Using Integrated Bio...
Sustainable Approach Of Recycling Palm Oil Mill Effluent Using Integrated Bio...Sustainable Approach Of Recycling Palm Oil Mill Effluent Using Integrated Bio...
Sustainable Approach Of Recycling Palm Oil Mill Effluent Using Integrated Bio...
 
Palm Oil, Palm Kernel Oil Process - Fractions, Derivatives and Product Uses
Palm Oil, Palm Kernel Oil Process - Fractions, Derivatives and Product UsesPalm Oil, Palm Kernel Oil Process - Fractions, Derivatives and Product Uses
Palm Oil, Palm Kernel Oil Process - Fractions, Derivatives and Product Uses
 
Version Control With GitHub & RStudio
Version Control With GitHub & RStudioVersion Control With GitHub & RStudio
Version Control With GitHub & RStudio
 
Step by Step Guidance to Study Abroad
Step by Step Guidance to Study AbroadStep by Step Guidance to Study Abroad
Step by Step Guidance to Study Abroad
 
R program
R programR program
R program
 
R Programming: First Steps
R Programming: First StepsR Programming: First Steps
R Programming: First Steps
 
R programming intro with examples
R programming intro with examplesR programming intro with examples
R programming intro with examples
 
Policy on Protection and Management of Peatland Ecosystem in Indonesia
Policy on Protection and Management of Peatland Ecosystem in IndonesiaPolicy on Protection and Management of Peatland Ecosystem in Indonesia
Policy on Protection and Management of Peatland Ecosystem in Indonesia
 
Wiring diagrams and ladder logic
Wiring diagrams and ladder logicWiring diagrams and ladder logic
Wiring diagrams and ladder logic
 
Peatlands, carbon and climate change
Peatlands, carbon and climate changePeatlands, carbon and climate change
Peatlands, carbon and climate change
 
R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to Matrices
 
Digital Mapping of Peat soils in Indonesia
Digital Mapping of Peat soils in IndonesiaDigital Mapping of Peat soils in Indonesia
Digital Mapping of Peat soils in Indonesia
 
Introduction to palm oil processing
Introduction to palm oil processingIntroduction to palm oil processing
Introduction to palm oil processing
 
Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...
Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...
Getting Up to Speed with R: Certificate Program in R for Statistical Analysis...
 

Semelhante a Chapter 1

Semelhante a Chapter 1 (6)

Six sigma presentation
Six sigma presentationSix sigma presentation
Six sigma presentation
 
شرح الوحدة الرابعة
شرح الوحدة الرابعةشرح الوحدة الرابعة
شرح الوحدة الرابعة
 
شرح الوحدة الرابعة
شرح الوحدة الرابعةشرح الوحدة الرابعة
شرح الوحدة الرابعة
 
شرح الوحدة الرابعة
شرح الوحدة الرابعةشرح الوحدة الرابعة
شرح الوحدة الرابعة
 
ف 1 الدرس الثانى
ف 1 الدرس الثانىف 1 الدرس الثانى
ف 1 الدرس الثانى
 
Final (1)
Final (1)Final (1)
Final (1)
 

Último

التعلم المؤسسي في المؤسسات الأكاديمية. pptx
التعلم المؤسسي في المؤسسات الأكاديمية. pptxالتعلم المؤسسي في المؤسسات الأكاديمية. pptx
التعلم المؤسسي في المؤسسات الأكاديمية. pptxyjana1298
 
الفعل الصحيح والفعل المعتل ونواعه لفيف نقص .ppt
الفعل الصحيح والفعل المعتل ونواعه لفيف نقص .pptالفعل الصحيح والفعل المعتل ونواعه لفيف نقص .ppt
الفعل الصحيح والفعل المعتل ونواعه لفيف نقص .pptNaeema18
 
التنمية المستدامة والمكتبات الاكاديمية.pptx
التنمية المستدامة والمكتبات الاكاديمية.pptxالتنمية المستدامة والمكتبات الاكاديمية.pptx
التنمية المستدامة والمكتبات الاكاديمية.pptxJoudyHaydar
 
أمثلة عن قضية السرقات الشعريه والانتحال في الشعر
أمثلة عن قضية السرقات الشعريه والانتحال في الشعرأمثلة عن قضية السرقات الشعريه والانتحال في الشعر
أمثلة عن قضية السرقات الشعريه والانتحال في الشعرneamam383
 
التعليم في عصر الذكاء الاصطناعي مواطن التحدي ومناهل الفرص _.pdf
التعليم في عصر الذكاء الاصطناعي مواطن التحدي ومناهل الفرص _.pdfالتعليم في عصر الذكاء الاصطناعي مواطن التحدي ومناهل الفرص _.pdf
التعليم في عصر الذكاء الاصطناعي مواطن التحدي ومناهل الفرص _.pdfNaseej Academy أكاديمية نسيج
 
الخرائط الموضوعاتية وتحليلية - المحاضرة الثالثة.pdf
الخرائط الموضوعاتية وتحليلية - المحاضرة الثالثة.pdfالخرائط الموضوعاتية وتحليلية - المحاضرة الثالثة.pdf
الخرائط الموضوعاتية وتحليلية - المحاضرة الثالثة.pdfabdomjido9
 
وزارة التربية دورة استراتيجيات التعلم النشط -.ppt
وزارة التربية دورة استراتيجيات التعلم النشط -.pptوزارة التربية دورة استراتيجيات التعلم النشط -.ppt
وزارة التربية دورة استراتيجيات التعلم النشط -.pptAdamIdiris
 
درس الطباقالمحسنات المعنويّة، بهدف تحسين المعنى .pptx
درس الطباقالمحسنات المعنويّة، بهدف تحسين المعنى .pptxدرس الطباقالمحسنات المعنويّة، بهدف تحسين المعنى .pptx
درس الطباقالمحسنات المعنويّة، بهدف تحسين المعنى .pptxNaceraLAHOUEL1
 
الوعي المعلوماتي للعاملين في المكتبات و مراكز المعلومات.pptx
الوعي المعلوماتي للعاملين في المكتبات و مراكز المعلومات.pptxالوعي المعلوماتي للعاملين في المكتبات و مراكز المعلومات.pptx
الوعي المعلوماتي للعاملين في المكتبات و مراكز المعلومات.pptxMohamadAljaafari
 
مدخل لعلم الارشاد السياحي الفصل الاول.pptx
مدخل لعلم الارشاد السياحي الفصل الاول.pptxمدخل لعلم الارشاد السياحي الفصل الاول.pptx
مدخل لعلم الارشاد السياحي الفصل الاول.pptxtourismistchristenaa
 
مخطط رياضيات .مخطط الفترة 4 و 5 رياضيات سنة سادسة6.docx
مخطط رياضيات .مخطط الفترة 4 و 5 رياضيات سنة سادسة6.docxمخطط رياضيات .مخطط الفترة 4 و 5 رياضيات سنة سادسة6.docx
مخطط رياضيات .مخطط الفترة 4 و 5 رياضيات سنة سادسة6.docxouassam
 
في قضية اللفظ والمعني والبعض من آراء العلماء
في قضية اللفظ والمعني والبعض من آراء العلماءفي قضية اللفظ والمعني والبعض من آراء العلماء
في قضية اللفظ والمعني والبعض من آراء العلماءneamam383
 
أهمية كرة القدم ومخاطر التعصب الكروي وعلاجه
أهمية كرة القدم ومخاطر التعصب الكروي وعلاجهأهمية كرة القدم ومخاطر التعصب الكروي وعلاجه
أهمية كرة القدم ومخاطر التعصب الكروي وعلاجهneamam383
 
نشأة القضية الفلسطينية وتطورها التاريخي .pptx
نشأة القضية الفلسطينية وتطورها التاريخي .pptxنشأة القضية الفلسطينية وتطورها التاريخي .pptx
نشأة القضية الفلسطينية وتطورها التاريخي .pptxNaceraLAHOUEL1
 
أنواع الحياة والاغراض الشعرية في العصر الجاهلي
أنواع الحياة والاغراض الشعرية في العصر الجاهليأنواع الحياة والاغراض الشعرية في العصر الجاهلي
أنواع الحياة والاغراض الشعرية في العصر الجاهليneamam383
 
إسنــــاد الأفعال. إلى الضمائر.pptx
إسنــــاد الأفعال.    إلى الضمائر.pptxإسنــــاد الأفعال.    إلى الضمائر.pptx
إسنــــاد الأفعال. إلى الضمائر.pptxssusere01cf5
 

Último (16)

التعلم المؤسسي في المؤسسات الأكاديمية. pptx
التعلم المؤسسي في المؤسسات الأكاديمية. pptxالتعلم المؤسسي في المؤسسات الأكاديمية. pptx
التعلم المؤسسي في المؤسسات الأكاديمية. pptx
 
الفعل الصحيح والفعل المعتل ونواعه لفيف نقص .ppt
الفعل الصحيح والفعل المعتل ونواعه لفيف نقص .pptالفعل الصحيح والفعل المعتل ونواعه لفيف نقص .ppt
الفعل الصحيح والفعل المعتل ونواعه لفيف نقص .ppt
 
التنمية المستدامة والمكتبات الاكاديمية.pptx
التنمية المستدامة والمكتبات الاكاديمية.pptxالتنمية المستدامة والمكتبات الاكاديمية.pptx
التنمية المستدامة والمكتبات الاكاديمية.pptx
 
أمثلة عن قضية السرقات الشعريه والانتحال في الشعر
أمثلة عن قضية السرقات الشعريه والانتحال في الشعرأمثلة عن قضية السرقات الشعريه والانتحال في الشعر
أمثلة عن قضية السرقات الشعريه والانتحال في الشعر
 
التعليم في عصر الذكاء الاصطناعي مواطن التحدي ومناهل الفرص _.pdf
التعليم في عصر الذكاء الاصطناعي مواطن التحدي ومناهل الفرص _.pdfالتعليم في عصر الذكاء الاصطناعي مواطن التحدي ومناهل الفرص _.pdf
التعليم في عصر الذكاء الاصطناعي مواطن التحدي ومناهل الفرص _.pdf
 
الخرائط الموضوعاتية وتحليلية - المحاضرة الثالثة.pdf
الخرائط الموضوعاتية وتحليلية - المحاضرة الثالثة.pdfالخرائط الموضوعاتية وتحليلية - المحاضرة الثالثة.pdf
الخرائط الموضوعاتية وتحليلية - المحاضرة الثالثة.pdf
 
وزارة التربية دورة استراتيجيات التعلم النشط -.ppt
وزارة التربية دورة استراتيجيات التعلم النشط -.pptوزارة التربية دورة استراتيجيات التعلم النشط -.ppt
وزارة التربية دورة استراتيجيات التعلم النشط -.ppt
 
درس الطباقالمحسنات المعنويّة، بهدف تحسين المعنى .pptx
درس الطباقالمحسنات المعنويّة، بهدف تحسين المعنى .pptxدرس الطباقالمحسنات المعنويّة، بهدف تحسين المعنى .pptx
درس الطباقالمحسنات المعنويّة، بهدف تحسين المعنى .pptx
 
الوعي المعلوماتي للعاملين في المكتبات و مراكز المعلومات.pptx
الوعي المعلوماتي للعاملين في المكتبات و مراكز المعلومات.pptxالوعي المعلوماتي للعاملين في المكتبات و مراكز المعلومات.pptx
الوعي المعلوماتي للعاملين في المكتبات و مراكز المعلومات.pptx
 
مدخل لعلم الارشاد السياحي الفصل الاول.pptx
مدخل لعلم الارشاد السياحي الفصل الاول.pptxمدخل لعلم الارشاد السياحي الفصل الاول.pptx
مدخل لعلم الارشاد السياحي الفصل الاول.pptx
 
مخطط رياضيات .مخطط الفترة 4 و 5 رياضيات سنة سادسة6.docx
مخطط رياضيات .مخطط الفترة 4 و 5 رياضيات سنة سادسة6.docxمخطط رياضيات .مخطط الفترة 4 و 5 رياضيات سنة سادسة6.docx
مخطط رياضيات .مخطط الفترة 4 و 5 رياضيات سنة سادسة6.docx
 
في قضية اللفظ والمعني والبعض من آراء العلماء
في قضية اللفظ والمعني والبعض من آراء العلماءفي قضية اللفظ والمعني والبعض من آراء العلماء
في قضية اللفظ والمعني والبعض من آراء العلماء
 
أهمية كرة القدم ومخاطر التعصب الكروي وعلاجه
أهمية كرة القدم ومخاطر التعصب الكروي وعلاجهأهمية كرة القدم ومخاطر التعصب الكروي وعلاجه
أهمية كرة القدم ومخاطر التعصب الكروي وعلاجه
 
نشأة القضية الفلسطينية وتطورها التاريخي .pptx
نشأة القضية الفلسطينية وتطورها التاريخي .pptxنشأة القضية الفلسطينية وتطورها التاريخي .pptx
نشأة القضية الفلسطينية وتطورها التاريخي .pptx
 
أنواع الحياة والاغراض الشعرية في العصر الجاهلي
أنواع الحياة والاغراض الشعرية في العصر الجاهليأنواع الحياة والاغراض الشعرية في العصر الجاهلي
أنواع الحياة والاغراض الشعرية في العصر الجاهلي
 
إسنــــاد الأفعال. إلى الضمائر.pptx
إسنــــاد الأفعال.    إلى الضمائر.pptxإسنــــاد الأفعال.    إلى الضمائر.pptx
إسنــــاد الأفعال. إلى الضمائر.pptx
 

Chapter 1

  • 1. Chapter 1 Problem Solving Algorithms Ragia A. Ibrahim, Ph.D. Student 1 ‫القاهرة‬ ‫جامعة‬ ‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫مركز‬‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬
  • 2. Solving Problem Activities 1. Define The problem. 2. Analyze the problem Analyze Define Develop An Algorithm Write A program Test & Debug 3. Develop an algorithm for solving the problem 4. Write program corresponding to the algorithm. 5. Test and Debug the program By: Ragia Ibrahim 2 ‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬ ‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
  • 3. What is an Algorithm? A Set of instructions that if followed, will produce a solution for a given problem. Algorithm instructions should be written in a form that would be easily converted into computer instructions. By: Ragia Ibrahim 3 ‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬ ‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
  • 4. Computer instructions categories Input Processing Output Memory DATA e.g. Salary Associated Memory Location e.g. Float S Insert : cin>>S Output: cout<<S; By: Ragia Ibrahim 4 ‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬ ‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
  • 5. Flowchart Symbols, Example. Start OR End Input Data Condition Print output Process By: Ragia Ibrahim 5 ‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬ ‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
  • 6. Example1 Convert from Square meter to square yard: 1 Square yard=1.196 Square meter Stop Start “Enter Square Meters” Store Value In M Y=M*1.196 Print Y By: Ragia Ibrahim 6 ‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬ ‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
  • 7. Example2 Find the Largest number Among three Numbers Stop Start “Enter three Numbers” Store Value In X, Y, Z Print L By: Ragia Ibrahim 7 IF X>Y L=X IF Z>L L=Y L=Z ‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬ ‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
  • 8. Example3 Find the reminder and quotient upon dividing non negative integer by a positive integer. Stop Start “Enter dividend and divider” Store Value In X, Y Print Value of R, Q By: Ragia Ibrahim 8 IF R>=Y R=X Q=0 R=R-Y Q=Q+1 ‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬ ‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
  • 9. 9 ‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬ ‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
  • 10. 10 Q1 Start “Enter pair of integers” Store Value In X, Y IF y mod y=x false true End‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬ ‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬
  • 11. ‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬ ‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬ 11 Q2 A perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself Example: Factors of 6 are 1,2,3 1+2+3 = 6 Factors of 28 are 1,2,4,7,14 1+2+4+7+14=28 Stop Start “Enter Positive Integer Number” Store Value In N Print “Not perfect” f<= N/2 Sum=0 f=1 F=f+1 Sum=Sum+f N mod f=0 s=n Print “perfect”
  • 12. ‫االحصائيه‬ ‫والبحوث‬ ‫الدراسات‬ ‫معهد‬ ‫القاهرة‬ ‫جامعة‬ ‫والبرمجيات‬ ‫المعلومات‬ ‫قواعد‬ ‫بحوث‬ ‫مركز‬ 12 Q3 Start “Enter Positive Integer Number” Store Value In N i<n i=2 prime= true i++ prime= false n mod i = 0 print prime Stop