ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 06 Jun 2017 My Price 9.00

array of0s and1s

C programming exercise on 2 arrays and how to union and intersection both of the arrays

 

1.Sets of numbers can be represented using array of0s and1s. The idea is thata[i]!=0ifiis in the set, anda[i] == 0if it isnot. For example, the arraya[10] = {0, 0, 1, 0, 1, 1, 0, 0, 0, 0}wouldrepresen±heset{2, 4, 5}becausea[2],a[4],anda[5]have the value1, and everywhere else a contains zeros. Since the array has a ²xed bound, sayN,the values in the set are restricted to the range0...N-1. Write a C program that reads in two sets of numbersAandB, andcalculates and print their union (° ∪B) and intersec³on(° ∩(B).° ∪ °is the set of elements that appear in either A or B, and that(° ∩ °((is the set of elements that appear in both A and B. The values in the sets are restricted to the range0... 9..1) Name your programsets.c. .2) The program will read in the number of element in the ²rst set, for example, 4, then read in the numbers in the set, for example,3 6 8 9. The repeat for the second set. The two sets do not necessarily are of the same size..3)  The sets are stored using arrays of 0s and 1s as described above. .4) Calculate the union and intersec³on of the two sets and display the result..5) Sample input/output:Please enter the number of elements in set A: 3.Enter the numbers in set A: 3 5 8.Please enter the number of elements in set B: 4.Enter the numbers in set B: 7 5 9 3.Output:The union of set A and B is: 3 5 7 8 9 The intersection of set A and B is: 3 52.A binary bar code scan is a bit pa±ern that contains only 1s and 0s. Write a program that ²nds the edges of light and dark regions.Process an input bit pa±ern in the following manner:.Assign a 1 to the output bit pa±ern whenever two consecu³ve bits (one bit and it’s previous bit) aredi´erent.Assign a 0 to the output bit pa±ern whenever two consecu³ve bit (one bit and it’s previous bit) are thesame.Assign 0 to the ²rst output bit since there is no previous bit for the ²rst bit For example, input and outputbit pa±ern of the program that detects the edges might look like the following:Input: 00101101 Output: 00111011.1) Name your programbarcode.c..2) Assume the input contains exactly 8 bits..3) As part of the solu³on, write and call the func³on edge() with the prototypevoid edge(int n, int a1[],int a2[]);.to perform edge detec³on. The arguments of the func³onedge()contain the length of the input and output arrays with the samesize, the input arraya1, and output arraya2.

Attachments:

Answers

(11)
Status NEW Posted 06 Jun 2017 09:06 AM My Price 9.00

-----------

Not Rated(0)