×
Log in to StudySoup
Get Full Access to Math - Textbook Survival Guide
Join StudySoup for FREE
Get Full Access to Math - Textbook Survival Guide

a) Show that this algorithm determines the number of 1

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

Solution for problem 10E Chapter 3.3

Discrete Mathematics and Its Applications | 7th Edition

  • Textbook Solutions
  • 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 1 272 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: 7
Author: Kenneth Rosen
ISBN: 9780073383095

Unlock Textbook Solution

Enter your email below to unlock your verified solution to:

a) Show that this algorithm determines the number of 1

×
Log in to StudySoup
Get Full Access to Math - Textbook Survival Guide
Join StudySoup for FREE
Get Full Access to Math - Textbook Survival Guide
×
Reset your password