int a[10]={23, 45, 10, 0, 98, 36, 2, 56, 34, 12}; for (int i=0; i<9 ; i++) for (int j=0; j<9; j++) if (alj] > alj+1]) swap(&a[j], &a[j+1]); end-if end-for end-for Convert the following code into descriptive code, and verify using White Box Testing. a = 2 b= 10 c = a * b for(i=a, i
Q: # Help me finish the getMin getMax get StandardDeviation getSortedResampleMeans…
A: Coded using Java language.
Q: #include using namespace std; //function to sort elements of array void sort(int a[], int n) { int…
A: 1. Start2. Declare an array a[] to store integers.3. Read the number of elements, n, from the…
Q: this is basically compueter architecture add main code and functions to randomly populate a .space…
A: this is basically compueter architecture add main code and functions to randomly populate a .space…
Q: make flowchart for this one plz #include int sortingbook(int array[], int N) { int count = 0, i…
A: Flow chart is a step by step diagramatic process of the algorithm which is represented with the…
Q: Count the divisions double fct (const double A[], int n) { } if (n == 0 ) return 1 else return (A…
A: Base case for recursion is when n = 0, in which case the function returns 1.
Q: Java Insertion Sort but make it read the data 12, 11, 13, 5, 6 from a file not an array // Java…
A: Please find the answer below :
Q: 181272 17 18 19 20 23 24 /** Returns the sum of the prefix sums of given array. */ public static int…
A: Big-oh characterization: It is one of the types of asymptotic notation, it is being used to…
Q: In searching an element in an array, linear search can be used, even though simple to implement, but…
A: BELOW STEP BY STEP COMPLETE SOLUTION REGARDING YOUR PROBLEM WITH EXPLANATIONS :
Q: For a recursive binary search, put the following code in the correct order by dragging each line to…
A: - We need to rearrange the code lines to make the recursive binary search work.
Q: First, open hash.h file and read it. Create a file named hash.c and write the following functions: •…
A: SHA_40 is a hashing algorithm which takes an input of arbitrary length and generates a 40-bit hash…
Q: Convert to C language #include using namespace std; //hash function 2 int main() { int n;…
A: Here I have prompted the user to enter a number. Next, I have taken integer input from the user and…
Q: 6 - Merge sorted arrays Program a method merge_sorted(a,b) that when given two sorted arrays a and…
A: #include <iostream> using namespace std; void merge_sorted(int arr1[], int x, int arr2[], int…
Q: Input: Array A storing n >= integers Output: The sum of elements in A /*line 1*/ S=A[0] /*line 2*/…
A: The solution for the above given question is given below:
Q: What does the following code? void xxxx(int arr[], int index[], int n) { int temp[n]; for (int…
A: Objective: Here, a function is given, and the outcome Answer: Here, the array named 'index' will…
Q: void countSort(int arr[], int n, int exp) { intoutput[n]; inti, count[10] = { 0 }; for (i=0; i=0;…
A: converting the given C code for Counting Sort into MIPS assembly language. Counting Sort is a…
Q: Question b T [40 10 20 80 60 5 50 55] Given an array T, draw diagram that shows how partition…
A: Actually, array is a collection of elements. Given array is a T [40 10 20 80 60 5 50…
Q: plz do not copy from chegg #include using namespace std; void WaitingTime(int processes[], int n,…
A: This is required code. See below steps for complete code.
Q: int sum, k, i, j; int x[4] [4]={5,6,7,8},{1,2,3,4},{9,8,7,3},{2,1,7,1}; sum=0; for (i=1; i x[i-1][j]…
A: sum is initilized to 0 The x is a 2D array given as follows i↓ j→ 0 1 2 3 0 5 6 7 8 1 1 2 3…
Q: { if(used capacity) { resize((1.5*capacity) + 1); } if(current index >= used) current_index = 0; { }
A: we must declare sequence variables them before using them . Below program is a similar example:
Q: 1: |R|←|P| Reserve space for |P| = 13 values. 2: x ← n 3: for i ← 0 ...(|P| − 1) do 4: c ← x div…
A: A Java programmer could implement Algorithm by first modelling the primitive numbers with the…
Q: Describe in English what func does, and what is guaranteed to be true (or not) after it runs. Don't…
A: Vector : During the run time, size changes. when appending elements, the vector automatically…
Q: 38 39 } CodeCheck public public static double [] makeAverage (double [] testl, double[] test2) } //…
A:
Q: I := 1; while I = i do { } I++; Data [J] :=Data [J] *2; Writeln (Data [J]); J--;
A: In this question we have been given an algorithm and we need to determine the runtime function and…
Q: Show the array [2, 4, 1, 5. 31 after the for loop in pancake_sort executes once. What is the…
A: Define find_max function:Initialize max_index to 0.Iterate through the array from index 0 to length…
Q: def count_inversion (art); 2. arr=[i fori i in arr if i !=o] 3. inversion=[ ] 4. for i in…
A: Given 2nd line: arr=[i for i in arr if i !=0] This will store all the non-zero elements of arr in…
Q: Python Program a method merge_sort(a,b) that when given two sorted arrays a and b, returns a new…
A: Given array of elements a = [1,3,5,6,10]b = [1,4,6,8] the resulting array should be: c =…
Q: C PROGRAM Implement the sortAscending Function #include void swap(int*, int*); void…
A: Assume the first element as the maximum value in the array. Iterate through the array to find an…
Q: ng namespace std; int main(int argc, char const *argv[]) { int n; cin>>n; // since the…
A: The code you provided is used to find the divisors of a given number n. Here's an explanation of the…
Q: int partition (int arr[], int low, int high). { } void sort(int arr[], int low, int high) { int pi=…
A: I have written code below:
Q: 10. A() { For (I = 1; I< = n; 1++) For (j =1;j< = n: j = j+i) Pf ("discrete"); }
A: Question:-
Q: Simulation parameters: •Define a step size h. Try something small like 0.001 seconds. Define a…
A: You have presumably gone over the mean previously; it is the most usually utilized kind of normal…
Q: Explain line 6,7 and 9. What is arrPos + n?
A: Pair is a c++ utility used to combine two values which may be different in type. Pair provides a way…
Q: //go method to be used to process a two-dimensional array public static int go (int[] [] Mat) { int…
A: EXPLANATION: In the given go function, their are two for loop out of which one is outer loop and…
Q: C PROGRAM Implement the sortDescending Function #include void swap(int*, int*); void…
A: NOTE: Student only asked to implement the sortDescending Function. So I can provide only the…
Q: The following procedure sums up all the prefix of an array a into a vector p. The loop body has some…
A: In this question we have to write a modified code to increase the performance of this c++ code for…
Q: Single number (use XOR):
A: One can easily solve this question using the naive algorithm. But the solution for O(1) extra memory…
Q: ) Consider the following C code snippet. void swap(int *xp, int *yp) { int temp = *xp;…
A: In this RISC-V assembly language implementation, converted a given C code snippet into assembly…
Q: 3. Write the following code using forEach(). for (let i=0; i<line.length; i++) { let s = line [i]…
A: Use ES6 function representation for forEach(). Syntax:- list.forEach(variable=>statements) ;
Q: 3. Given the following sequential code: int A[100], B[100]; int C=0; for (int i = 0; i <m; i++) {…
A: The sequential code parallelized using OpenMP is mention in step 2
Q: I have issus with this code: void rec(int n) { if(n==1) { cout<<1; return; } cout<<n<<" ";…
A: Given code: void rec(int n) {if(n==1) {cout<<1;return;}cout<<n<<"…
Q: ALGO1(A)// A is an integer array, an index that starts at 1 1): for i=1 to n-1 do 2): minIndex =…
A: An algorithm is a finite series of exact instructions that is used in mathematics and computer…
Step by step
Solved in 2 steps
- for (c = 0; e array(d]) position - d; if (position !- c) array[c]; swap = array[c) - array position] - swap; array(position];Convert C++ function to Python void counting(vector<vector<char>> &board) { for(int i = 0; i < rows; i++) { for( int j = 0; j < columns; j++) { int count = 0; if(board[i][j] == '0') { if(i+1 < rows && board[i+1][j] == 'X') count++; if(i-1 >= 0 && board[i-1][j] == 'X') count++; if(j+1 < columns && board[i][j+1] == 'X') count++; if(j-1 >= 0 && board[i][j-1] == 'X') count++; if(i+1 < rows && j+1 < columns && board[i+1][j+1] == 'X') count++; if(i+1 < rows && j-1 >= 0 && board[i+1][j-1] == 'X') count++; if(i-1 >= 0 && j+1 < columns && board[i-1][j+1] == 'X') count++; if(i-1 >= 0…Restrict unknown and illogical code. Asking third times. Make sure of correct code.
- Figure 2 void sort_Algo (int anArray[], int n) { int i, j, idx; for (i = 0; i anArray[ idx ]) idx = j; Swap (anArray[ idx ], anArray[ i ]); } } int main() { const int n = 8; int anArray[n] { -9, 14, 52, 106, 22, -1, 99}; sort_Algo(anArray, n); } Name the sorting algorithm exercised by the sort_Algo() function. * Your answer Determine if anArray[] is to be sorted into ascending, or descending order. Your answer Trace the sorting algorithm in Figure 2 as it sorts anArray[]. (Answer the question according to the format, eg. Pass 0:3, 3, 3; Pass 1: 3, 3, 3; Pass2: 3, 3, 3;) * Your answerint g(int nums[], int n) { if (n == 1) return 0; int val = g(nums, n-1); if (nums[n-1] > nums[val]) return val; return n-1; } Give a recurrence T(n) for the number of times the code nums[n-1] > nums[val] is executed when the array values are in ascending order. Then solve the recurrenceQ3: Matrix a= [1 3 5; 2 4 6] b=[0 0 0; 11 1]....... a+b is equal :- C=[ 1 2 3; 3 5 7] a+b=[1 3 5; 3 5 7] ans [ 1 3 5; 3 5 7] This is a required question ! *void func(vector<string>& names){ sort(names.begin(), names.end()); //(a) for(int i = names.size() - 1; i > 0; --i){. //(b) if(names[i] == names[i - 1]){ names[i] = move(names.back()); names.pop_back(); } } } What are the reasons or consequences for the programmer’s choice to loop backwards in the line marked (b), and under what circumstances would the algorithm behave differently if that line were replaced with: for (int i = 1; i < names.size(); ++i) ? What would change?please convert the code to C language //C++ program to check if two arrays //are equal or not #include <bits/stdc++.h>using namespace std; bool similar_array(vector<int> arr1, vector<int> arr2){ //create teo different hash table where for each key //the hash function is h(arr[i])=arr[i] //we will use stl map as hash table and //will keep frequency stored //so say two keys arr[0] and arr[5] are mapping to //the same location, then the location will have value 2 //instead of the keys itself //if two hash tables are exactly same then //we can say that our arrays are similar map<int, int> hash1; map<int, int> hash2; //for each number for (int i = 0, j = 0; i < arr1.size(); i++, j++) { hash1[arr1[i]]++; hash2[arr2[i]]++; } //now check whether hash tables are exactly same or not for (auto it = hash1.begin(), ij = hash2.begin(); it != hash1.end() && ij != hash2.end(); it++, ij++) {…4. Please explain the spatial and temporal locality in general. Please identify and explain the localities in the following example.- int a[N]; For (i 0; iEvaluate the performance per lineSelect the appropriate code that performs selection sort. a) int min; for(int j=0; j<arr.length-1; j++) { min = j; for(int k=j+1; k<=arr.length-1; k++) { if(arr[k] < arr[min]) min = k; } int temp = arr[min]; arr[min] = arr[j]; arr[j] = temp; } b) int min; for(int j=0; j<arr.length-1; j++) { min = j; for(int k=j+1; k<=arr.length; k++) { if(arr[k] < arr[min]) min = k; } int temp = arr[min]; arr[min] = arr[j]; arr[j] = temp; } c) int min; for(int j=0; j<arr.length-1; j++) { min = j; for(int k=j+1; k<=arr.length-1; k++) { if(arr[k] > arr[min]) min = k; } int temp = arr[min]; arr[min] = arr[j]; arr[j] = temp; } d) int min; for(int j=0; j<arr.length-1; j++) { min = j; for(int k=j+1; k<=arr.length; k++) { if(arr[k] > arr[min]) min = k; } int temp = arr[min]; arr[min] = arr[j]; arr[j] = temp; }Recommended textbooks for youDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag…Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill EducationDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag…Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education