Start with a list of numbers 1,2,....,2n. Remove two numbers a,b and add |a-b| to the list. Duplicates are allowed. For example, if n=2, you start with [1,2,3,4], you can remove 1 and 4 from the list and add |4-1|=3 to the list, leaving [2,3,3].Continue until one element is remaining. Prove or disprove that if the number remaining is even, n must be even.
for n = 1 , numbers will be [1,2] , it contains 2 elements. For
this after removing the first and last number of the list, The
remaining list will be [|2-1|] =[1] . It contain
only one element, so can't reduce further.
for n = 2, numbers will be [1,2,3,4] . It will be converted to
[2,3,3] -> [3,1] ->[2]
for n=3, numbers will be [1,2,3,4,5,6] . It will be converted to
[2,3,4,5,5]
->[3,4,5,3]->[4,5,0]->[5,4]->[1]
for n=4, numbers will be [1,2,3,4,5,6,7,8] . It will be converted
to
[2,3,4,5,6,7,7]->[3,4,5,6,7,5]->[4,5,6,7,2]->[5,6,7,2]->
[6,7,3] ->[7,3] -> [4]
It is observed for n= 1 remaining no is [1] which is ODD
for n= 2 remaining no is [2] which is EVEN
for n= 3 remaining no is [1] which is ODD
for n= 4 remaining no is [4] which is EVEN
Hence it is proved from the observation that that if the number
remaining is even, n must be even and that if the number remaining
is odd, n must be odd.
Start with a list of numbers 1,2,....,2n. Remove two numbers a,b and add |a-b| to the...
3. Let {x1, x2,...,xn} be a list of numbers and let ¯ x denote the average of the list. Let a and b be two constants, and for each i such that 1 ≤ i ≤ n, let yi = axi + b. Consider the new list {y1,y2,...,yn}, and let the average of this list be ¯ y. Prove a formula for ¯ y in terms of a, b, and ¯ x. 4. Let n be a positive integer. Consider...
1. use python List to Dictionary Write a function that has three parameters: a list of unsorted numbers with no duplicates, a start number, and an end number. This function should return a dictionary with all integers between the start and end number (inclusive) as the keys and their respective indices in the list as the value. If the integer is not in the list, the corresponding value would be None. Example unsorted list: [2,1,10,0,4,3] two numbers: 3, 10 returned...
1. a) Let A = {2n|n ∈ ℤ} (ie, A is the set of even numbers) and define function f: ℝ → {0,1}, where f(x) = XA(x) That is, f is the characteristic function of set A; it maps elements of the domain that are in set A (ie, those that are even integers) to 1 and all other elements of the domain to 0. By demonstrating a counter-example, show that the function f is not injective (not one-to-one). b)...
c programming A linked list is a linear data structure that allows us to add and remove items from the list very quickly, by simply changing a few pointers. There are many different variations of linked lists. We have studied the doubly-linked, circular, with a dummy-header-node version of a linked list. In the class notes we studied several functions to manipulate a Linked List. For this assignment you must write the code for the following additional linked list functions: addFirst,...
1. (Integers: primes, divisibility, parity.) (a) Let n be a positive integer. Prove that two numbers na +3n+6 and n2 + 2n +7 cannot be prime at the same time. (b) Find 15261527863698656776712345678%5 without using a calculator. (c) Let a be an integer number. Suppose a%2 = 1. Find all possible values of (4a +1)%6. 2. (Integers: %, =) (a) Suppose a, b, n are integer numbers and n > 0. Prove that (a+b)%n = (a%n +B%n)%n. (b) Let a,...
Q1: You can find a file that defines the CircularlyLinked List class similar to what we discussed in the class. Download the file and work on it. Your task is to: 1. Complete the missing methods in the file as discussed in the class. Search for the comment/" MISSING / in the file to see the methods that need to be completed. 2. Add the following methods to the class a. public Node getMin 1. Task: find the node with...
I need help on b-e. THANK YOU
blem 3. Consider the following statement: 1 For all n EN, 12 +22 +32 + ... +n? n(n+1)(2n +1) (a) Prove the statement () using mathematical induction. We use the term closed form expression to describe an algebraic expression that involves only a fixed amount of operations (i.e. that doesn't involving adding n terms). So for example, in the proposition above, the sum of n consecutive natural numbers (12 +22 + ... +...
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...
Create a java code that will take user input and find the median using two heaps (max and min heap). The two heap must sort the elements from small to large. Running time must be efficient and below O(n^2). The algorithm must support the following methods: - insert(b): insert a given element b in O(logn) time - getMedian(): return the median in O(1) time - removeMedian(): remove and return the median in O(logn) time Note: The median will return the...
Question 4 [35 marks in totalj An n x n matrix A is called a stochastic matrix if it! satisfies two conditions: (i) all entries of A are non-negative; and (ii) the sum of entries in each column is one. If the (,) entry of A is denoted by any for ij € {1, 2,...,n}, then A is a stochastic matrix when alij 20 for all i and j and I j = 1 for all j. These matrices are...