Write an algorithm that takes an array B and a number N as inputs.
Suppose that the array B contains n distinct numbers. Compute the sum of the N largest numbers in the array B.
Example: if the array B= [4, 5, 8, 11, 3] and N = 3, then the algorithm should return 24 (11+8+5).

Write an algorithm that takes an array B and a number N as inputs. Suppose that...
Write a function called
addNeighbors that takes an array of numbers and adds each number in
the array to the number next to it. The array will always have an
even number of numbers in it. In the end you should return an array
of neighbors added up. Please use JavaScript
Instructions from your teacher. Medium Question #4 Write a function called addNeighbors that takes an array of numbers and adds each number in the array to the number next...
2. Suppose that you are given an translating the algorithm for inputs of size 4 into a decision tree, you find that the decision tree has no leaf corresponding to the permutation (3,1,2,4). Write down input of 4 distinct 2-digit numbers that will not be sorted correctly by the given algorithm algorithm for sorting all sets of distinct integers. After an
2. Suppose that you are given an translating the algorithm for inputs of size 4 into a decision tree,...
Write a program in C++ language that finds the largest number in an array of positive numbers using recursion. Your program should have a function called array_max that should pass in an int array, and an int for the size of the array, respectively, and should return an int value. As an example, given an array of size 10 with contents: {10, 9, 6, 1, 2, 4, 16, 8, 7, 5} The output should be: The largest number in the...
Problem 3: (5 2 points) Design an algorithm that takes an array of positive integers A of length n and a positive integer T as an input and finds the largest N < T such that N can be written as a sum of some elements of A and returns such a representation of N. The complexity of the algorithms has to be O(nT). For example, for A 3,7, 10 and T 19, the output is 17 7+10, because we...
Write a function called multiSum(A). This particular function should take in a N × M array, A, and return four results: A 1 × M vector with the sum of the columns, A N × 1 vector with the sum of the rows, and Two numbers containing the sums of the two diagonals, the major diagonal first. For example: columnSum([1 2 3; 4 5 6; 7 8 9]) should return [12 15 18], [6 15 24]', 15 and 15 columnSum([0...
Modify the algorithm to solve the problem of finding the k-th largest number in array A, 1≤k≤n, without sorting the entire array. Partsof the algorithm are given below. Fill in the blanks. Select-k-th-largest(A: Array [1..n] of numbers) 1 for _____________________ 2 ________________ 3 for _____________________ 4 if _______________ then ___________ 5 if position ≠ i then 6 temp=A[i] 7 A[i]=A[position] 8 A[position]=temp
need help in this algorithm question
Let A be an array containing n numbers (positive and negative). Develop a divide and conquer algorithm that finds the two indices 1 sisjsn such that A[k] (the sum of the elements from i to j) is maximized. For example, in the array A [10,-5,-6,5, 7,-2,4, -11], the sub-array A[4:6] has the sum 5+ 7-2+4-14 and no other sub-array contains elements that sum to a value greater than 14, so for this input the...
Write a Java program to input a number of values into an array and then process the array by passing it to various methods that will compute and return information we are interested in. These include: 1. the average of the values in the array 2. the standard deviation of the values in the array 3. the number of items in the array less than the average 4. whether the array’s values are in increasing order or not First, you...
Help pls for assignment
2. Write an algorithm to display up to 10 user inputs 3. Write an algorithm to display print first 5 items in a collection. 4. Write an algorithm to read in 3 numbers. Display the largest number.
Suppose we have an array that contains tuples. These tuple contains three positive numbers. Implement an algorithm that counts how many distinct tuple that an array has(contains same number in same order). ex) [(1, 2, 1), (2, 2, 2), (3, 8, 3), (1, 2, 1), (3, 4, 3)] gives 4. 1 The algorithm should be implemented in Python3. 2 The function must have average-case runtime of O(n). You can assume Simple Uniform Random Hashing. 3 Python built-in dictionary cannot be...