Combinatorics › Counting principles

Bits and binary trees

Solve the first problem 4 problems

  1. Edit distance between Big and Bang ●○○○○ 10 ptsGiven two strings str1="Big"\text{str}_1 = \text{"Big"} and str2="Bang"\text{str}_2 = \text{"Bang"}, find the minimum number of operations needed to convert str1\text{str}_1 into str2\text{str}_2. The allowed operations are deleting a character, replacing a character with another, and inserting a character at any position.
  2. Element without a duplicate ●○○○○ 10 ptsEvery element of the list 2,2,3,4,5,9,5,4,9,1,32, 2, 3, 4, 5, 9, 5, 4, 9, 1, 3 appears exactly twice except one element, which appears only once. Find the element that does not have a duplicate.
  3. Locating a single bit error ●●○○○ 20 ptsA binary code x1x2…x7x_1x_2\ldots x_7 satisfies the parity check equations x4⊕x5⊕x6⊕x7=0x_4\oplus x_5\oplus x_6\oplus x_7=0, x2⊕x3⊕x6⊕x7=0x_2\oplus x_3\oplus x_6\oplus x_7=0 and x1⊕x3⊕x5⊕x7=0x_1\oplus x_3\oplus x_5\oplus x_7=0, where ⊕\oplus is addition modulo 2. A code of this type was changed to 11011011101101 after a bit error occurred at only one position kk during communication, so the bit at position kk flipped. Find kk.
  4. Count unival subtrees in a tree ●●○○○ 20 ptsA unival subtree of a binary tree is a subtree in which all nodes have the same value. A single leaf counts as a unival subtree. Consider the following binary tree. The root has value 00. The root's left child has value 11 and is a leaf. The root's right child has value 00; its left child has value 11 and its right child has value 00 (a leaf). The node with value 11 (the left child of the right child) has two children, both with value 11 (leaves). How many unival subtrees does the tree have?

More in Counting principles