Assignment 8 Sorting

by pat spag

HTML

<input type="button" value="Create Randomized String List" onclick="populateList();">
<br>
<input type="button" value="Merge Sort" onclick="callMergeSort()">
<br>
<input type="button" value="sorting Tech 2" onclick="bubbleSort1();">
<br>
<input type="text" value="9" id="textInput" size="8">
<input type="button" value="Insert String" onclick="InsertSort();">
<br> <br>
<div id="output">
</div>
<div id="output2">
</div>
<div id="output3">
</div>
<div id = "output4">

</div>
<div id = "output5">
</div>
<br>
<div id = "output5">
</div>
<input type="button" value="test" onclick="test()">

<div id = "output6">
</div>

CSS

check 44

JavaScript

var node = function(val){
	this.next = null;
  this.previous=null;
  this.content = val;
};
var queue = function(){
	this.front = null;
  this.back = null;
  this.length = 0;
  
  this.addToBack = function(val){
  if (this.front == null){
  	this.front = new node(val);
    this.back = this.front;
    return this;
  }
  var addedNode = new node(val);
  addedNode.previous = this.back;
  this.back.next = addedNode;
  this.back = addedNode;
  return this;
  }
  
  this.addToFront = function(val){
  	if (this.front == null);{
    	this.front= new node(val);
      this.back = this.front;
      return this;
  	}
    var addedNode = new node(val);
    addedNode.next = this.front;
    this.front.previous = addedNode;
    this.front = addedNode;
    return this;
 	}
  this.discardBack = function(){
  	if (this.front == null){
    	return null;
    }
    var discardBackItem = this.back.content;
    	if(this.back == this.front){
      	this.front = null;
        this.back = null;
        return discardBackItem;
      }else{
      	this.back = this.back.previous;
        this.back.next = null;
        return discardBackItem;
      }
  }
  this.discardFront = function (){
  	if (this.front ==null){
    	return null;
    }
    var discardFrontItem = this.front.content;
    	if (this.back == this.front){
      	this.front = null;
        this.back = null;
        return discardFrontItem;
      }else{
      	this.front = this.front.next;
        this.front.previous = null;
        return discardFrontItem;
      }
  }
  
 	this.toString = function(){
  	var str= "";
    var node = this.front;
    if (this.front == null){
    	str = "this que is empty"
    }else{
    	str ="";
    }
    	while (node != null){
      	str += node.content + " ";
        node = node.next;
      }
      return str;
  }
  this.count = function (){
  var count = 0;
  var counterNode = this.front;
  while (counterNode != null){
  	counterNode = counterNode.next;
    count +=1;
  	}
  return count;
 ...