edited by
753 views
0 votes
0 votes

Give a regular expression for the set of binary strings where every $0$ is immediately followed by exactly $k$ number of $1's$ and preceded by at least $k$ number of $1's$ ($k$ is a fixed integer).Choose the correct one out of two.

  1. $1^*1^k(01^k)^*1^*$       
  2. $1^*(1^k01^k)^*$
edited by

1 Answer

1 votes
1 votes

None is Correct. The Correct Regular Expression for the language described, will be :

$1^* + 1^*1^k0(1^k0)^*1^k$

 The Condition is "followed by exactly k number of 1's"Exactly K number of 1's means that Not more than K 1's, Not less than K 1's after Every Zero. 

Because of this Condition, Only the First $0$ can be preceded by more than $k$ 1's. All the other Zeroes (i.e. Except the First Zero) will be both Preceded and followed by Exactly $k$ 1's.


Note that If R and S are any Two RE then $R(SR)^*$ and $(RS)^*R$ Always denote the same language. Same logic can be applied here and the above RE can also be written as follows :

$1^* + 1^*1^k(01^k)^*$

Credit : @Bhanukumar

edited by

Related questions

0 votes
0 votes
1 answer
1
Ashish Roy 1 asked Jul 15, 2018
1,146 views
Let L(r1)=(b*ab*ab*ab*)* & L(r2)=(b*ab*ab*)*. What is L(r1) Intersection L(r2)?a) (b*ab*ab*ab*)*b) (b*ab*ab*)*c) (b*ab*ab*)^6d) (b*ab*ab*ab*ab*ab*ab*)*Please do explain a...
1 votes
1 votes
1 answer
2
0 votes
0 votes
1 answer
4
hasina ali asked Mar 21
104 views
Set of binary strings starting with 11 and ending with 00. E.g., 1100,1110100 ,1100100