4- Name: FindMinInArray, Input: T (a sequence of n numbers T[1], T[2], smallest number among them) T[n]), Output: min (the ....

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

electricity and magnetism solve question 4

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.
Instructions:
There will be no oral presentation for this assignment
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. Instructions: There will be no oral presentation for this assignment
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY