Recursive Bubble Sort in Javascript Bubble Sort can be carried out recursively as follows: const recursiveBubbleSort = function ( a , p = a . length - 1 ) { if ( p < 1 ) { return a ; } for ( let i = 0 ; i < p ; i ++) { if ( a [ i ] > a [ i + 1 ]) { [ a [ i ], a [ i + 1 ]] = [ a [ i + 1 ], a [ i ]]; } } return recursiveBubbleSort ( a , p - 1 ); } console . log ( recursiveBubbleSort ([ 2 , 1 , 4 , 7 , 3 , 9 , 5 , 6 , 8 ])); You can run the code here: https://repl.it/@VinitKhandelwal/bubble-sort-recursive-javascript
Project Weekay | Resume | LinkedIn Profile
NodeJS, AWS, MongoDB, ReactJS, Django, Python, ML with Scikit Learn, Matplotlib, Seaborn
Engineering, UX, Marketing, Product Designing, Business
sayhellotovinit@gmail.com | +91 99239 08880 | Pune, India