const NUMS_LEN = 2**NUMS_LEN_SIZE;
const GAP_SIZE = 300/NUMS_LEN;
const shellSortGaps = [1, 4, 10, 23, 57, 132, 301, 701, 1750].filter(x=>x<NUMS_LEN);
var index = 0, index2 = 0, index3 = 0, pos = NUMS_LEN_SIZE-1;
var subArr = 1, subArr2 = 1,msize=2;
var check0 = true, check = true, check2=true, check3 = true;
let resetButton, colorButton, bSort, csSort, iSort, gSort, slSort, oeSort, cSort, sSort, displayButton, resetMode;
for (let i=0;i<NUMS_LEN;i++) {
const getChildren = (id) => [(id+1)*2-1, (id+1)*2];
const getParent = (id) => floor((id+1)/2) - 1;
switch (resetMode.value()) {
for (let i=0;i<height;i+=height/NUMS_LEN) {
for (let i=0;i<height;i+=height/NUMS_LEN) {
for (let i=0;i<windowHeight;i+=windowHeight/NUMS_LEN) {
for (let i=0;i<windowHeight;i+=windowHeight/NUMS_LEN) {
for (let i=0;i<NUMS_LEN*2;i++) {
let n = floor(random(NUMS_LEN));
swap(n-round(random(0, max(round(NUMS_LEN*0.005), 1))), n+round(random(0, max(round(NUMS_LEN*0.005), 1))));
for (let i=0;i<windowHeight;i+=windowHeight/NUMS_LEN) {
for (let i=0;i<NUMS_LEN;i+=20) {
swap(floor(random(NUMS_LEN)), floor(random(NUMS_LEN)));
for (let i=0;i<height;i+=height/NUMS_LEN) {
nums.push(random(0,height));
for (let i=0;i<height;i+=height/NUMS_LEN) {
height+height*sin( map(i,0,height,0,TAU) )
for (let i=-1;i<1;i+=2/NUMS_LEN) {
nums.push(map(i**2,0,1,0,height)+random(0.01));
case "Shuffled Sine Wave":
for (let i=0;i<height;i+=height/NUMS_LEN) {
height+height*sin( map(i,0,height,0,TAU) )
case "Higher Frequency Sine Wave":
for (let i=0;i<height;i+=height/NUMS_LEN) {
height+height*sin( map(i,0,height,0,4*TAU) )
for (let i=0;i<height;i+=height/NUMS_LEN) {
nums.push(random(0.01)+random([height/8,height/4,3*height/8,height/2,5*height/8,3*height/4,7*height/8]));
for (let i=0;i<NUMS_LEN;i++) {