2. We know a subset can be represented by an array of 1's and 0's (1...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. We know a subset can be represented by an array of 1's and 0's (1 for an item in the subset and 0 for an item not in the subset). Shown below are some example subsets of A, B, C, D, E) and their array-representation. Note that #(1's in the array) equals the size of the subset. Subsets { A, B, E) (B) A 1 0 0 B 1 1 0 C D E 0 0 1 0 0 0 0 0 0 Array representation [1, 1, 0, 0, 1] [0, 1, 0, 0, 0] [0, 0, 0, 0, 0] What does the following code return when subsetOne and subsetTwo equal the arrays for subsets (A, B, E) and {B}? for (int i-0; i<subsetOne.length; i++) if (subsetOne [i] != subset Two [i]) return (false); return (true); How many times the comparison "subsetOne[i] != subsetTwo[i]" is done? State in English what the code returns, in general, for two input arrays subsetOne and subsetTwo (of 0's and I's and having the same length)? For subsetOne = [1, 1, 0, 0, 1], how many subsetTwo give the return value "true" and what is #(comparison "subse- tOne[i] != subsetTwo[i]") for each of those subsetTwo? For subsetOne = [1, 1, 0, 0, 1], how many subsetTwo give the return value "false" and how many of them have #(com- parison "subsetOne[i] != subsetTwo[i]")= k for each of k= 1, 2, 3, and 4? Give the codes to test each of the following: (a) subsetOne is a subset of subsetTwo, and (b) subsetOne and subset Two are disjoint. 2. We know a subset can be represented by an array of 1's and 0's (1 for an item in the subset and 0 for an item not in the subset). Shown below are some example subsets of A, B, C, D, E) and their array-representation. Note that #(1's in the array) equals the size of the subset. Subsets { A, B, E) (B) A 1 0 0 B 1 1 0 C D E 0 0 1 0 0 0 0 0 0 Array representation [1, 1, 0, 0, 1] [0, 1, 0, 0, 0] [0, 0, 0, 0, 0] What does the following code return when subsetOne and subsetTwo equal the arrays for subsets (A, B, E) and {B}? for (int i-0; i<subsetOne.length; i++) if (subsetOne [i] != subset Two [i]) return (false); return (true); How many times the comparison "subsetOne[i] != subsetTwo[i]" is done? State in English what the code returns, in general, for two input arrays subsetOne and subsetTwo (of 0's and I's and having the same length)? For subsetOne = [1, 1, 0, 0, 1], how many subsetTwo give the return value "true" and what is #(comparison "subse- tOne[i] != subsetTwo[i]") for each of those subsetTwo? For subsetOne = [1, 1, 0, 0, 1], how many subsetTwo give the return value "false" and how many of them have #(com- parison "subsetOne[i] != subsetTwo[i]")= k for each of k= 1, 2, 3, and 4? Give the codes to test each of the following: (a) subsetOne is a subset of subsetTwo, and (b) subsetOne and subset Two are disjoint.
Expert Answer:
Related Book For
Logic And Computer Design Fundamentals
ISBN: 9780133760637
5th Edition
Authors: M. Morris Mano, Charles Kime, Tom Martin
Posted Date:
Students also viewed these programming questions
-
Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...
-
ttth Suppose that the sequence of bags {Bn | n N} is recursively enumerated by the computable function e(n, x) = fn(x), [7 marks] Hence prove that the set of all recursive bags cannot be recursively...
-
The following Excel output summarizes the results of an analysis of variance experiment in which the treatments were three different hybrid cars and the variable measured was the miles per gallon...
-
At December 31, 2014, Eaton Corp. reported the following shareholders' equity: Shareholders' Equity Share Capital: Common Shares, 400,000 shares authorized, 120,000 shares issued and 100,000...
-
Triumph Soccer Club has the following cash flows during this year: It repaid existing debt of $875,430 while raising new debt capital of $1,213,455. It also repurchased stock in the open market for a...
-
Laura Neilson, a job specialist with Vocational and Educational Services for Individuals with Disabilities, responded to an advertisement in a New York newspaper for a position as a shower, a job...
-
Kusmaul Electric sold $500,000, 10%, 10-year bonds on January 1, 2010. The bonds were dated January 1 and paid interest on January 1 and July 1.The bonds were sold at 104. Instructions (a) Prepare...
-
1. Find the focal length of a convex mirror of radius of curvature 1m. 2. Focal length of a convex mirror is 50 cm. What is its radius of curvature? 3. Radius of curvature of a concave mirror is 25...
-
Suppose labor (L) and capital (K) are perfect substitute inputs. Each additional hour of labor increases output by one unit, and each additional hour of capital increases production by 2 units....
-
respond to two peers below peer 1 I picked an article on the Administrative Procedures Act (APA) mentioned in our textbook (p.183, 2022) Issue Over the last 70 years, since the inception of the APA,...
-
How can social workers or medical professionals help determine the difference between willful negligence and a potential educational barrier? What interventions could be helpful in these situations?...
-
You have secured a competitive internship with a start-up technology firm which develops innovative solutions for companies entering the Metaverse (the next generation of online social interaction)....
-
Ann, Boris, Carrie and Daniel are directors of SpeedRoad Transport Ltd. SpeedRoad is listed in the Australian Security Exchange (ASX) and operates a fleet of 2,000 buses travelling interstate....
-
A company had the following sales transactions: Total debit card sales = $300,000. Total credit card sales = $490,000. Total cash sales = $890,000. Total check sales = $150,000. There is a charge of...
-
Describe how using a frame analysis can counteract cluelessness and organizational barriers to learning?
-
Anna, a high school counselor, devised a program that integrates classroom learning with vocational training to help adolescents at risk for school dropouts stay in school and transition to work...
-
A virtual memory system uses 4 KB pages, 64-bit words, and a 48-bit virtual address. A particular program and its data require 4263 pages. (a) What is the minimum number of page tables required? (b)...
-
A sequential circuit has three D lip- lops A, B, and C, and one input X. The circuit is described by the following input equations: (a) Derive the state table for the circuit. (b) Draw two state...
-
Repeat Problem 4-27 with D lip- lops using a Gray- code assignment. Problem 4-27: A sequential circuit has two lip- lops A and B, one input X, and one output Y. The state diagram is shown in Figure...
-
Gross profit is (A) Excess of sales over cost of goods sold (B) Sales less purchases (C) Cost of goods sold + opening inventory (D) Net profit less expenses of the period
-
Net profit is calculated in the (A) Trading account (B) Profit and loss account (C) Trial balance (D) Statement of financial position
-
To find the value of closing inventory at the end of a period we (A) Do this by physically counting the inventory (i.e. stocktaking) (B) Look in the inventory account (C) Deduct opening inventory...
Study smarter with the SolutionInn App