1. /15 points] Consider the following function: Func1(A, n) * A is an array of integers 1 80; 2 for m 1 to 10 do k Random(n); for i1 to do j1 while (jn) do ssA[A[j]; j2*j; 3 4 5 6 7 8 end end 10 11 end 12 return (s); (a) What is the asymptotic worst case running time of Func1? (b) What is the asymptotic expected running time of Func1? Justify your solution
Q: Code in Python Q) Write a function to sort given array using Insertion sort algorithm and returns…
A: A function to sort given array using Insertion sort algorithm and returns the sorted array :- #…
Q: You are given an array called source, with length n, and a set of m arrays called target, each also…
A: #include <stdio.h>int check(int *source, int *t,int n){// sort the two arraysfor (i = 0; i…
Q: Given a vector V of N integers. Write a C function that displays on the screen all the sub-vectors…
A: This problem can be solved by nested while and for loops. Dynamic memory allocation for array is…
Q: 9. Consider the following function: int rec(int array[], int n) { int p; if (n < 0) if (array[n] <…
A: Output: 108050404090170180180 Recursive function call tree:
Q: С. Problem i. Given are group of integers separated by space and a single integer, store the group…
A: Python is a high-level standard programming language that is interpreted. The development model of…
Q: Consider an integer array a of length n with indexing starting at 0, where n is a positive integer.…
A: As per the company guidelines answer will be provided to the only one question. Please ask another…
Q: Given an array of ints, return the number of times that two 6's are next to each other in the array.…
A: Given: Given an array of integers. int n[] = {2, 6, 71, 6, 6, 6, 34, 6, 6, 89}; Requirement: Write a…
Q: Consider an array consisting of the following sequence: 1, 4, 9, 16, 25, 49, …, n [10]…
A: The given elements are the square of a number that is: 12 = 1, 22 = 4, 32 = 9, 42 = 16... and so on…
Q: // function to generate all subsequences of given array function generate_subseq(arr): // length…
A: Please upvote. I am providing you the correct answer below.
Q: You are given an array called source, with length n, and a set of m arrays called target, each also…
A: Step-1: Take the input for the source and the set of targets. Step-2: Find the minimum value in the…
Q: Write a program / Pseudo code / Algorithm that inserts the following numbers into two Separate…
A: Sample Response: //C++ program to computes the median of two array with all adjacent elements,…
Q: Solution should in JS Write a function that divides an array into chunks of size n, where n is the…
A: As per the given question, we need to write a function named chunkify() that takes an array i.e arr…
Q: Consider 2 two-dimensional integer arrays, x and y, of the same size (assume 3 by 4). Fill array x…
A: Use a srand() function to create the starting point to generate the random numbers. Take 2 2D…
Q: Write C++ Program and Test the following function: void multiply (float a[ ], int n, float b[]); The…
A: Problem Analysis : First, we will input the size of both the arrays. Then we will input the value…
Q: 1. Given a circular array of integers, do the following operations stepwise: Value ] 25 ] a + 15 ]…
A: TO REMOVE AN ELEMENT FROM CIRCULAR ARRAY BY LEFT / RIGHT SHIFTING.
Q: 6.18 Let A be an integer array with N elements. Suppose X is an integer function defined by [0 if K…
A: Answer: Given X(K) = X(A,N,K) = 0 if K =0 X(K-1)+A(K) if 0<K<=N…
Q: Find the number of super values in vectorv where an array element is super if it is greater than all…
A: Keep a variable maxRight and traverse the array from right to left. If any array element is greater…
Q: Plot the result of (given) selectionsort(A) when A is a perfectly sorted and contains randoms…
A: 1. create empty list for storing input size 2. create empty list for storing output size 3. declare…
Q: Let A be an array of integers of size 10, whose ith entry is represented by A[i] for i = 0 to 9, and…
A: - According to the rules, we have to check for the element 85 position in the array.
Q: You are given an array called source, with length n, and a set of m arrays called target, each also…
A: 1. Find Minimum elements for every possible (x) in Target[x] and store those elements in an array…
Q: Solution should in JS Write a function that divides an array into chunks of size n, where n is the…
A: The Javascript code is given in the below step with code and output screenshot.
Q: Attached photo is the question. Please help. Thanks. Binary Search Tree code: // // Example of an…
A: The answer is given below:-
Q: Read in two integers n and m (n, m < 50). Read n integers in an array A. Read m integers in an array…
A: Intersection finds all the common elements in A and B array. Union finds all the elements of A and B…
Q: 4. Consider the Quick-sort algorithm, which partitions elements into two sub-arrays, each of which…
A: Given each time one fifth is one subarray and rest i.e. 4/5th ( 1 - 1/5 = 4/5 ) is second array and…
Q: Given an Array M of 99 int values, and int *pit: 1. Declare two pointers p1 and p2 2. Make p1 point…
A: C++ code to solve the above problem is given below. ***Note: We can solve max 3 sub-parts…
Q: Question 2: The game of "FastestPath" consists of a path (a 1-D array) with n positive integers to…
A: #include<iostream>using namespace std; int calculate(int path[], int s, int i, int n){…
Q: Assuming we have found the position in the array s containing the same value stored in the variable…
A: Here, I have to choose an option to the above question.
Q: Following is the partition function for quicksort, where we have used the leftmost number as a…
A: The answer is 7, 8, 9, 14, 15, 22, 38 here 14 is pivot element ,the element less than 14 are on…
Q: You are given an array called source, with length n, and a set of m arrays called target, each also…
A: Step-1: Take the input for the source and the set of targets. Step-2: Find the minimum value in the…
Q: A two-dimensional array, A, has N rows and N columns, where N is a positive integer. The following…
A: Algorithm: Start Read n value Declare 2d array a[n][n] Initilaize k=1 Iterate through the matrix…
Q: Suppose N is a (6x3) matrix array. This program segment print the locations of the negative…
A: In this question we should nested loop: Nested Loop: A nested loop is one that is enclosed within…
Q: Suppose N is a (6x3) matrix array. This program segment print the locations of the negative…
A: Given a 6x3 matrix, we have to print the location of negative numbers in the matrix. A number is…
Q: Q5. Given an array of N elements. Get an integer K form user such that K<N. Now shift the elements…
A: C++ Program for above : #include <iostream> using namespace std; //it will rotate array…
Q: Suppose N is a (6x3) matrix array. This program segment print the locations of the negative…
A:
Q: You are given an array called source, with length n, and a set of m arrays called target, each also…
A: Actually, given information is where n=5 and m=6. source = [14, 13, 15, 11, 12]target[0] = [4, 2,…
Q: Read in two integers n and m (n, m < 50). Read n integers in an array A. Read m integers in an array…
A: #include <stdio.h> int main(){ int a[50], b[50],m,n,i,j; int x,y,z; printf("Enter…
Q: f(x) = 1/(1+25x?) This is a somewhat famous function in numerical analysis because it displays…
A: Here is the answer:- here n=10 and given f(x) value.
Q: . Consider an array of 66000 sorted entries. What is the maximum number of comparisons that must be…
A: Here is the explanation of solution.
Q: 1- Consider the following function : f (n) = 10n + 2n -20 For which positive integer m can you say…
A: Solution:- As, f (n) = 10*n6 + 2*n4 - 20 Thus, for m=6, we can say f (n) is O(nm). Also m = 6 for…
Q: Given a triplet of integers (X , Y , Z), such that X ≤ Y and Y ≥ Z, we define f(X , Y , Z) to be (X…
A: Required: Given a triplet of integers (X , Y , Z), such that X ≤ Y and Y ≥ Z, we define f(X , Y , Z)…
Q: You are given an array called source, with length n, and a set of m arrays called target, each also…
A: Solution : (a) Algorithm : 1. Find Minimum elements for every possible (x) in Target[x] and store…
Q: 2. Consider the Quick-sort algorithm, which partitions elements into two sub-arrays, each of which…
A: Here, we are going to find out the recurrence relation using quick sort for the given partitions.
Q: Question 2: Given two arrays a and b, where both arrays consisting of n positive integers. It is…
A: ANSWER:- SEE STEP NO 2
Q: Suppose you have given a circular array of integers where start and size is given. You need to find…
A: You have not mentioned any language to be used for coding but description shows that you want it in…
Q: Consider an array consisting of the following sequence: 1, 4, 9, 16, 25, 49, …, n Suppose a number…
A: So a) Iterate the array and check if a[i] == i^2 or not
Q: Q.1: Write a program to set 100 in the upper triangular of a given matrix a(4,4). For example array…
A: #include <iostream>using namespace std; int main() { // your code goes here int a[4][4];…
Q: Let M(n) be the minimum number of comparisons needed to sort an array A with exactly n ele- ments.…
A: Given : M(n) = 2M(n/2) + n/2 Case 1: M(2)=1 As n=2, M(2)= 2M(2/2)+2/2 =2M(1)+1…
Q: Let M[1 .. n] be an array, where each entry contains either a positive or a negative integer. Assume…
A: In given problem, we have anarray M[1 .. n] , in this array, each entry contains either a positive…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- 1. Consider a problem of computing the prefix average of a sequence of numbers stored in an array P consisting of P integers. We want to compute an array P such that P is the average of P for P . Consider the two algorithms related to the above problem. Answer the questions given belowSuppose an array sorted in ascending order is rotated at some pivot unknownto you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element. The complexity must be O(logN)You may assume no duplicate exists in the array."""def find_min_rotate(array): """ Finds the minimum element in a sorted array that has been rotated. """ low = 0 high = len(array) - 1 while low < high: mid = (low + high) // 2 if array[mid] > array[high]: low = mid + 1 else: high = mid return array[low] def find_min_rotate_recur(array, low, high): """ Finds the minimum element in a sorted array that has been rotated. """ mid = (low + high) // 2 if mid == low:.Multiplying Factors For a pair of integers (x,y) and an integer k, the multiplying factor is defined as minimum positive integer m such that LCM(x,y) * m is divisible by k. Here LCM(x,y) represents the smallest positive integer divisible by both x and y, their least common multiple. Given an array arr of n integers and an integer k, find the sum of multiplying factors over all pairs of integers (arr[i], arr[j]) and k0 <= i,j < n. Example Suppose n=3, arr =[4,5,6] and k=12. Pair Multiplying Factor Remarks (4, 3 LCM(4,4)**3=4**3 =12 4 ) LCM(5,5)**12=5** 12=60 (5, 12 LCM(6,6)**2=6**2 5) (6, 2 12 6 )
- Write a nToArray function which does the following:1. Accepts an empty partially filled array, the size of the array and an integer n as input parameters.2. Recursively extracts each digit of n and stores the digit into the array in forward order.3. Assumes the partially filled array has an infinite capacity.ExampleIf n is 2534 the array will contain the values 2,5,3,4. in c++1) Consider an integer array a of length n with indexing starting at 0, where n is a positive integer.If the elements of array a are to be written out in reverse order, which of the following C++ code fragment does NOT do the job? Question options: a. int i=n-1; while (i>=1){cout << a[i] << endl; i = i-1;} cout << a[i] << endl; b. int i=n-1; while (i>=1){cout << a[i] << endl; i = i-1;} c. int i=n-1; while (i>=0){cout << a[i] << endl; i = i-1;} d. int i=n; while (i>0){cout << a[i-1] << endl; i = i-1;} 2) Assume we use 8-bit cell to store floating point numbers, 1 bit for sign, 3 bits for excessed exponent, and 4 bits for significand. What is the decimal value for a cell with bit pattern 0 111 1101 Question options: a. 125 b. 224…Find the complexity of the function used to find the k th the smallest integer in an unordered array of integer
- Plot the result of (given) selectionsort(A) when A is a perfectly sorted and contains randoms integers ,0 to 100 inclusive, for array sizes n = 2,4,8,16,..1024. please provide code for A and generating the plot for each doubling array, as well as the resulting plot. def selectionsort(A): for i in range(len(A)): min_idx = i for j in range(i + 1, len(A)): if A[min_idx] > A[j]: min_idx = j A[i], A[min_idx] = A[min_idx], A[i] return AH3. Let S = [x1, x2, x3, ...xn], where n ≥ 5. How many ways can you choose five of the values in the array S, given that x1 = x2 = x3 and all other xi are distinct? The order of the chosen elements does not matter) Consider the following C code snippet. void swap(int *xp, int *yp) { int temp = *xp; *xp = *yp; *yp = temp; } int findMinimum(int arr[], int N) { // variable to store the index of minimum element int min_idx = 0; int min_E = arr[min_idx]; // Traverse the given array for (int i = 1; i < N; i++) { // If current element is smaller than min_idx then update it if (arr[i] < min_E) { min_idx = i; min_E = arr[min_idx]; } } return min_idx; } /* Function to sort an array using selection sort*/ void selectionSort(int arr[], int n) { int i, min_idx; // One by one move boundary of unsorted subarray for (i = 0; i < n-1; i++) { // Find the minimum element in unsorted array min_idx = findMinimum(&arr[i], n-i); // Swap the found minimum element with the first element if(min_idx != 0) swap(&arr[min_idx+i], &arr[i]); } }…
- Please Help me with This Problem Language = C++ Take an array of name A of size 4 X 4. Take input and then take B with size 4 X 4. Add them.And show result after taking transpose.Formally, the i th row, j th column element of C T is the j th row, i th columnelement of C:1. write the rows of C as the columns of C T2. write the columns of C as the rows of C TC is an m × n matrix then C T is an n × m matrix.Then save the result in a file named “result.txt”, according the matrix spaces and newline. Note:Understand the Question Properly and Kindly Answer9.). integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no such subarray, return -1. A subarray is a contiguous part of an array. Example 1: Input: nums = [1], k = 1 Output: 1 Example 2: Input: nums = [1,2], k = 4 Output: -1 Example 3: Input: nums = [2,-1,2], k = 3 Output: 3.(1) The following code transposes the elements of an M × M array, where M is a con- stant defined by # define: void transpose(long A[M][M]) { long i, j; for (i = 0; i < M; i++)for (j = 0; j < i; j++) { long t = A[i][j]; A[i][j] = A[j][i]; A[j][i] = t; } } When compiled, with optimization level −O1, GCC generates the following code for the inner loop of the function. 1 .L1: 234 5 6 7 8 9 movq movq movq movq addq addq cmpq jne .L1 (%rdx), %rcx (%rax), %rsi (%rdx) (%rax) $8, %rdx $120, %rax %rdi, %rax %rsi, %rcx, We can see that GCC has converted the array indexing to pointer code. (a) Which register holds a pointer to array element A[i][j]? (b) Which register holds a pointer to array element A[j][i]? (c) What is the value of M?