diff --git a/main.js b/main.js index 0b5fa7e..0e756ee 100644 --- a/main.js +++ b/main.js @@ -3,7 +3,9 @@ let arr=[]; //array to store the required elements for the required algorithm //pageNo: variable to store the current page number //algoType: variable to store the selected algorithm type, Searching=1, sorting=2 //algoNo: variable to store the selected algorithm within a selected algorithm type -let pageNo, algoType, algoNo; +let pageNo, algoType, algoNo,sorted,iterator; + +let graphWidth,graphHeight,barWidth,max,graphPadLeft,graphPadTop; function setup() { @@ -11,14 +13,21 @@ function setup() appHeight=(windowHeight<720)?720:windowHeight; //minimum height of the app should be 720 pixels and max should be the windowHeight createCanvas(appWidth,appHeight); pageNo=0; - algoType=0; - algoNo=0; + algoType=2; + algoNo=1; + generateArray(10); } function draw() { + graphWidth=appWidth*0.6; + graphHeight=appHeight*0.6; + barWidth=graphWidth/arr.length; + graphPadLeft=appWidth*0.2; + graphPadTop=appHeight*0.3; clear(); - background(200,0,100); + background(255); + fill(0,200,200); //switch case to maintain required pages with pageNo value switch(pageNo) { @@ -26,12 +35,30 @@ function draw() break; case 1: + if(algoType===1) + { + } + else if(algoType===2) + { + if(algoNo===1) + { + if(sorted===false) + { + sorted=selectionSortS(iterator); + iterator=iterator+1; + } + } + } break; case 2: break; } + for(let i=0;i=n) + return true; + m=d; + for(y=d+1;yarr[y]) + m=y; + } + if(m!=d) + { + t=arr[m]; + arr[m]=arr[d]; + arr[d]=t; + } + if(d<(n-1)) + return false; + else + return true; +} +function myDelay(deltaT) +{ + let startT=millis(); + while(millis() < startT + deltaT); } \ No newline at end of file