Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For assignments 1 and 2 , your Big - O notation and justification will be written in the HTML section of JSFiddle. Lecture Inserting Data
For assignments and your BigO notation and justification will be written in the HTML section of JSFiddle. Lecture Inserting Data into an Array covers some useful information on the basic Javascript needed for this assignment. You will be using the Javascript array
Programming Assignment Part
Using your JSFiddle account and JavaScript, you will create a program that will instantiate an integer array of a specified size. This means you must create a text box interface and a button Create Array Put a default value of in the Text Box. When the user clicks Create Array create an array and fill each array element with a random integer between and You will need to research the random function to do this the JavaScript function is Math.random This array should be a global variable.
You will next need an interface same JSFiddle with a second and third Text Box and button. The button will say Insert into Array It will trigger a function that will read a number from the second Text Box and insert it into the array at the index of the third Text Box. This will be done by calling a function as specified below.
The name of the function will be InsertIntoArray and it will have arguments function InsertIntoArrayarray index, value Argument is the array, argument is the index of where you are going to insert a new number, argument is the number to insert. The program should insert the new number at the index given and shift all the previous entries index up by The highest element of the array will be deleted. Count the number of operations performed on the array and output this to the screen. An operation is if you assign a value or compare a value only compare or assign operations should be counted.
Change the array size to and insert into a different index in the array. State using Big O Notation your time complexity and be prepared to justify your answer.
Programming parameters:
Create the array in Javascript;
Create a loop to assign each array element a random value.
Do not use push or splice commands assign elements by writing the code to perform all operations
When inserting you will be pushing the last value off the end of the array everything shifts right
Use a global counter to count every time you make an assignment every time you use an or operator
Output the count.
Step 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