Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Solve a function for each of the problems listed below and do a time analysis, specifying the number of operations (instructions to be executed) that
Solve a function for each of the problems listed below and do a time analysis, specifying the number of operations (instructions to be executed) that the function carries out and the big-O time of the function.
1. Compute the sum of all integers from 1 to n. The function should receive the value of n as an argument and return the sum. Example inputs and outputs: 2. Search for a target value in an array. The function must receive the array and the target value to search as arguments, and return true if the target value is found in the array and false otherwise. The datatype of the values in the array can be any type of your choice (int, float, string, char, etc.) Example inputs and outputs: 3. Increase all numbers in an array by a given value. The function should receive the array and the increment value as arguments and it does not return anything (it changes the input array). For example: 4. Given two unsorted arrays A1 and A2, and an integer x, display all pairs of values (a1, a2), where a1A1 and a2A2, such that a1+a2=x. The function should receive the two arrays and the sum value as arguments and it does not return anything, it simply displays the result to screen. For example: INPUT DISPLAY: [4,5,2,7,8,10],[1,9,4,12,7,6],3 (2,1),(7,4),(10,7) For each value v in an array, check whether there are 2 other values in the array that ad up to v, if so, print v. The function should receive the array as an argument and it does not return anything, it simply displays the result to screen. For example: Why the output? 5 because 3+2=5,7 because 5+2=7, and 8 because 3+5=8Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started