RB_JSFiddle_A7

by Ryan Brown

HTML

<form id = "formski">
  <input type = "textbox" id = "nDiscs" value = "4" />
  <input type = "button" value = "Calculate!" onClick="solveTower();"/>
  <p id = "output">
  </p>
  <p id= "output1">
  </p>
</form>

CSS

#formski
  {
    font-family: courier;
  }

JavaScript

//Q1:The Big  O notation complexity is O(2^n)
//Q2: yes we should, as the properties behind this  are exponetnial meaning that the amount of time it takes to process will double per disc that is added to the tower. 


var Node = function(_content)
	{
  	this.next = null;
    this.previous = null;
    this.content = _content;
  }
  
 var Queue = function()
 	{
  	this.front = null;
    this.back = null;
    	this.push = function(_content)
    		{
      		if (this.front == null)
        		{
            		this.front = new Node(_content);
              	this.back = this.front;
             	return this;
            }
        			var createNode = new Node(_content);
            
            	createNode.previous = this.back;
              
              this.back.next = createNode;
              
              this.back = createNode;
           return this;
      	}
    			this.dropTop = function()
          	{
            	if (this.front == null)
              	{
               	return null;	
              	}
           	var movedDisc = this.front.content;
              	if (this.back == this.front)
              		{
                		this.front = null;
                		this.back = null;
               		return movedDisc;
               		}
             		else
             			{
              			this.front = this.front.next;
                		this.front.previous = null;
                	return movedDisc;
              		}
             }
             
             this.removeB = function()
             	{
              	if (this.front == null)
                	{
                  return null;
                  }
                var movedDisc = this.back.content;
                	if (this.back == this.front)
                  	{
                    		this.front = null;
                    		this.back = null;
                    	return movedDisc; 
                    }
                  else
                  	{
                    		this.back = this.back.previous;
     ...