4- Name: FindMinInArray, Input: T (a sequence of n numbers T[1], T[2], ., T[n]), Output: min (the smallest number among them) 5- Name: SumDigits, Input: N (Two digit number), Output: sum (the sum of digits of N) 6- Name: GreatestCommonDivisor (simple, iterative algorithm), Input: x, y (two natural numbers), Output: w (Greatest Common Divisor of x and v) ....

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

solve questions 4, 5 and 6 please

Directions:
Implement the following in C++ and show the output of your code for at least two instances of the problem (All
examples come from "1.1 Introduction - Part II")
1- Name: Prime, Input: n (an integer number), Output: Prime or not prime
2- Name: SumOfNumbers, Input: n (positive integer), Output: sum (sum of all positive integers from 1 to n)
3- Name: ConvertPoundToKg, Input: weight-in-pounds (weight in pound), Output: weight-in-Kg (weight in
Kg)
4- Name: FindMinInArray, Input: T (a sequence of n numbers T[1], T[2], .., T[n]), Output: min (the
smallest number among them)
5- Name: SumDigits, Input: N (Two digit number), Output: sum (the sum of digits of N)
6- Name: GreatestCommonDivisor (simple, iterative algorithm), Input: x, y (two natural numbers), Output:
w (Greatest Common Divisor of x and y)
7- Name: EuclidGreatestCommonDivisor (Euclid's algorithm, do not use the recursive version), Input: x, y
(two natural numbers), Output: w (Greatest Common Divisor of x and y)
Trace your greatest common divisor programs for 5 iterations (problems 6 and 7), you can hand trace the code or
simply output the values from your code.
Compare the performance of the algorithms you used in problems 6 and 7.
Give an alternative algorithm for the primality test you implemented above (problem 1), describe your alternative
algorithm (you can use code or pseudocode), and compare the performance of the two algorithms.
Transcribed Image Text:Directions: Implement the following in C++ and show the output of your code for at least two instances of the problem (All examples come from "1.1 Introduction - Part II") 1- Name: Prime, Input: n (an integer number), Output: Prime or not prime 2- Name: SumOfNumbers, Input: n (positive integer), Output: sum (sum of all positive integers from 1 to n) 3- Name: ConvertPoundToKg, Input: weight-in-pounds (weight in pound), Output: weight-in-Kg (weight in Kg) 4- Name: FindMinInArray, Input: T (a sequence of n numbers T[1], T[2], .., T[n]), Output: min (the smallest number among them) 5- Name: SumDigits, Input: N (Two digit number), Output: sum (the sum of digits of N) 6- Name: GreatestCommonDivisor (simple, iterative algorithm), Input: x, y (two natural numbers), Output: w (Greatest Common Divisor of x and y) 7- Name: EuclidGreatestCommonDivisor (Euclid's algorithm, do not use the recursive version), Input: x, y (two natural numbers), Output: w (Greatest Common Divisor of x and y) Trace your greatest common divisor programs for 5 iterations (problems 6 and 7), you can hand trace the code or simply output the values from your code. Compare the performance of the algorithms you used in problems 6 and 7. Give an alternative algorithm for the primality test you implemented above (problem 1), describe your alternative algorithm (you can use code or pseudocode), and compare the performance of the two algorithms.
Expert Solution
steps

Step by step

Solved in 6 steps with 9 images

Blurred answer
Knowledge Booster
Matrix multiplication
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education