From 258f64ddacc69f87fce370d1c2b011dda5ae5cfc Mon Sep 17 00:00:00 2001 From: rajduino Date: Tue, 3 Dec 2019 17:21:30 +0530 Subject: [PATCH 1/3] Added functions searchingSelected(), sortingSelected(), generateArray(), selectionSort() to be modified later --- main.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/main.js b/main.js index bd0785f..0b5fa7e 100644 --- a/main.js +++ b/main.js @@ -38,4 +38,41 @@ function windowResized() appWidth=(windowWidth<1280)?1280:windowWidth; appHeight=(windowHeight<720)?720:windowHeight; resizeCanvas(appWidth, appHeight); +} +function searchingSelected() +{ + pageNo=1; + algoType=1; +} +function sortingSelected() +{ + pageNo=1; + algoType=2; +} +function generateArray(let n) +{ + arr=[]; + for(let i=0;iarr[j]) + m=j; + } + if(m!=i) + { + let t=arr[m]; + arr[m]=arr[i]; + arr[i]=t; + } + } } \ No newline at end of file From 393d754a98f9e0b09bd67b50158f5024e2bd793a Mon Sep 17 00:00:00 2001 From: rajduino Date: Tue, 3 Dec 2019 20:55:49 +0530 Subject: [PATCH 2/3] Added modified selectionSortS() and others! --- main.js | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 89 insertions(+), 6 deletions(-) diff --git a/main.js b/main.js index 0b5fa7e..bea877f 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 From a0ce91033af4b2b052cf6fedc6a842ea6f06c66e Mon Sep 17 00:00:00 2001 From: rajduino Date: Tue, 3 Dec 2019 21:08:50 +0530 Subject: [PATCH 3/3] resolved merge --- main.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/main.js b/main.js index 8dd5548..0e756ee 100644 --- a/main.js +++ b/main.js @@ -66,7 +66,6 @@ function windowResized() appHeight=(windowHeight<720)?720:windowHeight; resizeCanvas(appWidth, appHeight); } -<<<<<<< HEAD function mousePressed() { console.log("called"); @@ -75,8 +74,6 @@ function mousePressed() iterator=0; //selectionSort(); } -======= ->>>>>>> 12043e135563ee4c7514afa0a538d577e39bf4e1 function searchingSelected() { pageNo=1; @@ -87,7 +84,6 @@ function sortingSelected() pageNo=1; algoType=2; } -<<<<<<< HEAD function generateArray(n) { arr=[]; @@ -117,7 +113,6 @@ function selectionSort() m=i; } max=arr[m]; -======= function generateArray(let n) { arr=[]; @@ -129,7 +124,6 @@ function generateArray(let n) function selectionSort() { let m; ->>>>>>> 12043e135563ee4c7514afa0a538d577e39bf4e1 for(let i=0;i>>>>>> 12043e135563ee4c7514afa0a538d577e39bf4e1 } \ No newline at end of file