Assignment 2

by Taylor Zimmerman

HTML

<h1>
Time Complexity 
</h1>

Enter Array Size: <input type="textbox" id="ArraySize" value="100">

<input type="button" onclick ="CreateArray()" value="Create Array">
<br/>

Enter Location: <input type="textbox" id="InsetValue" value=""> 

Enter Value to Insert: <input type="textbox" id="InsertIndex" value=""><br/>

<input type="button" onclick="InsertIntoArray()" value="Insert Into Array">
<br/>

Enter Value to Find: <input type="textbox" id="find" value="">

<input type="button" onclick="search()" value="Search Array"><br/><br/>

<div id="output">
</div>
<div id="update">
</div>
<div id="complexity">
</div>

JavaScript

//var size = 1000
var array = new Array();
var out = "";
var index = "";
var newValue = document.getElementById("insert").value;
var search = "";
function CreateArray()
{
  for(var i = 0; i < array.length; i++)
  {
  	array[i] = Math.floor(Math.random() * 100 + 1)
  }
  
  for(var i = 0; i < array.length; i++)
    {
    	out += i + ":" + array[i] + "      ";
    }
	document.getElementById("output").innerHTML = out;
  
}
function InsertIntoArray()
 {
 	index = +document.getElementById("location").value;
  newValue = +document.getElementById("insert").value;
  return document.getElementById("output").innerHTML;
 }