subject

2.81: we are running programs on a machine where values of type int are 32 bits. they are represented in two's complement, and they are right shifted arithmetically. values of type unsigned are also 32 bits. we generate arbitrary values x and y, and convert them to unsigned values as follows: /* create some arbitrary values */ int x = random(); int y = random(); /* convert to unsigned */ unsigned ux = (unsigned) x; unsigned uy = (unsigned) y; for each of the following c expressions, you are to indicate whether or not the expression always yields 1. if it always yields 1, describe the underlying mathematical principles. otherwise, give an example of arguments that make it yield 0. (x < y) == (-x > -y) ((x + y) < < 4) + y - x == 17*y + 15*x ~x + ~y + 1 == ~(x+y) (ux - uy) == -(unsigned) (y - x) ((x > > 2) < < 2) < = x

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:00
)a grad student comes up with the following algorithm to sort an array a[1..n] that works by first sorting the first 2/3rds of the array, then sorting the last 2/3rds of the (resulting) array, and finally sorting the first 2/3rds of the new array. 1: function g-sort(a, n) . takes as input an array of n numbers, a[1..n] 2: g-sort-recurse(a, 1, n) 3: end function 4: function g-sort-recurse(a, `, u) 5: if u ⒠` ≤ 0 then 6: return . 1 or fewer elements already sorted 7: else if u ⒠` = 1 then . 2 elements 8: if a[u] < a[`] then . swap values 9: temp ↠a[u] 10: a[u] ↠a[`] 11: a[`] ↠temp 12: end if 13: else . 3 or more elements 14: size ↠u ⒠` + 1 15: twothirds ↠d(2 ◠size)/3e 16: g-sort-recurse(a, `, ` + twothirds ⒠1) 17: g-sort-recurse(a, u ⒠twothirds + 1, u) 18: g-sort-recurse(a, `, ` + twothirds ⒠1) 19: end if 20: end function first (5 pts), prove that the algorithm correctly sorts the numbers in the array (in increasing order). after showing that it correctly sorts 1 and 2 element intervals, you may make the (incorrect) assumption that the number of elements being passed to g-sort-recurse is always a multiple of 3 to simplify the notation (and drop the floors/ceilings).
Answers: 3
question
Computers and Technology, 22.06.2019 06:30
This technology is used to produce high-quality documents that look good on the computer screen and in print. wiki presentation paint desktop publishing
Answers: 3
question
Computers and Technology, 22.06.2019 22:00
What is a distinguishing feature of today’s graphic application software?) graphic applications are used today on a variety of devices, including touch-screen kiosks and mobile phones.
Answers: 3
question
Computers and Technology, 23.06.2019 15:00
Plz ( which is an example of a good url?
Answers: 1
You know the right answer?
2.81: we are running programs on a machine where values of type int are 32 bits. they are represent...
Questions
question
Mathematics, 20.09.2020 04:01
question
Mathematics, 20.09.2020 04:01
question
Social Studies, 20.09.2020 04:01
question
Chemistry, 20.09.2020 04:01
question
Mathematics, 20.09.2020 04:01
Questions on the website: 13722359