2 Chapter 2 Exercise: Implementing Loops 1. You may use the source code template in h3.s found in the assignment zip archive as a starting point. Let lower and upper be two positive integers with 1 ≤ lower, upper ≤ 10³ and lower ≤ upper. Let a and b be two positive integers with lower ≤ a,b ≤ upper and a ≤ b. Let x =a b. For all pairs of a and b satisfying the specified conditions, find and print the maximal value of x. For example, suppose lower = 10₁0 and upper = 1310- The algorithm will compute x for each a, b pair where 1010 max then max - x end for end for return max end function max_xor function main ( unsigned int lower, max, upper SysPrintStr ("Enter lower?") lower SysReadInt() SysPrintStr ("Enter upper?") upper- SysReadInt () max-max_xor (lower, upper) SysPrintInt (max) SysExit ( end function main

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

Don't give copy paste

2 Chapter 2 Exercise: Implementing Loops
1. You may use the source code template in h3.s found in the assignment zip archive as a starting point. Let lower and
upper be two positive integers with 1 ≤ lower, upper ≤ 10³ and lower ≤ upper. Let a and b be two positive integers with lower
≤ a,b ≤ upper and a ≤ b. Let x =ab. For all pairs of a and b satisfying the specified conditions, find and print the maximal
value of x. For example, suppose lower = 10₁0 and upper = 1310. The algorithm will compute x for each a, b pair where 1010
<a,b≤13₁0 anda<b,
x = 1010 1010 1010₂1010₂=0000₂ 010x = 1010 01110101021011₂=0001₂= 110x= 1010 12 10 = 1010₂1100₂ =
0110₂=610x = 1010 1310 = 101021101₂-0111₂ = 710 X = 11101110 1011₂01011₂ - 0000₂= 010x = 11101210 = 1011₂2
1100₂ 0111₂= 710x = 1110 13 ₁0 = 1011₂1101₂= 0110₂= 6₁0x = 1210 1210 1100₂1100₂ = 0000₂=0₁0x=12101310
= 1100₂1101₂=0001₂= 110x = 1310 13 10 = 110121101₂ = 0000₂ 010
The maximal value of x is 7 when a, b = 1010, 13₁0 and a, b = 1110, 1210- The output from the program should be 7. Here is the
pseudocode for the algorithm which solves this problem,
function max_xor (lower: unsigned int, upper: unsigned int) → unsigned int unsigned int a, b, max, x
max - 0
for a lower to upper do
for b - a to
do x+a+b
if x > max then max-x end for
end for
return max
end function max_xor
function main (
unsigned int lower, max, upper SysPrintStr ("Enter lower? ") lower SysReadInt() SysPrintStr ("Enter upper? ") upper -
SysReadInt ()
max max_xor (lower, upper) SysPrintInt (max)
SysExit (
end function main
Transcribed Image Text:2 Chapter 2 Exercise: Implementing Loops 1. You may use the source code template in h3.s found in the assignment zip archive as a starting point. Let lower and upper be two positive integers with 1 ≤ lower, upper ≤ 10³ and lower ≤ upper. Let a and b be two positive integers with lower ≤ a,b ≤ upper and a ≤ b. Let x =ab. For all pairs of a and b satisfying the specified conditions, find and print the maximal value of x. For example, suppose lower = 10₁0 and upper = 1310. The algorithm will compute x for each a, b pair where 1010 <a,b≤13₁0 anda<b, x = 1010 1010 1010₂1010₂=0000₂ 010x = 1010 01110101021011₂=0001₂= 110x= 1010 12 10 = 1010₂1100₂ = 0110₂=610x = 1010 1310 = 101021101₂-0111₂ = 710 X = 11101110 1011₂01011₂ - 0000₂= 010x = 11101210 = 1011₂2 1100₂ 0111₂= 710x = 1110 13 ₁0 = 1011₂1101₂= 0110₂= 6₁0x = 1210 1210 1100₂1100₂ = 0000₂=0₁0x=12101310 = 1100₂1101₂=0001₂= 110x = 1310 13 10 = 110121101₂ = 0000₂ 010 The maximal value of x is 7 when a, b = 1010, 13₁0 and a, b = 1110, 1210- The output from the program should be 7. Here is the pseudocode for the algorithm which solves this problem, function max_xor (lower: unsigned int, upper: unsigned int) → unsigned int unsigned int a, b, max, x max - 0 for a lower to upper do for b - a to do x+a+b if x > max then max-x end for end for return max end function max_xor function main ( unsigned int lower, max, upper SysPrintStr ("Enter lower? ") lower SysReadInt() SysPrintStr ("Enter upper? ") upper - SysReadInt () max max_xor (lower, upper) SysPrintInt (max) SysExit ( end function main
Expert Solution
steps

Step by step

Solved in 3 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