Question
Write the insertion sort algorithms as a function and test the functions by using randomly generated values. Type of array elements can be int. you can use any programming language you know
![Find the complexity of the traditional algorithms as Big O notation:
- Find the total of the array elements
sum(a, n)
{
}
{
result=0
}
for i=1 to n
if (result < a[i])
result = a[i]
- Find the maximum element of the array
max(a, n)
return result
total = 0
for i=1 to n
total = total + a[i]
return total](https://content.bartleby.com/qna-images/question/676c2a72-2dc6-4daa-8824-6f013a8120dd/71f36add-19e3-419f-b9d9-0372551f357f/s8uh8no_thumbnail.jpeg)
Transcribed Image Text:Find the complexity of the traditional algorithms as Big O notation:
- Find the total of the array elements
sum(a, n)
{
}
{
result=0
}
for i=1 to n
if (result < a[i])
result = a[i]
- Find the maximum element of the array
max(a, n)
return result
total = 0
for i=1 to n
total = total + a[i]
return total
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 5 steps with 3 images

Knowledge Booster
Similar questions
- Prompt: In python langauge, write a function that adds a random noise to all elements of a NumPy array Code: import numpy as np import math import matplotlib.pyplot as plt import pandas as pd def addNoise(inputArray): modifiedArray = np.zeros(len(inputArray)) #YOUR CODE HERE: return(modifiedArray) def test(): inputs = np.arange(-5, 5,0.2) outputs = addNoise(inputs) plt.figure(1) plt.plot(inputs) plt.title('Input') plt.xlabel('Index') plt.ylabel('Value') plt.show() plt.figure(2) plt.plot(outputs, 'black') plt.title('Output') plt.xlabel('Index') plt.ylabel('Value') plt.show() test()arrow_forwardIn C++ language Write a function that takes a 1 Demensional array and an integer n and reutrns the number of times 'n' appears in the array. If 'n' does not appear in the array, return -1.arrow_forwardGiven 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.arrow_forward
- Prompt: In Python language, write a function that applies the logistic sigmoid function to all elements of a NumPy array. Code: import numpy as np import math import matplotlib.pyplot as plt import pandas as pd def sigmoid(inputArray): modifiedArray = np.zeros(len(inputArray)) #YOUR CODE HERE: return(modifiedArray) def test(): inputs = np.arange(-100, 100, 0.5) outputs = sigmoid(inputs) plt.figure(1) plt.plot(inputs) plt.title('Input') plt.xlabel('Index') plt.ylabel('Value') plt.show() plt.figure(2) plt.plot(outputs,'Black') plt.title('Output') plt.xlabel('Index') plt.ylabel('Value') plt.show() test()arrow_forwardYou are designing a function that will manipulate an array of integers. It needs to work for arrays of any length. What is the minimum number of parameters your function will have?arrow_forward
arrow_back_ios
arrow_forward_ios