Write a C++ (or any programming) program/function to check A CB. Algorithm 6.1.1 Testing Whether ACB [The input sets A a
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Write a C++ (or any programming) program/function to check A CB. Algorithm 6.1.1 Testing Whether ACB [The input sets A a
Write a C++ (or any programming) program/function to check A CB. Algorithm 6.1.1 Testing Whether ACB [The input sets A and B are represented as one-dimensional arrays a[1], a[2],..., a[m] and b[1], b[2),..., b[n), respectively. Starting with a[1] and for each successive a in A, a check is made to see whether a is in B. To do this, a is compared to successive elements of B. If a is not equal to any element of B, then the output string, called answer, is given the value “A & B." If a equals some element of B, the next succes- sive element in A is checked to see whether it is in B. If every successive element of A is found to be in B, then the answer never changes from its initial value "A C B.") Input: m la positive integer), a[1], a[2],..., a[m] (a one-dimensional array repre- senting the set A], n [a positive integer), b[1], b[2],..., b[n] (a one-dimensional array representing the set B] Algorithm Body: i := 1, answer :=" AB" while (i sm and answer = "A C B") j:= 1, found :="no" while (j sn and found="no") if a = b[j] then found :="yes" j:=j+1 end while [If found has not been given the value “yes” when execution reaches this point, then a € B. if found = "no" then answer := " AB" i:=i+1 end while Output: answer (a string] Please attach a screenshot of the output.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!