a) Show that this algorithm determines the number of 1

Discrete Mathematics and Its Applications | 7th Edition | ISBN: 9780073383095 | Authors: Kenneth Rosen

Problem 10E Chapter 3.3

Discrete Mathematics and Its Applications | 7th Edition

  • 2901 Step-by-step solutions solved by professors and subject experts
  • Get 24/7 help from StudySoup virtual teaching assistants
Discrete Mathematics and Its Applications | 7th Edition | ISBN: 9780073383095 | Authors: Kenneth Rosen

Discrete Mathematics and Its Applications | 7th Edition

4 5 0 262 Reviews
12
0
Problem 10E

a) Show that this algorithm determines the number of 1 bits in the bit string S:

procedure bit count(S: bit string)

count := 0

while S ≠ 0

count := count + 1

S := S ˄ (S − 1)

return count {count is the number of 1s in S}

Here S − 1 is the bit string obtained by changing the rightmost 1 bit of S to a 0 and all the 0 bi Is to t he right of this to 1s. [Recall that S ˄ (S − 1) is the bitwise AND of S and S − 1.]

b) How many bitwise AND operations are needed to find the number of 1 bits in a string S using the algorithm in pan (a)?

Step-by-Step Solution:

Solution:Step 1</p>

In this problem we need to show that the given algorithm counts the number of 1’s in a bit string. We also need to find the number of AND operations are computed to find the number of 1 bits in a bit string using the given algorithm.

Step 2 of 2

Chapter 3.3, Problem 10E is Solved
Textbook: Discrete Mathematics and Its Applications
Edition: 7th
Author: Kenneth Rosen
ISBN: 9780073383095

×
Log in to StudySoup
Get Full Access to Discrete Mathematics And Its Applications - 7th Edition - Chapter 3.3 - Problem 10e

Forgot password? Reset password here

Join StudySoup for FREE
Get Full Access to Discrete Mathematics And Its Applications - 7th Edition - Chapter 3.3 - Problem 10e
Join with Email
Already have an account? Login here
Reset your password

I don't want to reset my password

Need help? Contact support

Need an Account? Is not associated with an account
Sign up
We're here to help

Having trouble accessing your account? Let us help you, contact support at +1(510) 944-1054 or support@studysoup.com

Got it, thanks!
Password Reset Request Sent An email has been sent to the email address associated to your account. Follow the link in the email to reset your password. If you're having trouble finding our email please check your spam folder
Got it, thanks!
Already have an Account? Is already in use
Log in
Incorrect Password The password used to log in with this account is incorrect
Try Again

Forgot password? Reset it here