Index_demo
by davidjb95
HTML
<p id='output'></p>
<p id='output2'></p>
JavaScript
function addNode() {
var value = parseInt(document.getElementById("LinkName").value);
ll.add(value);
length++;
LinkedList.prototype.bubbleSort();
}
var LinkedList = function () {
var LinkedListNode = function (content) {
this.next = null;
this.content = content;
};
var LinkedListNode2 = function (hash) {
this.next = null;
this.content = hash;
};
var LinkedListNode2 = function (content, hash) {
this.next = null;
this.content = content;
this.contenB = hash;
};
this.add = function (content) {
if (this.head == null) {
this.head = new LinkedListNode(content);
alert("content");
return this.head;
}
if (this.tail == null) {
this.tail = new LinkedListNode(content);
this.head.next = this.tail;
return this.tail;
};
this.tail.next = new LinkedListNode(content);
this.tail = this.tail.next;
this.tail.next = null;
return this.tail;
};
this.combine = function () {
if (this.head == null) {
var llContent = LinkedListNode.head.content;
var llHash = LinkedListNode2..head.hash;
this.head = new LinkedListCombine(llContent, llHash);
this.head.next = this.tail;
return this.tail;
}
if (this.tail == null) {
var llContent = LinkedListNode.tail.content;
var llHash = LinkedListNode2.tail.hash;
this.tail.next = new LinkedListCombine(llContent, llHash);
return this.head;
}
var llContent = LinkedListNode.tail.content;
var llHash = LinkedListNode2.tail.hash;
this.tail = new LinkedListCombine(llContent, llHash);
this.tail = this.tail.next;
return this.tail;
};
this.toHash = function(h) {
var hash = 0;
var chr = h;
//http://burtleburtle.net/bob/hash/integer.html
hash = (chr ^...