var max = 20;
var noi = 0;
var a = [];
var b = [];
var res = [];
var x = 0;
var t1b, t2b, t3b, t4b, t1m, t2m, t3m, t4m, tCall, tSort, tFull; //needed for performance measuring
function handle(e) {
var key = e.keyCode || e.which;
if (key == 13) {
addStr();
document.getElementById("newNode").value = "";
}
}
var Node = function(_content) {
this.next = null;
this.previous = null;
this.content = _content;
}
var Stack = function() {
this.top = null; //if nothing is on top ...
this.bottom = null; //... then there is no bottom
this.push = function(_content) {
if (this.bottom == null) {
this.bottom = new Node(_content);
this.top = this.bottom;
return this;
}
var addedNode = new Node(_content);
addedNode.last = this.top; // pointer to previous node
this.top.next = addedNode; // current top points to new
this.top = addedNode; // which becomes new top
return this;
}
this.pop = function() {
if (this.top == null) {
alert("Empty Stack");
return null;
}
if (this.bottom == this.top) {
this.bottom = null;
x = this.top.content;
return this.top.content;
}
var a = this.top.content;
this.top = this.top.last;
this.top.next = null;
x = a;
return a;
}
this.toString = function() {
var str = "";
var node = this.bottom;
while (node != null) {
str += node.content + "<br/>";
node = node.next;
}
return str;
}
}
//Limit user input
function limitInput(input) {
if (isNaN(input.value)) {
alert("This should be a number between 2 & 1500 !");
} else {
if (input.value < 0) input.value = 0;
if (input.value > 1500) input.value = 1500;
max = 1500;
}
}
function clScr() {
document.getElementById('left').innerHTML = "";
document.getElementById('right').innerHTML = "";
document.getElementById('middle').innerHTML = "";
document.getElementById('mh').innerHTML = "";
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.