Given a vector V of N integers. Write a C function that displays on the screen all the sub-vectors of maximum size that are made up of only contiguous cells with odd values. The function should have the following prototype: void maxOdd (int v[], int N); Example: given the array 1,3,7.1.0,1,9,3,1,0 the sub-vectors ofmaximum size with only contiguous odd numbers are: ,9,3,1 and 1,3,7,1.
Q: Consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user,…
A: ALGORITHM:- Sort_TAM (TAMUK[]) start = 0, mid = 0, end = length(TAMUK) - 1 while mid <= end if…
Q: A function named arithGym requires an input variable h, and returns three outputs (1) column vector…
A: The above problem can be coded in C++ in order to make use of vector classes. Vectors are same as…
Q: Write a C++ function, lastLargestIndex, that takes as parameters an int array and its size and…
A: 2. Program: #include <iostream> using namespace std; int lastLargestIndex(int a[], int size);…
Q: 6. Given the binary search function and an integer array a below with the target t-65, list all…
A: According to the information given:- We have binary search function and integer array and our…
Q: Write a function getMinMax() that, given an array of integers and two indexes, returns the minir and…
A: code is below:
Q: write a function that receives a vector of integers already sorted in ascending order, an integer n…
A: The answer is given below:-
Q: Write a C function with the following prototype: int searchSequence (int vet [1, int n, int m); that…
A: Algorithm: Start Read array size n Read n elements in an array a Read length of sub sequence m…
Q: 2. Write a program to take input a 4 X 4 matrix using a user defined function and print the output…
A: Since no programming language is mentioned, I am using c++. Algorithm: Start Read 4x4 matrix and…
Q: Write a user-defined function that adds or subtracts two polynomials of any order. Name the function…
A: The, given information is : Name the function p=polyadd(p1,p2,operation). The first two input…
Q: Write a function that receives a vector of integers already sorted in ascending order, an integer n…
A: Use a counter variable to store the number of iterations and return this counter variable only if…
Q: Write a function called “AddRows" that accepts two parameters: W1: a matrix of size 7x4 elements of…
A: NOTE - I have used the Python programming language. I have created a function named addRows(). In…
Q: Implement the following function, without using any data structure or #include /* Given two…
A: we are given two vectors of characters and need to determine of they are permutations of each other.…
Q: A matrix M with i rows, j columns can be transposed into a matrix N having j rows and i columns by…
A: //a.) Code : //Include necessary header files#include <stdio.h>// Defining a Function that…
Q: Write a function that receives a vector of integers already sorted in ascending order, an integer n…
A: output
Q: int busca_seq(int vetor[], int n, int b) { //seu código } For example: Test Input Result int vet[5],…
A: Algorithm: Start Initialize size of vector Initialize vector with given data Read search element…
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: You are give a matrix (a list of lists) of DISTINCT integers and a target number. Each row in the…
A: Program: public class Main { public static int[] searchMatrix(int[][] matrix,int target){…
Q: Program in C. Write a function that receives a vector of integers already sorted in ascending…
A: Input : Vector Number Output : Number of searches needed to search the number in vector.
Q: Write a function called "AddRows" that accepts two parameters: M1: a matrix of size 6x4 elements of…
A: I have created a function named AddRows(). In this function, I have used nested for loop to traverse…
Q: Question: As an engineer and a software developer your job in this project is to declare and…
A: Solution: 1. Implementation of Printmat() function: // Printmat() methodvoid Printmat(float…
Q: Write a user-defined function that adds or subtracts two polynomials of any order. Name the function…
A: Actually, user defined function is a function defined by user
Q: Write a function that receives a two-dimensional array, prints out the data by row along with the…
A: Since your not mentioning the programming language we used C to complete this program. PROGRAM:…
Q: Write a function that takes a vector of integers, an integer n representing the number of elements…
A: The code given below defines it
Q: Please do write a function that takes a vector of integers, an integer n representing the number of…
A: Algorithm: Start Read array length n Read n numbers in an array 'a' Read number to search 'b'…
Q: Given a vector V of N integers. Write a C function that displays on the screen all the sub-vectors…
A: Given: This is not a graded question so please don't disregard it as if it is. Thank you in advance…
Q: Q1:, ., Implement a range function for a dynamic array which returns a new dynamic array that is a…
A: Step 1 : Start Step 2 : Define a function which returns a new dynamically created array of the given…
Q: Write a function called "AddRows" that accepts two parameters: W1: a matrix of size 7x4 elements of…
A: NOTE - I have used the Python programming language. I have created a function named addRows(). In…
Q: Write a function that will merge the contents of two sorted (ascending order) arrays of type integer…
A: Purpose of the program: The program would merge two sorted arrays using pointers. The arrays may…
Q: Write a function called “AddRows” that accepts two parameters: W1: a matrix of size 7x4 elements of…
A: #include <iostream>using namespace std; void AddRows(int W1[7][4], int B1[4]){ for(int…
Q: Given a target value t and an integer array a with nelements, write a function to sequentially…
A: The solution conatins use of functions, arrays, conditional statements, loops. It finds the index of…
Q: I need help with a C program
A: Below is the required C program: - In the given program binary search is performed to search the…
Q: Write a function matrix_multiply(mat1, mat2) that takes two matrices and returns the result of the…
A: import numpy as np def matrix_multiply(mat1, mat2): rows = len(mat1) cols = len(mat2[0])…
Q: Implement the following addArrays function which takes as input two linear arrays of the same…
A: The above question is solved in step 2 :-
Q: Write a function that will merge the contents of two sorted (ascending order) arrays of type integer…
A: Purpose of the program: This program would ask the user to input two sorted arrays (in ascending…
Q: Write a function that accepts a number, N, and a vector of numbers, V. The function will return…
A: The program includes input/output and bits/stdc++ header files. A vector of n elements is being…
Q: 10. Suppose I have a vector x 6] 0] = 6] <- 0
A: x = [3, 5, 1, 10, 12, 6] we want all elements less than 6 to be eqaul to 0 target vector = [0, 0, 0,…
Q: Write a function called minimax that takes M, a matrix input argument and returns mmr, a row vector…
A: Solution I tried my best
Q: Write a C program that can take an array of length n having positive unique numbers. You are…
A: // C function to find highest in arr[] of size n #include <stdio.h> int largest(int arr[], int…
Q: Write a function that takes a vector of integers, an integer n representing the number of elements…
A: Algorithm : search_seq function Step 1 : declare loop variable. Step 2 : use for loop to read the…
Q: Write a function called "AddRows" that accepts two parameters: M1: a matrix of size 6x4 elements of…
A: The function AddRows() recieves one 2-D array of size 6x4 and one 1-D array of size 4. Each element…
Q: Write a function called "AddRows" that accepts two parameters: M1: a matrix of size 6x4 elements of…
A: I give the code in java along with output and code screenshot
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: Implement the following function that returns a vector of vectors of Item, each of which is a subset…
A: The problem is about slicing a vector
Q: Let us call a 2-dimensional array of integers a magic matrix if the following conditions are true.…
A: The program declares 6 rows and 9 columns two-dimensional arrays. Then call the function which takes…
Q: Write a C++ program that receives an array of type int, a target to look for and n representing the…
A: int count(int arr[], int target, int n, int loc[]) arr[] = input array of integer by user target =…
Q: Write a program for a user-defined function to multiply a polynomial. Name this function: P=polymult…
A: Here, I am going to write a python code for the above question.
Step by step
Solved in 2 steps with 4 images
- Consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called TAMUK. The number of each of these letters is unknown. We have a function, called SWAP(TAM,i,j), which places the ith letter in the jth entry of string TAM and the jth letter in the ith entry of TAM. Note that SWAP(TAM,i,j) is defined for all integers i and j between 0 and length(TAM)–1, where length(TAM) is the number of letters of TAM. 1. Using our algorithmic language, write an algorithm, called Sort_TAM, which sorts the letters in the array TAMUK in a way that all T’s appear first, followed by all A’s, and followed by all M’s. The algorithm Sort_TAM should have one parameter: The array TAMUK. Also, your solution is correct only if the following four constraints are satisfied: - Constraint 1: Each letter (‘A’, ‘M’, or ‘T’) is evaluated only once. - Constraint 2: The function SWAP(TAM,i,j) is used only when it is…consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called TAMUK. The number of each of these letters is unknown. We have a function, called SWAP(TAM,i,j), which places the ith letter in the jth entry of string TAM and the jth letter in the ith entry of TAM. Note that SWAP(TAM,i,j) is defined for all integers i and j between 0 and length(TAM)–1, where length(TAM) is the number of letters of TAM. 1. Using our algorithmic language, write an algorithm, called Sort_TAM, which sorts the letters in the array TAMUK in a way that all T’s appear first, followed by all A’s, and followed by all M’s. The algorithm Sort_TAM should have one parameter: The array TAMUK. Also, your solution is correct only if the following four constraints are satisfied: - Constraint 1: Each letter (‘A’, ‘M’, or ‘T’) is evaluated only once. - Constraint 2: The function SWAP(TAM,i,j) is used only when it is…consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called TAMUK. The number of each of these letters is unknown. We have a function, called SWAP(TAM,i,j), which places the ith letter in the jth entry of string TAM and the jth letter in the ith entry of TAM. Note that SWAP(TAM,i,j) is defined for all integers i and j between 0 and length(TAM)–1, where length(TAM) is the number of letters of TAM. 1. Using our algorithmic language, write an algorithm, called Sort_TAM, which sorts the letters in the array TAMUK in a way that all T’s appear first, followed by all A’s, and followed by all M’s. The algorithm Sort_TAM should have one parameter: The array TAMUK. Also, your solution is correct only if the following four constraints are satisfied: - Constraint 1: Each letter (‘A’, ‘M’, or ‘T’) is evaluated only once. - Constraint 2: The function SWAP(TAM,i,j) is used only when it is…
- Consider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called TAMUK. The number of each of these letters is unknown. We have a function, called SWAP(TAM,i,j), which places the ith letter in the jth entry of string TAM and the jth letter in the ith entry of TAM. Note that SWAP(TAM,i,j) is defined for all integers i and j between 0 and length(TAM)–1, where length(TAM) is the number of letters of TAM. 1. Using our algorithmic language, write an algorithm, called Sort_TAM, which sorts the letters in the array TAMUK in a way that all T’s appear first, followed by all A’s, and followed by all M’s. The algorithm Sort_TAM should have one parameter: The array TAMUK. Also, your solution is correct only if the following four constraints are satisfied: - Constraint 1: Each letter (‘A’, ‘M’, or ‘T’) is evaluated only once. - Constraint 2: The function SWAP(TAM,i,j) is used only when it is…Implement the following function, without using any data structure. /* Given two vectors of chars, check if the two vectors are permutations of each other, i.e., they contains same values, in same or different order.e.g., V1=[‘a’,’b’,’a’] and V2=[‘b’,’a’,’a’] stores same multi-set of data points: i.e., both contains two ‘a’, and one ‘b’. e.g., V3=[‘a’,’c’,’t’,’a’] and V4=[‘a’,’c’,’t’] are not same multi-set. V3 contains two ‘a’s, while V4 has only one ‘a’. Note: when considering multiset, the number of occurrences matters. @param list1, list2: two vectors of chars @pre: list1, list2 have been initialized @post: return true if list1 and list2 stores same values (in same or different order); return false, if not. */ bool SameMultiSet (vector<char> list1, vector<char> list2)Given two arrays A and B of equal size N, the task is to find a vector containing only those elements which belong to exactly one array - either A or B - but not both. That is, if some element x appears in both A and B it should not be included in the output vector. Complete the implementation of "getVector(vector<ll>A, vector<ll>B, int N)" function. Example: Input: 1 3 5 7 1 3 2 4 6 7 8 Output: 3 5 1 3 2 4 6 8 The driver codes are attached in the images below. DO NOT CHANGE THE PROVIDED DRIVER CODES AT ALL, LEAVE THEM EXACTLY THE SAME. ONLY ADD CODE TO THE "getVector(vector<ll>A, vector<ll>B, int N)" FUNCTION
- Implement the following function that returns a vector of vectors of Item, each of which is a subset of elements chosen from the given vector a[first…last]: /* if a is {1,2,3}, first=0, last=2, the function shall returns a vector of the following vectors: {}, {1}, {2}, {3}, {1,2},{1,3}, {2,3},{1,2,3}, all subsets of a[0…2]. Precondition: last-first+1>=1, i.e., there is at least one element in the a[first…last] Note 1)if the length of a[first…last] is n, then the function should return a vector of 2n vectors 2) The order of these subsets does not need to match what’s listed here… */ vector<vector<int>> subsets (const vector<int> & a, int first, int last) codeImplement a range function for a dynamic array which returns a new dynamic array that is a subset of the original. input parameters: array - (the array and any related parameters) start - index of the first elementend - index of the last elementInterval - An integer number specifying the incrementation of index This function returns a new dynamic array containing the elements from the start thru the end indices of the original array.All array indexing must be done using pointer arithmetic. For example, given the array: 49 96 99 47 76 29 22 16 30 22 If the start and end positions were 5 and 9 with step 2, return a new dynamic array: 29 16 22 Please use following main to test your function. int main(){int *p = new int[10]{49,96,99,47,76,29,22,16,30,22}; int *q = range(p,10,5,9,2);for(int i=0;i<3;i++) cout<<q[i]<<" "; // print 29 16 22 cout<<endl;delete [] q;q = range(p,10,1,8,3); for(int i=0;i<3;i++)cout<<q[i]<<" "; // print 96 76 16 cout<<endl;…Implement a C function, named median, that receives two arrays as parameters passed and returns the median of the values stored in these two arrays. The two arrays are sorted. The prototype of the function MUST be: double median(int a[], int b[], int sizeA, int sizeB);For example, if I have int a[] = {1, 2, 10, 12, 100}; and int b[] = {3, 11, 20, 500, 600}; then the median is (11+12)/2 = 11.5.
- Write a function that receives a vector of integers already sorted in ascending order, an integer n representing the number of elements in this vector, and an integer b. Implement the sequential search algorithm to look for the integer b in the vector. The binary search works as follows: you must look for the element in the position exactly in the half of the vector, if it is the searched one, it returns the number of tests done so far, if it is not the searched one, calculate the midpoint of the half of the vector after assess whether the searched value is greater or less than the value at the middle position. Not finding the value searched, the function must return 0. The name of the function will be called "busca_bin". int bin_search(int array[], int n, int b){//code}Implement a function GetMinimumCutSegments(int[] arr, int k) that takes in an array arr of positive integers and an integer k, and returns the minimum number of contiguous segments of the array that must be concatenated to form an array of size k. The function should return -1 if it is not possible to create an array of size k by concatenating contiguous segments of the input array. Example: Input: [1, 2, 3, 4], 6 Output: 2 Explanation: The minimum number of contiguous segments that must be concatenated to form an array of size 6 is 2. The two segments that can be concatenated are [1, 2] and [3, 4]. Input: [1, 2, 3, 4], 7 Output: -1 Explanation: It is not possible to create an array of size 7 by concatenating contiguous segments of the input array. Constraints: The input array arr will have at most length 100. The integer k will be at least 1 and at most 10^6. Can you write a C# function that solves this problem? public int GetMinimumCutSegments(int[] arr, int k) { // Your code…Write a C++ function given an array of integers nums [passed by reference] and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. int[] twoSum(int nums[], int target)Sample Output:Input: nums = [2,7,11,15], target = 9Output: [0,1]