Understanding String and Set Expressions in Exercise
10 likes | 98 Vues
Learn what different expressions yield in the context of strings and sets, and test your knowledge by identifying set members in given strings.
Understanding String and Set Expressions in Exercise
E N D
Presentation Transcript
Exercise 1 for strings and sets 1. What does each of the following expressions give? (a) a5 (b) |aba7b| (c) || (d) xR , where x = abab (e) AB, where A = {a, b, c}, B = {aaaa, bbbb, cccc}. (f) A*BA* ,where A and B are the same sets defined in (e) above. Answer: (a) aaaaa (b) 10 (c ) 0 (d) baba (e) AB = {aaaaa, abbbb, acccc, baaaa, bbbbb, bcccc, caaaa, cbbbb, ccccc} (f) A*BA* = { x | x = {a, b, c}* and x has aaaa, bbbb, or cccc as a substring} 2. For each of the following sets, which of the strings given below in (1) – (7) are its members? (a) {xyxR | x {a, b, c}*, y ccc } (b) {xx | x {a, b, c}* } (c) {x | x {a, b, c}* and x has more a’s than b’s. } {aibj | j, i > 0 } (d) ({a, b, c}* - ({aibj | i > j > 0 } {aibj | 0 < i < j })) {aibj | j, i > 0 } (1) aaaabbbb (2) aaaa (3) aaaacccaaaa (4) bbbaaaa (5) abcccccba (6) aaaaab (7) abaaba Answer: (a): (3), (5) (b): (2), (7) (c): (6) (Notice that the members should be in {aibj | i > j > 0}) (d): (1) (Notice that the members should be in {aibi | i > 0 })