

(1 point) [3 Marks] A 6-digit binary string a 6-digit number composed of O's and 1's....
Problem 3. A ternary string is a sequence of O's, 1's and 2's. Just like a bit string, but with three symbols 0,1 and 2. Let's call a ternary string good provided it never contains a 2 followed immediately by a 0, i.e., does not contain the substring 20. Let Go be the number of good strings of length n. For example, G_1=3, and G. = 8 (since of the 9 ternary strings of length 2, only one is not...
For this problem, your answer can be a numerical expression and does not need to be fully evaluated. For example, you could write 5⋅23+45⋅23+4. A basket contains nine red balls numbered 1, 2, 3, 4, 5, 6, 7, 8, and 9 and nine blue balls numbered 1, 2, 3, 4, 5, 6, 7, 8, and 9. a) A sample of nine balls are drawn from the basket without replacement. How many distinct samples are possible (assuming that order does not...
For a string s ∈ {0, 1} let denote the number represented by in
the binary * s2 s numeral system. For example 1110 in binary has a
value of 14 . Consider the language: L = {u#w | u,w ∈ {0, 1} , u }
, * 2 + 1 = w2 meaning it contains all strings u#w such that u + 1
= w holds true in the binary system. For example, 1010#1011 ∈ L and
0011#100 ∈...
6.) (a) A string contains several X's followed by several O's. Devise a divide-and-conquer algorithim that finds the number of X's in the string in log2n steps, where n is the length of the string. (b) An array originally contained different numbers in ascending order but may have been subsequently rotated by a few positions. For example, the resulting array may be: 21 34 55 1 2 3 4 5 8 13 Is it possible to adapt the Binary Search...
2. This question is about processing strings 2.1 [4 marks] Given a string str, we can calculate a checksum of the string by summing up the ASCII codes of the characters in the string. For example, the checksum of a string "apple" is 530, which equals to 'a' + 'p' + 'p' + 'l' + 'e' = 97 + 112 + 112 + 108 + 101. Write a function int calculate_checksum(char str[] that calculates and returns the checksum of the...
(1) (50%) Write a C program that takes as input a fully parenthesized, arithmetic expression of binary operators +, -,*,/, and converts the expression into a binary expression tree. Your program should take input from the command line. The entire expression should be in a character string without any space in it An input string only includes floating numbers in the format of Y.YY, that is, one digit to the left of the decimal point and two digits to the...
Write a function decompressed(count_tuples)
that takes a list of counts of '0's and '1's as defined above and
returns the expanded (un-compressed) string. You may assume that
the first value of count_tuples has a count that is
greater than or equal to zero and all other counts are greater than
zero.
Comments to show how to figure this out would be greatly
appreciated
A data file in which particular characters often occur multiple times in a row can be compressed...
3 points) Question Three Consider the context-free grammar S >SS+1 SS 1a and the string aa Give a leftmost derivation for the string. 3 points) (4 poiots) (5 points) (3 points) sECTION IWOLAttcmpt.any 3.(or 2) questions from this.scction Suppose we have two tokens: (1) the keyword if, and (2) id-entifiers, which are strings of letters other than if. Show the DFA for these tokens. Give a nightmost derivation for the string. Give a parse tree for the string i) Is...
The first significant digit in any number must be 1, 2, 3, 4, 5, 6, 7, 8, or 9. It was discovered that first digits do not occur with equal frequency. Probabilities of occurrence to the first digit in a number are shown in the accompanying table. The probability distribution is now known as Benford's Law. For example, the following distribution represents the first digits in 194 allegedly fraudulent checks written to a bogus company by an employee attempting to...
Banks issue credit cards with 16 digit numbers. If you've never thought about it before you may not realize it, but there are specific rules for what those numbers can be. For example, the first few digits of the number tell you what kind of card it is - all Visa cards start with 4, MasterCard numbers start with 51 through 55, American Express starts with 34 or 37, etc. Automated systems can use this number to tell which company...