Question

In: Computer Science

using any form of induction, that a binary string begins and ends with the same character...

using any form of induction, that a binary string begins and ends with the same character iff contains an even number of occurences of substrings from (01,10).

Solutions

Expert Solution

According to induction, it should contain a base and a hypothesis. Here:

  • Base: Start with length n=1. A one-digit string contains equal number of substrings 0101 and 1010 (that is, zero) and starts and ends with the same character.
  • Induction hypothesis: ∀k<n, a string of length k has an equal number of substrings 1010 and 1010 if and only if it starts and ends with the same character.
  • Induction steps: Say s is a string of length n. Now, take cases:
  1. If each character of the string is different from the previous character (meaning, s=0101⋯1010 or s=1010⋯0101) then it is easy to show that it starts and ends with the same character if and only if it has the same number of 0101 and 1010.

  2. The other case is when s has at least two consecutive 1s or 0s. Now, use Andre's hint to make a new substring s′, by replacing all consecutive 0s with a single 0 and all consecutive 1s with a single 1.

    Notice that the number of substrings 01 in s′ is the same as in s and the number of 10 in s′ is the same as in s. So, s and s′ have the same number of substrings 01 and 10. Also, notice that the first character of s is the same as of s′ and also the last character of s is the same as of s′.

    But s′ has a length less than n, so you can use the induction hypothesis and say that s′ starts and ends with the same character if and only if it has the same number of substrings 01 and 10. But because of the similarities you have noticed between s and s′, you can prove that the same holds for s, too.

(Hint: Replace any string of consecutive 0's with a single 0, and any string of consecutive 1's with a single 1. That does not affect the number of substrings of type 01 or 10.)*

*just for small reference.


Related Solutions

(In JAVA)Write code to print the location of any alphabetic character in the 2-character string passCode.
Java Language Write code to print the location of any alphabetic character in the 2-character string passCode. Each alphabetic character detected should print a separate statement followed by a newline. Ex: If passCode is "9a", output is: Alphabetic at 1 import java.util.Scanner;   public class FindAlpha {    public static void main (String [] args) {       Scanner scnr = new Scanner(System.in);       String passCode;              passCode = scnr.next();     ...
Design a state machine to recognize if a binary string contains any occurrence of the sequence...
Design a state machine to recognize if a binary string contains any occurrence of the sequence “10101”. Is it possible to design this state machine with less states? By using Finite State machine designer. http://madebyevan.com/fsm/
Using the windows32 framework, write a procedure to read a string and shift each character of...
Using the windows32 framework, write a procedure to read a string and shift each character of the string by one. As an example, if your input string is Abcz, your output should be Bcda. Note that you must test your string for non-alphabetic characters (such as numbers and special characters). If there are non-alphabetic characters, you should terminate your program with an appropriate message. You should display your converted string using the output macro. Hint: Let your procedure returns an...
Two induction coils are wound on the same form as shown in Figure 8. Explain what...
Two induction coils are wound on the same form as shown in Figure 8. Explain what the symbols L1, L2, M refer to, and explain the significance black dots shown. [5 marks] Figure 8: Self-inductances and mutual inductance  
This is a straightforward program that will "draw" a rectangle using any character selected by the...
This is a straightforward program that will "draw" a rectangle using any character selected by the user. The user will also provide the width and height of the final rectangle. Use a nested for loop structure to create the output. Input: This program will draw a rectangle using your character of choice. Enter any character: [user types: *] Enter the width of your rectangle: [user types: 20] Enter the height of your rectangle: [user types: 5] Output: ******************** ******************** ********************...
Using python: Given a string x, write a program to check if its first character is...
Using python: Given a string x, write a program to check if its first character is the same as its last character. If yes, the code should output "True"
Java String search Design and implement a recursive version of a binary search.  Instead of using a...
Java String search Design and implement a recursive version of a binary search.  Instead of using a loop to repeatedly check for the target value, use calls to a recursive method to check one value at a time.  If the value is not the target, refine the search space and call the method again.  The name to search for is entered by the user, as is the indexes that define the range of viable candidates can be entered by the user (that are...
Show using the C4v point group character table the orthogonality of any two irreducible representations. Using...
Show using the C4v point group character table the orthogonality of any two irreducible representations. Using the same point group demonstrate the property of the character table that two irreducible representations can be used to deduce the characters for another (ex combinations of the irreducible representations for px and py can be used to determine the characters for the irreducible representation of dxy)
. Write a program which encodes any string using the XOR instruction.  Test it using your <first...
. Write a program which encodes any string using the XOR instruction.  Test it using your <first name last name> in the data segment to produce cipher text and then decode using the program to get plain text.  Use the last two digits of your student id as the key.  Print plane text from the data segment, print the cipher text, and then print the plain text upon execution.  Submit the asm/list file and screenshots that shows the output of your code. What are...
Show and explain how to obtain the echelon form of any matrix using Matlab.
Show and explain how to obtain the echelon form of any matrix using Matlab.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT