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 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

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

Program this

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 2 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
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