int a[100], b[1000], c[1000]; // get some data for a, b, and c 0; i < 100; i++) for (j for (i %3D = 0; j < 10; j++) a[i] += c[j*100 + i] * b[j*100 + i] ;
Q: What does .compare do in c++? for example in this sorting function void employeeSort(string…
A: Compare: “compare()” function is one of in-built function that is used to compare the strings. It…
Q: OverflowS You have learned the concept of overflow (with say n! that overflows at 13! for integer)…
A: 1 In Java short range is from -32,768 to 32,767 thus when it encounters this full range then the…
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: Overflows You have learned the concept of overflow (with say n! that overflows at 13! for integer)…
A: In fibonacci series next number is the sum of previous two numbers.
Q: Elements in Ascending Order { int a[10000].i,n.j.temp; scanf("%d", &n); for(i=0;ia[j+1]) {…
A: Here we have two nested loop i and j.
Q: Suppose array a is int[] a = {1, 2, 3, 5, 7}, what is a[0] - a[2]? A. -2 B. 1 C. 2 D. -1
A: Lets see the solution in the next steps
Q: Consider an array of size n. Write a function that takes n values as input for the array, swaps…
A: Consider an array of size n. Write a function that takes n values as input for the array, swaps…
Q: The Pascal triangle can be used to compute the coefficients of the terms in the expansion (a + b)".…
A: Write the C program to Pascal triangle to compute of the terms in the expansion (a+b)2
Q: Write a program that reads a list of integers, and outputs those integers in reverse. The input…
A: #include <stdio.h>#include <stdlib.h> int main() { int a[20]; int n; int i; scanf("%d",…
Q: In java: Write a program using a Scanner that asks the user for a number n between 1 and 9…
A: Introduction of Program: In the above Java Program, the user will enter the number of rows then the…
Q: Write a program using c# to do the following: Initialize an array A with 10 elements. Initialize an…
A: Structured exception handling is supported in C#, as it is in C++. You write code surrounded by…
Q: Let A={1,2,3...,10}. How many subsets B of A where B = │4│and the smallest element in B is 4?…
A: 1) The smallest number in the subset should be 4. It leaves the following elements to be chosen…
Q: Write C++ program that implements the histogram of the given array. 1: X is 1 by 10000 integer…
A: Code : #include <bits/stdc++.h>using namespace std; void printHistogram(int arr[], int n){…
Q: a. System.out.println (x); for (int i -0; i < x.length - 1; i++) System.out.println (x); for (int i…
A: EXPLANATION: The index in the array starts from 0 and goes up to n-1 where n is the total number of…
Q: C++ Given a positive integer, N, the ’3N+1’ sequence starting from N is defined as follows: If…
A: #include <iostream>using namespace std;int sequence(int N){ int x,count = 1;…
Q: Question 2.1 Given a positive integer, N, the '3N+1' sequence starting from N is defined as follows:…
A: #include <iostream>using namespace std;int sequence(int N){ int x,count = 1;…
Q: 2) We consider the following code: public void Sorting(Object[] data) { for (int i = 0; i i; -j) if…
A: Bubble sort is a simple sorting algorithm that can be used as a rearrangement of the set of elements…
Q: A decreasing sequence of numbers is a sequence of integers where every integer in the sequence is…
A: while ( true ) { ... if ( Condition ) { break; } ... } The above while-loop…
Q: 6, 20, 24, 28, 32, 36, 40, 44, 48} and int B[4][3] = {5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35,…
A: We can have the general formula as, C[m][n]=A[m][n]+2*B[m][n] [from given int C[4][3] = A[4][3] +…
Q: Pointers, modified) by Catherine Arellano We have a new game show that pits three people against…
A:
Q: 10. Given a list of unsorted integers, find the pair of elements that have the smallest absolute…
A: Coded using Python 3.
Q: Write a function that divides an array into chunks of size n, where n is the length of each chunk.…
A: 1. create the method with 2 array 2. create a new array 3. Iterate on the arr argument 4. new res…
Q: please help me public static void main(String args[]){ int[] x={1,4,88,9,13,77,4,18};…
A: Given code time complexity is O(n). We are providing the time complexity is O(login).
Q: Write a function SWAP (int ARR[ ], int Size) in C+ to modify the content of the array in such a way…
A: The Answer is
Q: In C++ Consider an array of size n. Write a function that takes n values as input for the array,…
A: C++ code: #include <iostream> using namespace std; //function to swap adjacent elements void…
Q: Program in C Write a program that does the following: Creates int array array_1 of length 10.…
A: Program code: //including header files #include<stdio.h> //main method int main() {…
Q: int A[10] = { 3,2,1,0,4}; int *p = &A[3]; %3D
A: Required:
Q: Write a program in c++: A-In permutations and combinations, the term “n C r” refers to n…
A: /* C++ program to calculate the value Of nCr */ #include <bits/stdc++.h> using namespace std;…
Q: Example input and output: Enter a value for n: 3 3, 10 , 5, 16 , 8, 4, 2, 1 Number of terms: 8…
A: #include <iostream>using namespace std;int sequence(int N){ int x,count = 1;…
Q: A set of integers may be implemented using an array of integers. Since the array is only partially…
A: set.h Code: #include<stdio.h> typedef int Set[100]; //Function dclarations void…
Q: in Python Minima in permutations. Write a program that takes an integer n from the command line,…
A: Code is written in python below- #importing random module import random def generateRandom(n): #…
Q: R6.3 Consider the following array: int(] a - { 1, 2, 3, 4, 5, 4, 3, 2, 1, 0}; What is the value of…
A: As per our honor code, we are answering the first 3 subparts. (a) Given snippet of code: int total…
Q: Implement the sieve of Eratosthenes: a function for computing prime numbers, known to the ancient…
A: the code is an given below : #importing copy to create shallow copy # and math to use sqrt() import…
Q: Question 2.1 Given a positive integer, N, the "3N+1' sequence starting from N is defined as follows:…
A: The program is written in c++
Q: Java only Rajesh loves lucky numbers. Everyone knows that lucky numbers are positive integers whose…
A: Coded using Java language.
Q: Write a program that lists all Fibonacci numbers that are less than or equal to the number k (k≥2)…
A: Write a C program that lists all Fibonacci numbers that are less than or equal to the number k (k≥2)…
Q: Q2. By applying the concept of array in C language, kindly examine below equation with a C program…
A: //C Source Code :- #include<stdio.h> #include<math.h> /*function to find equation f(x)…
Q: The Pascal triangle can be used to compute the coefficients of the terms in the expansion (a +…
A: Write a C program that creates a two-dimensional matrix a representing the Pascal triangle of size…
Q: What value does f2 return when it is passed an array of integers A = {1,2, 3, 4, 5, 6, 7, 8, 9, 10},…
A: Correct answer is : Option b - 21
Q: Explain this c code in details. #include int main() { int max_weight_truck, n; scanf("%d",…
A: #include <stdio.h> int main() { int max_weight_truck, n; scanf("%d", &max_weight_truck);…
Q: Count consecutive summers def count_consecutive_summers(n): Like a majestic wild horse waiting for…
A: Coded using Python 3.
Q: What is the complexity of the following code segment (assume all the libraries are included)? int x…
A: The correct option is
Q: In Java, Apply replacement selection sort to the following list assuming array size M = 3; 27 47 35…
A: The algorithm are: Register are filled with records and input to be sorted. All register are put…
Q: 5 - a) 2 4 5 3 3 c) 6 12 15 9 int arr[4]= {2, 4, 5, 3}; for (int i= 0; i<4; i++) cout<<arr[i] * 3< "…
A: Question 5:int arr[4]={2,4,5,3};for(int i=0;i<4;i++)cout<<arr[i]*3<<" ";Answer:6 12…
Q: Implement an empty integer array of capacity 5. a) Use a loop to input values from the console into…
A: #include <iostream> using namespace std; int main(){ //creating array int a[5];…
Q: .The following is the C code that you need to implement for this lab: uint8_ t f(uint8_tn)…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Count consecutive summers def count_consecutive_summers(n): Like a majestic wild horse waiting for…
A: Actually, python is a easiest programming language. It is a dynamically typed programming language.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- Please Help In JAVA Here is the skeleton of a code for insertion sorting in a functional language. You have to add right lines of codes for the language you choose (C, C++, C#, JAVA etc,). The following sample is for C++ (define (insert L M) (if (null? L) M (if (null? M) L (if (< (car L) (car M)) (cons (car L) (insert (cdr L) M)) (cons (car M) (insert (cdr M) L)))))) ;; Exp. (insertionsort '(4 2 10 3 -1 5)) ==> (-1 2 3 4 5 10)(define (insertionsort L) (if (null? L) '() (insert (list (car L)) (insertionsort (cdr L))))) (define (random-list n) (unless (exact-nonnegative-integer? n) (raise-argument-error 'make-list "exact-nonnegative-integer?" 0 n)) (let loop ([n n] [r '()]) (if (zero? n) r (loop (sub1 n) (cons (random 2147483647) r))))) Sample function call:(insertionsort (random-list 10000)) Hint: most languages have some function to determine the runtime of functionsImplement in C Program 5.20 LAB: Word frequencies Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins with an integer indicating the number of words that follow. Assume that the list will always contain fewer than 20 words, and each word contains fewer than 10 characters. Ex: If the input is: 5 hey hi Mark hi mark the output is: hey - 1 hi - 2 Mark - 1 hi - 2 mark - 1 Hint: Use two arrays, one array for the strings and one array for the frequencies. #include <stdio.h>#include <string.h> int main(void) { /* Type your code here. */ return 0;}Using Dr-Racket, what is the purpose of the number function?(define (number n)(local [(define (abstract int)(* int 11))] (build-list n abstract))) A) Create a list of the first n multiples of 11 starting at 11. B) Create a list of the first n multiples of 11 starting at 0. C) Create a list of the first n multiples of 11 starting at 1. D) Create a list of the first 11 multiples of n starting at 1. E) Create a list of the first 11 multiples of n starting at 0.F) Create a list of the first 11 multiples of n starting at n.
- Write a program in C++ that reads a list of 10 names from a file and stores them in an array. Next, allow the user to search for the number of instances of a name. The program should prompt a user for a name and output the total number of instances of that name entered to the screen and to a file (see example input and output below). It should continue to prompt for names until the word done is typed in. For this lab, use the string data type as opposed to char to store the names (i.e. don’t use c-strings). INPUT FILEJoe Sally Joe Sue Sally Adam Joe Adam Adam Joe OUTPUT FILE (There should be 10 spaces between the columns) 8. NAME INSTANCES 9. ---- --------- 10. Joe 4 11. Sally 2 12. Adam 3 13. Sue 1 14. John - Expected outputWrite a program in C++ that reads a list of 10 names from a file and stores them in an array. Next, allow the user to search for the number of instances of a name. The program should prompt a user for a name and output the total number of instances of that name entered to the screen and to a file (see example input and output below). It should continue to prompt for names until the word done is typed in. For this lab, use the string data type as opposed to char to store the names (i.e. don’t use c-strings). Input FileJoeSallyJoeSueSallyAdamJoeAdamAdamJoe Output File (be sure to output the class heading to the output file) (There should be 10 spaces between the columns) 8. NAME INSTANCES9. ---- --------- 10. Joe 411. Sally 212. Adam 313. Sue 114. John - Expected output in image belowdef find_root4(x, epsilon): ''' IN PYTHON Assume: x, epsilon are floating point numbers and epsilon > 0 Use bisection search to find the following root of x such that If x >=0, return y such that x - epsilon <= y ** 2 <= x + epsilon Else, return y such that x - epsilon <= y ** 7 <= x + epsilon Note: You must use bisection search to implement the function. ''' pass
- Modified Recursive Binary Search • Write C++ program hw7.cpp that meets the following requirements: – First, write a recursive binary search function with the following prototype: int binarySearch(int array[], int first, int last, int value); – Now suppose we have a sorted array like this: int a[SIZE] = { 3, 5, 7, 9, 22, 22, 22, 22, 30, 35, 51, 52, 73 }; – Then the following statement int index = binarySearch(a, 0, SIZE-1, 22); – would return one of the indices that match the target value (22), and it could be index 4, 5, 6, or 7. – Now, your mission is to modify this recursive binary search function to always return the leftmost index when there are multiple indices that match the target value. Thus, in the above case, the function must return index 4. – If no match found, the function returns -1. – Write a main function that checks if your modified binary search function works as expected with at least 3 example arrays. – Note: your modified binary search function must ensure the…In java: Develop a function that accepts an array of integers and returns their average. Develop a function that accepts an array of integers and a threshold value from the user. The function returns how many values in the array are strictly greater than the cutoff. Using the functions written for #1, #3, and #4, find the number of values above average in two randomly generated arrays. Develop two functions:a. a function that returns the index of the maximum value in an array of integers passed by a caller, the caller prints the returned index and the value at that indexb. a function that returns the index of the alphabetically first value in an array of strings, the caller prints the returned index and the value at that inde Develop two functions:a. a function that swaps the alphabetically first value in an array of Strings with the first value in the array. Call this function twice on two different arrays of Strings; in the caller, use the function written for #2b to display…Write program in C compatible with quincy please. Exercise 2: Write a program to store an input list of ten integers in an array; then display a table similar to the following, showing each data value and what percentage each value is of the total of all ten values. n % of total 4 2.00 12 6.00 18 9.00 25 12.00 24 12.00 30 15.00 28 14.00 22 11.00 23 11.00 10 5.00
- Please Help In JAVA Here is the skeleton of a code for insertion sorting in an imperative language. You have to add right lines of codes for the language you choose (C, C++, C#, JAVA etc,). The following sample is for C++. #include <iostream>#include <array>#include <stdio.h>#include <stdlib.h>#include <ctime>using namespace std; void insertionSort(int A[], int n){for (int i = n-2; i >= 0; i--){ int j; int v = A[i]; for (j = i + 1; j <= n-1; j++) { if (A[j] > v) break; else A[j-1] = A[j]; } A[j-1] = v;}} int *randomArray(int n){srand((unsigned) time(0));int * A = new int [n];for (int i = 0; i < n; i++){ A[i] = rand();}return A;} Sample function calls (call these functions in main driver function):int n = 100000;int * A = randomArray(n);insertionSort(A, n);delete [] A; Note: delete memory of first array before sorting second array. After you modify the code: (1) Generate 100, 000 random numbers and sort them (2) Generate 300000…int a[10] = {0,1,2,3,4,5,6,7,8,9};int *m = &a[0];int *p = &a[5];int *q = &a[1]; p = (int) m + (int) p - (int) q; what is the value of of *pWrite a program named as reverse.c that reads a message, then prints the reversal of the message. The output of the program should look like this: Enter a message: Don ’t get mad, get even. Reversal is : .neve teg ,dam teg t ’noD Hint: Read the message one character at a time (using getchar) and store the characters in an array. Stop Reading when the array is full or the character read is ‘\n’. The framework of reverse.c is as below: /* reverse.c */ #include #define N 50 int main(){ int arr[N],i=0; char ch; printf("Enter a message: "); /* Put code here to get input from user by using getchar() */ printf("Reversal is: "); /* Put code here to print out the reversal by using putchar()*/ printf("\n"); return 0; }