
Given two integer arrays, A and B of length n each, write an efficient algotihm to find an integer that occurs the same number of times in both A and B. extra: solve this recurrence: T(1) = 1; T(n) = T(n/4) + n
You are given a set of integer numbers A = {a1, a2, ..., an}, where 1 ≤ ai ≤ m for all 1 ≤ i ≤ n and for a given positive integer m. Give an algorithm which determines whether you can represent a given positive integer k ≤ nm as a sum of some numbers from A, if each number from A can be used at most once. Your algorithm must have O(nk) time complexity.
d) A Pythagorean quadruple consists of four integer a, b, c, d such that a2 + b2 c2d2 Turn some of the near-miss solutions that I talk about in the second part of the video into Pythagorean quadruples. (Hint: re- member that 1 12). e) Use some of the near-miss solutions to find some integers that can be written as the sum of two positive integer squares in two differ- ent ways.
Find the N point DFT for x[n] for the following cases: a) Ko is an integer b) Ko is not an integer
Find the N point DFT for x[n] for the following cases: a) Ko is an integer b) Ko is not an integer
13. Consider the sequence of numbers ao, ai, a2, a3, given by ao-2, ai-3, and for any positive integer k 2, a3ak 2ak-1. (a) Evaluate a2,a3, a4,as. Show your work. (b) Prove that for all positive integers n, an 2 +1
Find number list that is n%6 = 0 given list is integer 0 to n. You can only use three function. addOne(), isOdd(), isEven(). For example, if n = 13 input list is 1 2 3 4 5 6 7 8 9 10 11 12. Output list is 6, 12. It is easy with mod operator, but I cannot use it. We can only use addOne(), isOdd(), isEven().
(C programming) Given a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence. Input The input consists of multiple datasets. Each data set consists of: n a1 a2 . . an You can assume that 1 ≤ n ≤ 5000 and -100000 ≤ ai ≤ 100000. The input end with a line consisting of a single 0. Output...
Let n be a positive integer. We sample n numbers a1, a2,..., an from the set {1,...,n} uniformly at random, with replacement. We say that picks i and j with are a match if ai = aj, i < j. What is the expected total number of matches? Use indicators.
Let {dn}n≥0 denote the number of integer solutions a1 +a2 +a3 +a4 = n where 0 ≤ ai ≤ 5 for each i = 1, 2, 3, 4. Write the ordinary generating function for {cn}n≥0. Please express the ordinary generating function as a rational function p(x) /q(x) where both p(x) and q(x) are polynomials in the variable x.
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....