Write functions for computing union, intersection, and set difference on arbitrarily long bit vectors used to represent
Question:
Write functions for computing union, intersection, and set difference on arbitrarily long bit vectors used to represent set membership as described in Section 9.3. Assume that for each operation both vectors are of equal length.
Transcribed Image Text:
9.3 Bit Vectors for Representing Sets Determining whether a value is a member of a particular set is a special case of searching for keys in a sequence of records. Thus, any of the search methods discussed in this book can be used to check for set membership. However, we can also take advantage of the restricted circumstances imposed by this problem to develop another representation. In the case where the set elements fall within a limited key range, we can repre- sent the set using a bit array with a bit position allocated for each potential member. Those members actually in the set store a value of 1 in their corresponding bit; those members not in the set store a value of 0 in their corresponding bit. For example, consider the set of primes between 0 and 15. Figure 9.1 shows the corresponding bit table. To determine if a particular value is prime, we simply check the corre- sponding bit. This representation scheme is called a bit vector or a bitmap. The mark array used in several of the graph algorithms of Chapter 11 is an example of such a set representation. If the set fits within a single computer word, then set union, intersection, and difference can be performed by logical bitwise operations. The union of sets A and B is the bitwise OR function (whose symbol is | in Java). The intersection of sets A and B is the bitwise AND function (whose symbol is & in Java). For example, if we would like to compute the set of numbers between 0 and 15 that are both prime and odd numbers, we need only compute the expression 0011010100010100 & 0101010101010101.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 66% (3 reviews)
To implement the functions for computing union intersection and set difference on arbitrarily long bit vectors used to represent set membership well c...View the full answer
Answered By
Ehsan Mahmood
I’ve earned Masters Degree in Business Studies and specialized in Accounts & Finance. Couple with this, I have earned BS Sociology from renowned institute of Pakistan. Moreover, I have humongous teaching experience at Graduate and Post-graduate level to Business and humanities students along with more than 7 years of teaching experience to my foreign students Online. I’m also professional writer and write for numerous academic journals pertaining to educational institutes periodically.
4.90+
248+ Reviews
287+ Question Solved
Related Book For
Practical Introduction To Data Structures And Algorithm Analysis Java Edition
ISBN: 9780136609117
1st Edition
Authors: Clifford A. Shaffer
Question Posted:
Students also viewed these Computer science questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
As described in Section 5.7, virtual memory uses a page table to track the mapping of virtual addresses to physical addresses. This exercise shows how this table must be updated as addresses are...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Figure shows an overhead view of a ring that can rotate about its center like a merry-go-round. Its outer radius R2 is 0.800 m, its inner radius R1 is R2/2.00, its mass M is 8.00 kg, and the mass of...
-
A heat engine has a solar collector receiving 600 Btu/h per square foot inside which a transfer media is heated to 800 R. The collected energy powers a heat engine which rejects heat at 100 F. If the...
-
Determine the Norton equivalent at terminals a-b for the circuit in Fig. 4.115 . 10/, ww- 5 A
-
Match the measures of worth in the first column with one (or more) of the analysis approaches that is (are) appropriate for that measure. Measure of Worth (a) Annual Worth (b) External Rate of Return...
-
The Coca-Cola Company is organized geographically and defines reportable operating segments as regions of the world. The following information was extracted from Note 21 (Operating Segments) in the...
-
For each of the following matrices A Maxn (R), test A for diagonal- izability, and if A is diagonalizable, find an invertible matrix Q and a diagonal matrix D such that Q-1AQ = D. (a) (63) 2 1 3 (b)...
-
Compute the probabilities for the following situations. These probabilities can be computed analytically, or you may write a computer program to generate the probabilities by simulation. (a) Out of a...
-
Write an algorithm to implement the transpose self-organizing list heuristic, assuming that the list is implemented using an array. In particular, write a function transpose that takes as input a...
-
Consider the circuit in Example 2-32. Assume that devices fail independently. What is the probability mass function of the number of failed devices?
-
Give a short (5 - 10 minutes) presentation to a partner explaining a communication strategy, protocol or standard of your choice. This could include information related to public relations, crisis...
-
Category 7 - Diversity - Cultural Dimensions Discuss 2 divergent cultural characteristics that can be present in a group. Define these characteristics using textbook citations and provide examples to...
-
List the four (4) different communication strategies you have used while communicating with clients and co-workers?
-
Create a simple blockchain simulation in Python. Your program should be able to create new blocks, validate the integrity of the chain, and display the entire blockchain.
-
1; Journal Prompt: Different Cultures Is it ethical or appropriate for someone from one culture to attempt to change the cultural values of someone from another culture? For example, consider the...
-
A stock has a beta of 1.4 and an expected return of 16 percent. A risk-free asset currently earns 6.25 percent. (a) What is the expected return on a portfolio that is equally invested in the two...
-
Determine the resultant moment produced by the forces about point O. 0.25 m 0.125 m, 0 0.3 m- 60 F = 500 N F = 600 N
-
Give an example to show that the RTS/CTS in the 802.11 protocol is a little different than in the MACA protocol.
-
A wireless LAN with one AP has 10 client stations. Four stations have data rates of 6 Mbps, four stations have data rates of 18 Mbps, and the last two stations have data rates of 54 Mbps. What is the...
-
List two ways in which WiMAX is similar to 802.11, and two ways in which it is different from 802.11.
-
solve for x, y, and r
-
Given the matrix A below, find the values of the elements a3,2 and -1 A = 9 -1 a2,3. -2-7-8 -4 8 21556 -2 -1 -5 339 26670 -7 13867 160 -2 -3 6 1
-
My Brother has a house worth $400,00 and he has no mortgage as it is paid off! His utility bills and insurance and maintenance cost him about $500 per month and property taxes and all other costs...
Study smarter with the SolutionInn App