sider the following loop, which is the same loop as in the Free Form part: t low, high, A[100]; //assume array A has been initialized Precondition: 0 < low < high < 100 t best=low, sub3low+1; hile (sub <= high) if (A[sub]>A[best]) best=sub; ++sub; Postcondition: A[i]SA[best] for all integers i in [low, high] at variables have values changed during the execution of the loop? (Check all the correct answ et full credit) ow
Q: Write a program in C++ that lets the user enter a product code. The program should determine if the…
A: I have provided C++ CODE along with CODE SCREENSHOT and TWO OUTPUT…
Q: Given two Arays, arr1 and arr2, write a C++ function to check if arr2 is a sub array of arr1. For…
A: Hello student. Greetings from my side. Hope you are doing great. I will try my best to answer your…
Q: HELP PROGRAMMING IN C- Use the program below as starting point to the question. 4. Using any sorting…
A:
Q: JAVA Programming Write a function that returns true if you can partition an array into one element…
A: Algorithm - Take one string as input. Now use the below logic if(count==1) return false;…
Q: A set of integers may be implemented using an array of integers. Since the array is only partially…
A: set.h #define Max 20typedef int Set[Max]; void initialize (int *count);void display (Set S, int…
Q: Background for Question 14-20: Below is a bubble sort program that sorts the elements in an array.…
A: Control flow graph for above program:
Q: Selection sort works as follows. . . and OOP is also known as a. It visits the array and compares…
A: According to the question we need to fill in the blanks:And we need attempt 6 Only among the given…
Q: Write a program in ¢++ that asks the user to enter 10 integers of an array . The program must return…
A: #include<iostream> using namespace std; int pos(int arr[]){ //return position of element…
Q: Code: #include using namespace std; void BUBBLE(int A[],int N){ for(int k=0;kA[ptr+1]){…
A: Explanation: To remove the function from the program and writing everything into a main function is…
Q: A minimax or saddle point in a two-dimensional array is an element that is the minimum of its row…
A: Here I have first of all created a 2D array and then prompted the user to enter the elements into…
Q: #include #include using namespace std; int main() { int arr [7] = {9, 4, 1, 6, 2}; int i, j, k,…
A: Answer: A function is a block of code that runs when we call any function. You can pass data into…
Q: In the example above you required the user to input the values for the array. Modify the program in…
A: EXPLANATION - For initializing the 2D array Syntax is - int array[row][column ]={{n1,…
Q: Below is a bubble sort program that sorts the elements in an array. static void bubbleSort(int] arr)…
A: The answer is given in the step 2
Q: Write a function that takes an array of elements and returns only the integers. Examples…
A: In this problem, we need to design the code to solve the given problem. Will be solving this issue…
Q: Write code that loops through the array userVals. Each iteration: If userVals[i] is less than 10,…
A: Solution with detail explanation using comments:- // consider array of 6 integersinteger array(6)…
Q: An array is special if every even index contains an even number and every odd index contains an odd…
A: Algorithm - Design a method with one argument as a string. Now use the below logic to solve the…
Q: / * Count the number of times that the first element in array numbers occurs in the first n elements…
A: #include <iostream>using namespace std; int first_element_occurs(int *numbers, int n){ int…
Q: An array with an odd number of elements is said to be balanced if all elements (except the middle…
A: #include <iostream> using namespace std; //creating function int func(int array[],int n){…
Q: Consider the following code fragment: let a = Array.create(A, Array.create(B, 1); %3D let m =…
A: Here in this code array is created by using create.array function which will return an array of the…
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: Background for Question 14-20: Below is a bubble sort program that sorts the elements in an array.…
A: Step 1 The answer is given in the below step
Q: Jint min_index_of_array(int* ar, int len) { * Find the INDEX of the minimum value in ar. If there…
A: ALGORITHM:- 1. Declare and initialize the array. 2. Pass the array to the function. 3. Store the…
Q: An array is special if every even index contains an even number and every odd index contains an odd…
A: Coded using JavaScript.
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: An array is positive dominant if it contains strictly more unique positive values than unique…
A: Algorithm - Take input from user. Now use the below logic - const positives = new Set(a.filter(n…
Q: Python
A: Introduction of Program Python is a widely-used general-purpose, high-level programming language. It…
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: Write a jagged array program through following logic 1. Using in dex number 2. Intialize…
A: Since no programming language is mentioned, I am using c#. Algorithm: Start Declare a Jagged array…
Q: An array is special if every even index contains an even number and every odd index contains an odd…
A: Algorithm - Design a method with one argument as a string. Now use the below logic to solve the…
Q: A run is a sequence of adjacent repeated values. Write a program that generates a sequence of 20…
A: These programs can be asked from control statements, array, string, oops etc. Java basic programs…
Q: A left rotation operation on an array of size n shifts each of the array's elements 1 unit to the…
A: Sample Output Screenshot:
Q: a. I input an array of integers: int[] arr = { 4, 100, 2, 50, 7, -45, -23, 84, 51, 120, 98, -72 }.…
A: Initialize total to 0 as well
Q: A set of integers may be implemented using an array of integers. Since the array is only partially…
A: Note: As you have asked the multipart question, as per our policy we will solve the first three…
Q: All code in Javascript A: For the following array items 2.2, 3.3, 4.4, 6.5, 4.4, 10.2, 6.7, 7.1,…
A: Declare and define array. Calculate length of array iterate from i=0 to i<length Display…
Q: What does the ff. algorithm return? (Note: indentation is important) algorithm foo(f : function, a1,…
A: In the given algorithm we have the array hit keep track of which elements of the codomain B have…
Q: Below is a bubble sort program that sorts the elements in an array. static void bubbleSort(int] arr)…
A: The answer is given in the step 2
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: Question 3: r" An array listA is called balanced if it stores the same count of even and odd…
A: Step-1: Start Step-2: Declare and input an array 'listA' of size 10 Step-3: Print array listA…
Q: consisting of n integers a1 < a2 <... < an
A: python code is given below,
Q: (c) A palindromic number is a number that is the same if read forwards or backwards: 12321 and…
A: Palindrome number is a number which is read same from backwards as well as front. It means reverse…
Q: function biggest_gap(L) that takes a list L of real numbers
A: Approach As language is not mentioned, the function is written in javascript since two values are…
Q: In C++ >>> Write a program that prompts the user to enter 50 integers and stores them in an array.…
A: A C++ program is as follows, File name: “main.cpp” #include <iostream> using namespace std;…
Q: The following function checks whether the dataset stored in an array follows the rules of a…
A: Solution:- Please find below your answer in second step;
Q: In c++ Write a function named "eliminate_duplicates" that takes an array of integers in random…
A: Program: #include<iostream>using namespace std;//function decalartion to eliminated…
Q: Using Javascript Write a higher-order function that when given an array of numbers, return a new…
A: Program Approach: Include open script tag. Define function even only and pass array. Now use filter…
Q: Program a method merge_sorted(a,b) that when given two sorted arrays a and b, returns a new sorted…
A: Code :- import numpy as np def merge_sorted(a,b): m=len(a)-len(b)…
Q: Background for Question 14-20: Below is a bubble sort program that sorts the elements in an array.…
A: Step 1 The answer is given in the below step
Q: Background for Question 14-20: Below is a bubble sort program that sorts the elements in an array.…
A: The answer is given in the below step
Q: a program in c++ write a function named "eliminate_duplicates" that takes an array of integers in…
A: Program: #include<iostream>using namespace std;//function decalartion to eliminated…
Step by step
Solved in 2 steps
- In java Develop a function that accepts an array and returns true if the array contains any duplicate values or false if none of the values are repeated. Develop a function that returns true if the elements are in decreasing order and false otherwise. A “peak” is a value in an array that is preceded and followed by a strictly lower value. For example, in the array {2, 12, 9, 8, 5, 7, 3, 9} the values 12 and 7 are peaks. Develop a function that returns the number of peaks in an array of integers. Note that the first element does not have a preceding element and the last element is not followed by anything, so neither the first nor last elements can be peaks. Develop a function that finds the starting index of the longest subsequence of values that is strictly increasing. For example, given the array {12, 3, 7, 5, 9, 8, 1, 4, 6}, the function would return 6, since the subsequence {1, 4, 6} is the longest that is strictly increasing. Develop a function that takes a string…9.1.1: Output numbers in reverse. Write a program that reads a list of 10 integers, and outputs those integers in reverse. For coding simplicity, follow each output integer by a space, including the last one. Then, output a newline. Ex: If the input is 2 4 6 8 10 12 14 16 18 20, the output is: 20 18 16 14 12 10 8 6 4 2 To achieve the above, first, read the integers into an array. Then output the array in reverse. CODES in Coral LanguageGiven an integer array of positive single digit values such as:int a[] = {8,4,2,6,9};1) Write a recursive arrayToN function which returns the concatenation of all array values as an integer value.This function should accept all required data as parameters and return a long integer value.ExamplesIf the array is 8 4 2 6 9 the arrayToN function returns the integer 84269.If the array is 0 2 6 8 9 3 5 1 the arrayToN function returns the integer 2689351.
- Write a program that has a struct studentType that contains the following members of type string, first, last, and type int grade, section, and type double gpa. The program should define the struct and declare an array studentType, size 3. Prompt the user for the information for the struct and the data should be read in and set for each student. Once all of the data has been read in, write it back out using the formatting show below. Example of this: g++ -Wall-pedantic -Wextra main.cpp ./a.out Enter first last grade section gpa:a mouse 3 1003 2.95 Enter first last grade section gpa:b mouse 4 1005 3.01 Enter first last grade section gpa:c mouse 2 1000 4.0 Student 0 a mouse 3 1003 2.95 Student 1 b mouse 4 1005 3.01 Student 2 c mouse 2 1000 4Programming Language: C Write the following three functions: a) The function gets an array A of length n of ints, and a boolean predicate pred. It returns the smallest index i such that pred(A[i])==true. If no such element is not found, the function returns -1. int find(int* A, int n, bool (*pred)(int)); b) The function gets an array A of length n of ints, and a function f. It applies f to each element of A. void map(int* A, int n, int (*f)(int)); c) The function gets an array A of length n of ints, and a function f. The function f gets 2 ints and works as follows: 1. Start with accumulator = A[0] 2. For i=1...length-1 compute accumulator=f(accumulator, A[i]) 3. Return accumulator For example, if f computes the sum of the two inputs, then reduce() will compute the sum of the entire array. int reduce(int* A, int n, int (*f)(int,int)); Test for the functions: // used for test Q3-find bool is_even(int x) { return x%2 == 0; } bool is_positive(int x) { return x>0; } void…Write a recursive function that finds the minimum value in an ArrayList. Your function signature should be public static int findMinimum(ArrayList<Integer>) One way to think of finding a minimum recursively is to think “the minimum number is either the last element in the ArrayList, or the minimum value in the rest of the ArrayList”. For example, if you have the ArrayList [1, 3, 2, 567, 23, 45, 9], the minimum value in this ArrayList is either 9 or the minimum value in [1, 3, 2, 567, 23, 45] ================================================ import java.util.*; public class RecursiveMin{public static void main(String[] args){Scanner input = new Scanner(System.in);ArrayList<Integer> numbers = new ArrayList<Integer>();while (true){System.out.println("Please enter numbers. Enter -1 to quit: ");int number = input.nextInt();if (number == -1){break;}else {numbers.add(number);}} int minimum = findMinimum(numbers);System.out.println("Minimum: " + minimum);}public static int…
- 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…Program to be written in C: Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicating the number of integers that follow. For coding simplicity, follow each output integer by a space, including the last one. Assume that the list will always contain less than 20 integers. Ex: If the input is: 5 2 4 6 8 10 the output is: 10 8 6 4 2 To achieve the above, first read the integers into an array. Then output the array in reverseWrite a program in C++ that lets the user enter the total rainfall for each of 12 months into an array of double. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts. Input Validation: Do not accept negative numbers for monthly rainfall figures. At the end, the program should display a list of months, sorted in order of rainfall, from highest to lowest.
- Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. This time, your problem has additional details: Constraints: The solution set must not contain duplicate triplets. The order of the output and the order of the triplets does not matter. 3 <= nums.length <= 3000 -105 <= nums[i] <= 105 Function definition for Java: public List<List<Integer>> threeSum(int[] nums) { // Your code here } Function definition for Python: def threeSum(self, nums: List[int]) -> List[List[int]]: #Your code here Announced Test Cases: Input: nums = [0,1,1] Output: [] Explanation: The only possible triplet does not sum up to 0.Input: nums = [-5,0,5,10,-10,0] Output: [[-10,0,10],[-5,0,5]] Explanation: There are two possible combinations of triplets that satisfy: (-5,0,5) and (-10,0,10). Hint: There are 3 well-known ways to solve this problem!Program this in java:a. I input an array of integers: int[] arr = { 4, 100, 2, 50, 7, -45, -23, 84, 51, 120, 98, -72 }.b. Declare an integer variable that named "total".c. create a loop.d.1. The loop control variable value to be declared is 0. This will be represented by the variable "i" and it represents the index of the inputted array.e.2. The loop has a condition that if the current loop control variable value is greater than or equal to the size of the array minus the first item of the array, the loop will break.f.3. After the body or function is executed, the loop control variable is incremented by 2.g.4. The body of the loop has a conditional statement. if arr[i] is even, add it to total, else minus it to the total.g. After the loop breaks or finishes, display the value of the total.in C programing Write a recursive function that returns 1 if an array of size n is in sorted order and 0 otherwise. Note: If array a stores 3, 6, 7, 7, 12, then isSorted(a, 5) should return 1 . If array b stores 3, 4, 9, 8, then isSorted(b,4) should return 0.int isSorted(int *array, int n){