Given a sequence of numbers, its head length is the largest integer m for which the first m terms are nondecreasing. For instance, the head length of [1, 1, 2, 4, 3] is 4. Thus, we can compute the average head length for any set of sequences. For example, we can evaluate the head lengths for all six permutations of the sequence [1, 2, 3]: [2, 1, 3], [3, 1, 2], and [3, 2, 1] each have head length 1, [1, 3, 2] and [2, 3, 1] have head length 2, and [1, 2, 3] has head length 3. Thus, a permutation of [1, 2, 3] has average head length (1 + 1 + 1 + 2 + 2 + 3)/6 = 5/3. Let n be a positive integer. Consider all the permutations of [1, 2, …, n]. What fraction of them has head length 1? What fraction of them has head length k, for k < n? What is the average head length of a permutation of [1, 2, …, n]? What is the average head length of a permutation of [1, 1, 2, 3, …, n]? What is the average head length of a sequence of length n consisting of the numbers {1, 2, 3, 4}?
![no of permulations for 11,2,3,...,n] ,n! possibile I In positions. lafor head tength ! . position is then gud position has n-](http://img.homeworklib.com/questions/729db1f0-6392-11ea-b33f-77ca1f9bf341.png?x-oss-process=image/resize,w_560)

Given a sequence of numbers, its head length is the largest integer m for which the...
Haskell Program: hailstone :: Integer -> Integer Given a positive integer n, return the length of the hailstone sequence beginning with n. The hailstone sequence for an integer n can be found by repeatedly applying a specific function. We will write e[i] for element i in the sequence, and define: e[0] = n e[i+1] = e[i] / 2, if e[i] is even e[i+1] = 3 * e[i] + 1, if e[i] is odd The sequence ends once e[i] is 1....
1, and let σ be a permutation of {1, , n). Recall that for each integer m a) Let n 1, we denote ơm--σ ο . . . o σ. Show that n times b) Let 21, and let be a permutation of..,n consisting of a unique cycle of length n. Deduce from the previous question that there exists i e (1,..., n) such that i +c() )+22(n1).
1, and let σ be a permutation of {1, , n). Recall...
1. Show that the set of rational numbers of the form m /n, where m, n E Z and n is odd is a subgroup of QQ under addition. 2. Let H, K be subgroups of a group G. Prove: H n K is a subgroup of G 3. Let G be an abelian group. Let S-aEG o(a) is finite . Show that S is a subgroup of G 4. What is the largest order of a permutation in S10?...
use Java please.
The Fibonacci Sequence Given the initial Fibonacci numbers 0 and 1, we can generate the next number by adding the two previous Fibonacci numbers together. For this sequence, you will be asked to take an input, denoting how many Fibonacci numbers you want to generate. Call this input upperFibLimit. The longest Fib sequence you should generate is 40 and the shortest you should generate is 1. So,1<upperFibLimit<40 The rule is simple given f(0) 0, f(1) 1 ....
Given the following algorithm:
Algorithnm Input: a1, a2,...,an, a sequence of numbers n, the length of the sequence x, a number Output: ?? i:- 1 While (x2 # a, and i < n) i+1 End-while If (x- - a) Return(i) Return(-1) 3, -1, 2,9, 36,-7, 6,4 a) What is the correct output of the Algorithm with the following input: a1, a2,..an b) What is the asymptotic worst-case time complexity of the Algorithm?
Algorithnm Input: a1, a2,...,an, a sequence of numbers...
You are given a sequence of positive real numbers a[1..n]. You can now add ‘+’ and ’×’ signs between these numbers, and your goal is to generate an expression that has the largest value. As an example, if a = {2, 3, 0.5, 2}, then you should output the expression 2 × 3 + 0.5 + 2 = 8.5. This is larger than any other expression (e.g. 2 × 3 × 0.5 × 2 = 6, 2 + 3 +...
Let's say you are given a sequence of distinct positive numbers. We want to find a subsequence with the maximum possible sum, with the restriction that we are not allowed to take three consecutive elements from the original sequence. For example, for input 1, 6, 5, 2, 7, 9, 3, 4, the subsequence with the maximum possible sum is 6, 5, 7, 9, 4 (we have two pairs of consecutive elements 6, 5 and 7, 9 but not three consecutive...
Q(1) Given a rope of length n meters, cut the rope in different parts of integer lengths in a way that maximizes product of lengths of all parts. You must make at least one cut. Assume that the length of rope is more than 2 meters Examples: (n-4) Input: rope length is 4 Output: 2*2-4(Maximum obtainable product is 2*2) Input: rope length is 5 Output: 2*3-6 (Maximum obtainable product is 2*3) (n-5) Input: rope length is 10 (n- 10) Output:...
Pseudo-random numbers are pervasive and extremely important in modern computing and scientific applications. But how exactly is a sequence of apparently random number generated? Here we study one early method which has the benefit of being very easy to implement 1. If we take a positive integer n having k digits (k 1), then n 10*, so that n2 (10)2 02. Thus we would expt up to 2k digits in the square of the k digit number 1l So, for...
5.Prove Proposition. Suppose that a, -a and bb and a>b. Then there is a positive integer M such that ifp2 M and q 2 M then a >b Suggestions to get you started 0. It is easier to use a direct proof. Do not try to prove this one by contradiction. 0'. Draw the picture of the situation 1. Since a< b, what does the Hausdorff Lemma say? Draw the real line showing what the Hausdorff Lemma sets up for...