Q.2 Consider the following statements on Array : S1: Array is static in nature whose size needs to be declared first. S2 : Increasing the size of array takes O(n) time. Now choose the correct option : S1 is correct and S2 is the reason of A S1 being correct. Both S1 and S2 are correct but they В are uncomparable. S2 is correct and S1 is the reason for S2 being correct. D S1 is correct but S2 is not correct.
Q: 13. Given that Array is defined as shown below, determine the content of Array after executing the…
A: Solution:
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: 7. Consider implementing a function to dynamically allocate an array of integers and set all its…
A: An array in terms of programming is a collection of variables(elements) that share the same type of…
Q: C++ We would like to write a void function, call it "makeNewArray", that will print a new array by…
A: It has been stated that the void function should print a list of the positions of the elements that…
Q: 2) We consider the following code: public void Sorting(Object[] data) { for (int i = 0; i i; --j) if…
A: The program is written in Java. The sorting flow is clearly printed in the output screenshot with…
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: Evaluate the given expression Given i=1, j=2 k=3, I=2, x=4, y=5 i == j && i + j == k || y == x + I…
A: Please find the answers in below steps
Q: Consider the following function reverse, that attempts to reverse an array in place (i.e. without…
A: Swap Function
Q: Q A: What is the starting index of ary Q B: What is the last index of ary Q C: Write statement to…
A: Starting index of ary:- 0
Q: HIT THE JACKPOT! PROBLEM: Create a function that takes in an array (slot machine outcome) and…
A: The function, testJackpot takes a string of slot outcomes as an array and then check if all are the…
Q: (3) There is a function void fnE(int i, int num) that runs in 1000-i steps, regardless of what num…
A: We have to calculate the total time in big-O of function fnA of variable n. To calculate Big O,…
Q: 5. Let x be an array. Which of the following operations are illegal? I. ++X II. x+1 III. x++ IV. x*2…
A: As we know here Statement I -> ++x will give an error after compilation . Here x will store the…
Q: Complete the following function definition to recursively print the index of a unique value in an…
A: we have to write all code in the blanks
Q: Q2: write program to find the largest no. in the array of int datanum, and record it in the assorted…
A: #include<stdio.h> int main() { int datanum[12]={31,28,29,25,31,22,34,35,38,21,29,30};…
Q: PYTHON CODE: In order to beat AlphaZero, Grandmaster Hikaru is improving her chess calculation…
A: Required: In order to beat AlphaZero, Grandmaster Hikaru is improving her chess calculation…
Q: We have an array (x) of ints: x = {6,2,3,1,6,1,1,7,8} We would like to write a void function, call…
A: #include<iostream>using namespace std; void newArray(int *arr){ int a=0; int b=0; int…
Q: 9. Implement an array with values 1, 5, 14, 23, 45, 52, 58, 81, 82 91. a) Create a getindex(…
A: Solving the given problem by using C++, as no programming language is specified. The below given…
Q: Find errors and suggest correction, if any, in the following C++ statements. long float x; char *cp…
A: No. Error Corrections i. Too many types float x; or double x; ii. type must be matched char *cp…
Q: Question 2 In the following program, there is a call to the print_in_reverse function which has the…
A: Answer : Copyable Code: #include <stdio.h> #define A_SIZE(A) sizeof(A)/sizeof(A[0])
Q: Given these two arrays, char arrA[] = {'a', 'e', 'i', 'o', 'u'} and char arrB[] = {'T', 'A',…
A: The given two character type arrays named arrA and arrB. These arrays are initialized with values of…
Q: 1. Write the definition of the function setZero that initializes any one-dimensional array of type…
A: Program: //Header file #include<iostream> #include<iomanip> //Using namespace…
Q: 1. Create a function flip val flip : bool array array -> int -> int -> bool array array = that…
A: please do support for my efforts thanks! answer: 1) void flip_matrix(bool arr[n][m],int x,int y){…
Q: 4. Consider the following function main: int main() { int alpha[20]; int beta[20]; int gamma[4] =…
A: PROGRAM: //Header file #include<iostream> #include<iomanip> //Using namespace std…
Q: The following array declaration is initialized with the first three of Fibonacci sequence numbers.…
A: Here have to determine Fibonacci code.
Q: 1. Consider a class having 'n' students. You need to read all the student marks for a particular…
A: Solution:-- 1)As per given in the question is to do the programming in the C language as per…
Q: Define a function that will output an array of values of type double that is passed as an argument…
A: Note :- You have not mention the language of the program, so i'm answering your question in C++.…
Q: 1. Given an unsorted array of N integers (N > 0) and an integer value x, write the function that…
A: Array: A data object contained in contiguous memory locations is referred to as an array. So we cam…
Q: Write a following functions to do the following operations on the int array b[20]: a. SetArr( ) to…
A: Since the coding language is not mentioned , I have done the code in C++. Algorithm : Question a)…
Q: 3.6 Write a program that reads Mathematic test marks of 10 (ten) student and stores it to a…
A: Here I ahve created the array with size 10. Next, I ahve taken input from the user and stored it…
Q: Identify output in the following code & also identify the general working/functionality of the code…
A: Output of the following given code: 1 3 5
Q: #include 2 3 int main(){ 4. int n, m; // size of array A. rows and columns int n_, m_; // size of…
A: First some basics of matrix multiplication are if two matrices A and B of sizes a,b and x,y are to…
Q: #include int main(void) { int array1[9]; printf("Enter Array1 elements:"); for(int…
A: Add code line to print your name (Ghadeer) and take a screenshot for the program output: Program…
Q: Consider an 1-d array of type int and a pointer pointing variable pointing to the 2nd item of the…
A: Q: Code the given problem
Q: ato 2 3 void good_enough(int array, int length); 4 with elements randomly arranged. I struggle with…
A: Answer
Q: Consider the following function main: Int main() { int inStock[10][4]; int alpha [20]; int beta[20];…
A: Given question has asked to write following function on given array, inStock[10][4], alpha [20],…
Q: define and initialize and array X of length 8. You need implement following and write outcomes with…
A: Given: int X[]={1, 2, 3, 4, 5, 6, 7, 8}; ⇒X[0]=1, X[1]=2, X[2]=3, X[3]=4, X[4]=5, X[5]=6, X[6]=7…
Q: 7.17) Write the inOrder() method, which has an array of integers as a parameter, and returns true…
A: Given: Write the inOrder() method, which has an array of integers as a parameter, and returns true…
Q: • Define a void function called myFunc that takes a 2-by-3 integer array as an argument and performs…
A: The question does not state any particular programming language for the solution to be in. We have…
Q: Question 3
A: Writing the program code in java as in the given question no programming language is specified.This…
Q: PYTHON CODE: In order to beat AlphaZero, Grandmaster Hikaru is improving her chess calculation…
A: Required: In order to beat AlphaZero, Grandmaster Hikaru is improving her chess calculation…
Q: Please define and initialize and array X of length 8. You need implement following and write…
A: Program : #include <iostream>int main(){ int X[8] = {1,2,3,4,5,6,7,8}; int* p; p =…
Q: C++ solution required Gustavo Gus has to remove one of his drug chemists due to trust issues. So he…
A: First line will contain TT, number of testcases. Then the testcases follow. First line of each test…
Q: 3) A function is implemented with a feature to print a line when x is found in the array A. def…
A: Your output of python program for all three function is given below with an output screenshot .
Q: Q 26 ) Consider the following code and answer the questions. int ary[] = {5, 9, 4, 2, 6, 7,…
A: A) Starting index of ary is : 0 ( as, every array starts with index 0 ). B) last index of ary…
Q: let a {x:0}; for (let i = 0; i < 4; i++) { a = Array.create (2, a); } a = 1; After running the last…
A: Answer is given below-
Q: 2. (a) Write an algorithm in pseudo-code that • takes as input an array A[1...n], and an item M…
A: Below is the complete solution with C program taking an array A and element M and returns the last…
Q: 3. Implement a function called findLargestIndex which returns the index of the rowwith the largest…
A: The function called findLargestIndex is used to find the index of a row whose all element sums are…
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: Consider the following function. void printArray(int cards[], int size) { for (int i=0; i<size;…
A: const keyword: The const is the keyword to set a variable value as a constant that will not allow…
Q: 3. Write a program to find intersection of two sorted array. For example, if the two sorted arrays…
A: As no programming language is mentioned, it is solved using basic C++
Step by step
Solved in 2 steps
- int main() { int inStock[10][4]; int alpha[20]; int beta[20]; int gamma[4] = {11, 13, 15, 17}; int delta[10] = {3, 5, 2, 6, 10, 9, 7, 11,1, 8};. . .} a. Write the definition of the function setZero that initializes any onedimensional array of type int to 0. b. Write the definition of the function inputArray that prompts the user to input 20 numbers and stores the numbers into alpha. c. Write the definition of the function doubleArray that initializes the elements of beta to two times the corresponding elements in alpha. Make sure that you prevent the function from modifying the elements of alpha. d. Write the definition of the function copyGamma that sets the elements of the first row of inStock to gamma and the remaining rows of inStock to three times the previous row of inStock. Make sure that you prevent the function from modifying the elements of gamma. e. Write the definition of the function copyAlphaBeta that stores alpha into the first five rows of inStock and beta into the…3. Write a program to find intersection of two sorted array.For example, if the two sorted arrays as input are {21, 34, 41, 22, 35} and {61, 34, 45, 21, 11}, it should returnan intersection array with numbers {34, 21}. For the sake of this Problem, you can assume that numbers ineach integer array are unique.Using Kotlin Make up four students - add them into an array. Create a function for the class that checks if a given student name is in an array. Check if student (pick a name from your array) is in the array and print the result. Use the in operator. my code so far fun main() { // create 4 students var student1 = Student("JIm", 47, "3432") var student2 = Student("Bill", 35, "1222") var student3 = Student("Mary", 21, "58F5") var student4 = Student("Graham", 29, "8958") var students=arrayOf(student1, student2, student3, student4) for (student in students) { student.nameExists) } } class Student(var name: String, var age: Int, var classID: String){ fun nameExists() { if("Mary" in name) { println("Name is in the array") } } }
- Suppoce we're given numpy arrays of names and scores, where each row in the scores array lists the midterm and final scores for that respective student. For example, Carol has a 75 on the midterm and 99 on the final. names = np. array([ "Alice" "Bob". "Carol","Derek ","Erin"]) Scores = np.array([ [95, 98], [82, 88], [75, 99], [80, 90], 85, 82 ]]) Write function avgMidtermNoC that takes ve parameters names and score arrays, and returns the average score on the midterm, exduding anyone who's name starta with C.3. Implement a function called findLargestIndex which returns the index of the rowwith the largest sum.ex. int array[3][6] = {{3, 6, 8, 2, 4, 1}, // sum = 24{2, 4, 5, 1, 3, 4}, // sum = 19{1, 0, 9, 0, 1, 0}}; // sum = 11If the findLargestIndex function was called using this array, it would return 0, asit is returning the index of the row, not the sum.Note that the number of columns is required when passing a 2d array to a function.Assume that 2D arrays passed to this function will have 6 columns.Title line: int findLargestIndex(int array[][6], int rows, int columns);4. Write a program to find kth smallest element in unsorted array?You are given an unsorted array of numbers and k, you need to find the kth smallest number in the array. Forexample if given array is {1, 2, 3, 9, 4} and k=2 then you need to find the 2nd smallest number in the array,which is 2.
- Can you help me please: have the program know when numbers out of the array boundaries are received and mitigate those problems. The given code intentionally induces numbers out of bounds and the student’s portion must correct for this. As always use a header file and implementation file to do those calculations. Remember not to change the given code below in any way Design and implement the class myArray that solves the array index out of bounds problem and also allows the user to begin the array index starting at any integer, positive or negative. Every object of type myArray is an array of type int. During execution, when accessing an array component, if the index is out of bounds, the program must terminate with an appropriate error message. Consider the following statements:myArray list(5); //Line 1 myArraymyList(2, 13); //Line 2myArray yourList(-5, 9); //Line 3The statement in Line 1 declares list to be an…Write 3 functions: Write int readNumbersIntoArray(int numbers[], int size); // Reads up to size numbers or a non-numeric and puts them in the array. // Returns how many numbers read. Write int minOrMax(int numbers[], int size, bool Max); // Returns the minimum or the maximum value in the array depending on "Max". // If "Max" is true, then it returns the maximum. // If "Max" is false, then it returns the minimum. Write double trimmedAvg(int numbers[], int size); // Returns the trimmed average of the array. // A trimmed average is a normal average but leaves out the first instance of // the smallest and largest value in the array when doing the calculation. // HINT: use calls to minOrMax() to get the largest and smallest number. Write int main(): // Prompt the user for between 3 and 20 numbers and use readNumbersIntoArray() to // read them into an array. Print an error message and exit if less than three numbers. // Print out the min, max, and trimmedAverage of the array using calls…Write 3 functions: Write int readNumbersIntoArray(int numbers[], int size); // Reads up to size numbers or a non-numeric and puts them in the array. // Returns how many numbers read. Write int minOrMax(int numbers[], int size, bool Max); // Returns the minimum or the maximum value in the array depending on "Max". // If "Max" is true, then it returns the maximum. // If "Max" is false, then it returns the minimum. Write double trimmedAvg(int numbers[], int size); // Returns the trimmed average of the array. // A trimmed average is a normal average but leaves out the first instance of // the smallest and largest value in the array when doing the calculation. // HINT: use calls to minOrMax() to get the largest and smallest number. Write int main(): // Prompt the user for between 3 and 20 numbers and use readNumbersIntoArray() to // read them into an array. Print an error message and exit if less than three numbers. // Print out the min, max, and trimmedAverage of the array using calls…
- 2. An interpolation search assumes that the data in an array is sorted and uniformly distributed.Whereas a binary search always looks at the middle item in an array, an interpolation searchlooks where the sought-for item is more likely to occur. For example, if you searched yourtelephone book for Victoria Appleseed, you probably would look near its beginning ratherthan its middle. And if you discovered many Appleseeds, you would look near the lastAppleseed. Instead of looking at the element a[mid] of an array a, as the binary search would,an interpolation search examines a[index], where p = (desiredElement - a[first]) / (a[last] - a[first]) index = first + [(last – first) × p]Implement an interpolation search of an array. For particular arrays, compare the outcomesof an interpolation search and of a binary search. Consider arrays that have uniformlydistributed entries and arrays that do not. Modify and save the file asSearchComparerYourlastname.java.Part 1 Write a function that takes an integer array and the size of the array The array is supposed to have 'N' integers in it, where N-1 integers are repeated even number of times and one integer is repeated odd number of times For example array = {1,5,5, 1,2,5,2,2,5}. 1 and 5 are repeated even number of times whereas 2 is odd number times. The function should find the element which is repeated odd number of times and return it. In the case of the example shown above, the function should return 2. int FindSingleElement(int arr[], int size) { } int main(int argc, char *argv[]) { return 0; } THIS IN C++.In the following code both myList and yourList are dynamic arrays of the same size. The code initializes the array myList to certain values. The value in each element of yourList should be twice the value in the corresponding element in myList. However, the output of this code would show that is not the case. Provide the correct code to accomplish the desired results. int *myList;int *yourList;myList = new int[5];myList[0] = 8;for (int i = 1; i < 5; i++)myList[i] = i * myList[i - 1];yourList = myList;for (int i = 0; i < 5; i++)yourList[i] = 2 * myList[i];