Skip to content

Commit d108a9b

Browse files
authored
Merge pull request vJechsmayr#56 from osusara/feature/osusara
Feature/osusara
2 parents 42013f8 + 35c822f commit d108a9b

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

‎DecimalToBinaryOctalHexadecimal.js‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function baseConverter(n, b){
2+
var stack = new Stack();
3+
var rem, convertedString = '', digits = '0123456789ABCDEF';
4+
5+
while (n > 0){
6+
rem = Math.floor(n % b);
7+
stack.push(rem);
8+
n = Math.floor(n / b);
9+
}
10+
11+
while (!stack.isEmpty()){
12+
convertedString += digits[stack.pop()];
13+
}
14+
15+
return convertedString;
16+
}
17+
18+
console.log(baseConverter(1021313, 2));
19+
console.log(baseConverter(1021313, 8));
20+
console.log(baseConverter(1021313, 16));

‎SelectionSort.js‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function selectionSort(arr){
2+
for (let i = 0; i < arr.length; i++) {
3+
let min = i;
4+
for (let j = i + 1; j < len; j++) {
5+
if (arr[min] > arr[j]) {
6+
min = j;
7+
}
8+
}
9+
if (min !== i) {
10+
let tmp = arr[i];
11+
arr[i] = arr[min];
12+
arr[min] = tmp;
13+
}
14+
}
15+
return arr;
16+
}
17+
18+
console.log(selectionSort([4,2,3,1,5]));

0 commit comments

Comments
 (0)