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
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
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff2a7fc4c-c2bd-4ff5-a7dc-748575e16c0c%2F7ebfb259-e89e-4ba2-8cbe-0d5ad6434e2f%2F3keznx_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education