๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿค– data structures & algorithms

Data Structures & Algorithms with Javascript : Queues

[์ด์ „ ๊ธ€]2024.07.19 - [๐Ÿค– data structures & algorithms] - Data Structures & Algorithms with Javascript : Stacks

 

Data Structures & Algorithms with Javascript : Stacks

2024.07.18 - [๐Ÿค– data structures & algorithms] - Data Structures & Algorithms with Javascript : Lists2024.07.17 - [๐Ÿค– data structures & algorithms] - Data Structures & Algorithms with Javascript : Arrays2024.07.17 - [๐Ÿค– data structures & algorithms]

pyotato-dev.tistory.com

๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป ์ €๋ฒˆ ํฌ์ŠคํŒ…์—์„œ ์Šคํƒ ์ž๋ฃŒ ๊ตฌ์กฐ์— ๋Œ€ํ•ด ์‚ดํŽด๋ดค๋‹ค.
๋ฐ์ดํ„ฐ๋ฅผ ์ˆœ์„œ๋Œ€๋กœ ์‚ฝ์ž…ํ•˜๋Š” push์—ฐ์‚ฐ, ๊ฐ€์žฅ ์ตœ๊ทผ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฆฌ์ŠคํŠธ์—์„œ ๊บผ๋‚ด์„œ ์ œ๊ฑฐํ•˜๋Š” pop์—ฐ์‚ฐ,
๊ทธ๋ฆฌ๊ณ  ๊ฐ€์žฅ ์ตœ๊ทผ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๊ธฐ๋งŒ ํ•˜๋Š” peek ์—ฐ์‚ฐ์„ class๋กœ ๊ตฌํ˜„ํ•ด ๋ณด๊ณ ,
์Šคํƒ์„ ํ™œ์šฉํ•ด ํŒฐ๋ฆฐ๋“œ๋กฌ, ์žฌ๊ท€ ๋™์ž‘ ํ‰๋‚ด๋‚ด๊ธฐ, ์ง„์ˆ˜ ๋ณ€๊ฒฝ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ๋งŒ๋“ค์–ด๋ดค๋‹ค.

์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” LIFO ๋ฐฉ์‹๊ณผ๋Š” ๋ฐ˜๋Œ€์ธ FIFO (first-in-first-out) ๋ฐฉ์‹์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” queue๊ฐ€ ๋ฌด์—‡์ธ์ง€,  ํ๋ฅผ ํ™œ์šฉํ•œ ๋ฐ์ดํ„ฐ ์ •๋ ฌ(radix sort), ์šฐ์„ ์ˆœ์œ„ ํ์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž.

๐Ÿ‘ซ Queue ์—ฐ์‚ฐ

ํ๋Š” ์˜์–ด๋กœ ์ค„, ๋Œ€๊ธฐํ•˜๋‹ค๋ฅผ ๋œปํ•œ๋‹ค

 

ํ ์ž๋ฃŒ ๊ตฌ์กฐ๋Š” ๋Œ€๊ธฐ์ค„๊ณผ ๊ฐ™์€ ํ˜•ํƒœ๋‹ค. ์ค„์„ ์„œ๋ ค๋ฉด ๋งจ ๋’ค์— ์„œ ์žˆ๊ณ ,

์ž…์žฅ ๋ฐ ์ˆœ๋ฒˆ์ด ๋˜๋ฉด ๋งจ ์•ž์—์„œ๋ถ€ํ„ฐ ์ค„์„ ์„ฐ๋˜ ์‚ฌ๋žŒ๋“ค์ด ๋น ์ง€๋Š” ๊ฒƒ์ฒ˜๋Ÿผํ๋„ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ๋™์ž‘ํ•œ๋‹ค.

ํ์˜ ์ฃผ์š” ์—ฐ์‚ฐ์—๋Š” ์ƒˆ๋กœ์šด ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฝ์ž…ํ•˜๋Š” "enqueue"์™€ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ญ์ œํ•˜๋Š” "dequeue"๊ฐ€ ์žˆ๋‹ค.

"enqueue"๋Š” ์ƒˆ ๋ฐ์ดํ„ฐ๋ฅผ queue์˜ ๋งจ ๋์— ์ถ”๊ฐ€ํ•˜๋Š” ์—ฐ์‚ฐ์ด๊ณ , "dequeue"๋Š” ๋งจ ์•ž์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ œ๊ฑฐํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

 

 

์ด์ „ stack์—์„œ "peek" ์—ฐ์‚ฐ์€ ๋งจ ๋งˆ์ง€๋ง‰ ๋ฐ์ดํ„ฐ๋ฅผ ํ™•์ธํ•˜๋Š” ์—ฐ์‚ฐ์ด๋ผ๊ณ  ํ–ˆ๋‹ค.

ํ์—์„œ peek ์—ฐ์‚ฐ์€ ๋งจ ์•ž์˜ ๋ฐ์ดํ„ฐ๋ฅผ ํ™•์ธํ•˜๋Š” ์—ฐ์‚ฐ์ด๋‹ค.

๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป array ๊ธฐ๋ฐ˜ ํด๋ž˜์Šค  ํ ๊ตฌํ˜„

โ€ผ ์˜ˆ์ œ๋Š” ์ฑ…์˜ ๊ตฌํ˜„์„ ์ฐธ๊ณ ํ•˜์—ฌ ํด๋ž˜์Šค๋กœ ์žฌ๊ตฌ์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค!!

class Queue{
	constructor(){
    	this.dataStore = [];
    }
    // ํ์— ๋ฐ์ดํ„ฐ ์‚ฝ์ž…
    enqueue(element){
    	this.dataStore.push(element);
    }
    // ํ์˜ ๋งจ ์ฒซ ์•„์ดํ…œ ์ œ๊ฑฐ
    dequeue(){
		return this.dataStore.shift();
	}
    
    // ๋งจ ์•ž ์š”์†Œ ํ™•์ธ (peek์—ฐ์‚ฐ)
    front(){
    	return this.dataStore[0];
    }
    
    // ๋งจ ๋’ค ์š”์†Œ ํ™•์ธ
    back(){
    	return this.dataStore[this.dataStore.length - 1];
    }
    
    // ํ ์•„์ดํ…œ ๋ฌธ์ž์—ด๋กœ ๋ฐ˜ํ™˜
    toString(){
    	let stringifiedQueue = '';
        for(let i=0; i< this.dataStore.length; i++){
        	stringifiedQueue+=this.dataStore[i] +'\n';
        }
        return stringifiedQueue;
    }
    
    // ํ๊ฐ€ ๋น„์—ˆ๋Š” ์ง€ ํ™•์ธ
    empty(){
    	return this.dataStore.length===0
    }

}

// ์ฝ˜์†”๋กœ ์ถœ๋ ฅํ•ด์ฃผ๋Š” ์œ ํ‹ธํ•จ์ˆ˜
const print = (item) => console.log(item);

const queue = new Queue();
queue.enqueue('a'); // ํ ์ƒํƒœ : ['a']
queue.enqueue('b'); // ํ ์ƒํƒœ : ['a','b']
queue.enqueue('c'); // ํ ์ƒํƒœ : ['a','b','c']

print(queue.toString()); 
/**
a
b
c
*/
print(queue.dequeue()); // b  ํ ์ƒํƒœ : ['b','c']
print(queue.toString());
/**
b
c
*/
print(queue.front()); // b
print(queue.back()); // c

 

๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป ํ๋กœ ๋ฐ์ดํ„ฐ ์ •๋ ฌ : radix sort

IBM ์นด๋“œ ํŽ€์น˜์นด๋“œ๋ฅผ radix sort๋กœ ์ •๋ ฌํ•˜๋Š” ์žฅ๋ฉด

๊ณผ๊ฑฐ ์ปดํ“จํ„ฐ์˜ ์—ญ์‚ฌ๋ฅผ ์‚ดํŽด๋ณด์ž๋ฉด, ํ”„๋กœ๊ทธ๋žจ์€ mainframe ํ”„๋กœ๊ทธ๋žจ์„ ํŽ€์น˜์นด๋“œ๋กœ ์ž…๋ ฅํ–ˆ์—ˆ๋‹ค.

๊ฐ๊ฐ์˜ ์นด๋“œ๊ฐ€ ํ•˜๋‚˜์˜ ํ”„๋กœ๊ทธ๋žจ ๋ช…๋ น์„ ์ง€๋‹ˆ๊ณ  ์žˆ์—ˆ๋‹ค. ์ด ์นด๋“œ๋“ค์€ bin๊ฐ™์€ ๊ตฌ์กฐ๋ฌผ์ด ์ •๋ ฌํ•ด ์ฃผ๋Š” ๊ธฐ๊ณ„๋ฅผ ํ†ตํ•ด ์ •๋ ฌ๋˜์—ˆ๋‹ค.

์ด ์ •๋ ฌ ๋™์ž‘์„ ํ๋ฅผ ํ™œ์šฉํ•ด ๋ชจ๋ฐฉํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด ์ •๋ ฌ ๋ฐฉ์‹์„ radix sort๋ผ๊ณ  ํ•œ๋‹ค. 

 

radix sort์˜ ์˜ˆ๋ฅผ ์‚ดํŽด๋ณด์ž. 

๋‹ค์Œ๊ณผ ๊ฐ™์ด 0 ~ 99 ์‚ฌ์ด์˜ ์ˆซ์ž ์„ธํŠธ๊ฐ€ ์žˆ๋‹ค๊ณ  ํ•˜์ž.

91, 46, 85, 15, 92, 35, 31, 22

 

๋จผ์ € 1์˜ ์ž๋ฆฌ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌ์„ ํ•ด์ฃผ๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

Bin 0 : 
Bin 1 : 91, 31
Bin 2 : 92, 22
Bin 3 : 
Bin 4 : 
Bin 5 : 85, 15, 35
Bin 6 : 46
Bin 7 : 
Bin 8 : 
Bin 9 : 

 

์ฒซ๋ฒˆ์งธ ์ •๋ ฌ์„ ํ†ตํ•ด ์ˆซ์ž ์„ธํŠธ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ •๋ ฌ๋œ๋‹ค.

91, 31, 92, 22, 85, 15, 35, 46

 

์ด์ œ 10์˜ ์ž๋ฆฌ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌ์„ ํ•ด์ฃผ์ž.

Bin 0 : 
Bin 1 : 15
Bin 2 : 22
Bin 3 : 31, 35
Bin 4 : 46
Bin 5 : 
Bin 6 : 
Bin 7 : 
Bin 8 : 85
Bin 9 : 91, 92

 

๋‘ ๋ฒˆ์งธ ์ •๋ ฌ์„ ํ†ตํ•ด ์ˆซ์ž ์„ธํŠธ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ •๋ ฌ๋œ๋‹ค.

15, 22, 31, 35, 46, 85, 91, 92

 

์ด ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ํ๋กœ ๊ตฌํ˜„ํ•ด ๋ณด์ž.

๋…ผ๋ฆฌ ํ๋ฆ„

1. ๊ฐ๊ฐ์˜ bin์„ ํ๋กœ ๋‚˜ํƒ€๋‚ด๊ธฐ ์œ„ํ•ด์„œ๋Š” 9๊ฐœ์˜ ํ๊ฐ€ ํ•„์š”ํ•˜๋‹ค.

2. modulus์™€ ์ •์ˆ˜ ๋‚˜๋ˆ—์…ˆ์„ ํ†ตํ•ด 1๊ณผ 10์˜ ์ž๋ฆฟ์ˆ˜๋ฅผ ์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

3. ์ž๋ฆฟ์ˆ˜์— ๋”ฐ๋ผ์„œ ํ•ด๋‹น ํ์— ์ˆซ์ž๋ฅผ ์ถ”๊ฐ€ํ•ด ์ค€๋‹ค.

4. 1๊ณผ 10์œผ๋กœ ์ •๋ ฌํ•ด ์ค€ ํ๋“ค์„ ์ˆœ์„œ๋Œ€๋กœ ๋นผ์„œ ํ•˜๋‚˜์˜ ๋ฌธ์ž์—ด๋กœ ์ด์–ด์ค€๋‹ค.'

๊ตฌํ˜„

โ€ผ ์˜ˆ์ œ๋Š” ์ฑ…์˜ ๊ตฌํ˜„์„ ์ฐธ๊ณ ํ•˜์—ฌ  ๋ณ€๊ฒฝ์‚ฌํ•ญ์ด ์žˆ์Šต๋‹ˆ๋‹ค!!

const TEN = 10;
const TEST_CASE_COUNT = 3;

// digit์€ 1 ๋˜๋Š” 10์˜ ์ž๋ฆฟ์ˆ˜๋กœ ๋ถ„๋ฐฐ
function distribute(nums, queues, digit){
	for(let i= 0; i < TEN; ++i){
		digit === 1? queues[nums[i] % TEN].enqueue(nums[i]) : queues[Math.floor(nums[i] / TEN)].enqueue(nums[i]) 
	}
}

// 0-9๊นŒ์ง€์˜ ํ์—์„œ ์ˆซ์ž ๊ฐ€์ ธ์˜ค๊ธฐ
function collect(queues, nums){
	let i = 0;
    for(let digit = 0; digit < TEN; ++digit){
    	while(!queues[digit].empty()){
        	nums[i++] = queues[digit].dequeue();
        }
    }
}

// ๊ณต๋ฐฑ์œผ๋กœ ์ด์–ด์ค€ ์ •๋ ฌ๋œ ํ๋“ค
function displayArray(arr){
	return arr.join(' ');
}

// ์‚ฌ์šฉ

// ์ž๋ฆฟ์ˆ˜ ๋ณ„ 0 - 9์˜ ํ bin
const queues = [];
for(let i = 0; i < TEN; ++i){
	queues[i] = new Queue();
}

// ์ •๋ ฌํ•ด์ค„ ์ˆซ์ž ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค
let testCase = Array.from({length: TEST_CASE_COUNT}, ()=>{
    let nums = [];
    for(let i = 0; i < TEN; ++i){
    	nums[i] = Math.floor(Math.floor(Math.random()*101));
    }
    return nums;
});

for(let i = 0; i < TEST_CASE_COUNT; i++){
    print(`test case ${i+1} ์ •๋ ฌ ์ „: ${displayArray(testCase[i])}`);
    distribute(testCase[i], queues, 1); // 1์˜ ์ž๋ฆฟ์ˆ˜๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌ
    collect(queues, testCase[i]); 
    distribute(testCase[i], queues, 10) // 10์˜ ์ž๋ฆฟ์ˆ˜๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌ
    collect(queues, testCase[i]); 
    print(`test case ${i+1} ์ •๋ ฌ ํ›„: ${displayArray(testCase[i])}`);
    print('\n');
}
/**
VM1137:40 test case 1 ์ •๋ ฌ ์ „: 20 92 26 13 3 66 24 27 81 30
VM1137:40 test case 1 ์ •๋ ฌ ํ›„: 3 13 20 24 26 27 30 66 81 92

VM1137:40 test case 2 ์ •๋ ฌ ์ „: 28 86 46 14 52 97 98 55 72 35
VM1137:40 test case 2 ์ •๋ ฌ ํ›„: 14 28 35 46 52 55 72 86 97 98

VM1137:40 test case 3 ์ •๋ ฌ ์ „: 16 96 44 37 5 36 32 17 62 11
VM1137:40 test case 3 ์ •๋ ฌ ํ›„: 5 11 16 17 32 36 37 44 62 96
*/

๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป ์šฐ์„ ์ˆœ์œ„ ํ (priority queue)

์ผ๋ฐ˜์ ์ธ ํ ์—ฐ์‚ฐ์—์„œ๋Š” dequeue์—ฐ์‚ฐ์€ ๋ฌด์กฐ๊ฑด ๋งจ ์ฒ˜์Œ ํ์— ์ถ”๊ฐ€๋œ ์—˜๋ฆฌ๋จผํŠธ๊ฐ€ ์ œ๊ฑฐ๋œ๋‹ค.

ํ•˜์ง€๋งŒ ๋•Œ์— ๋”ฐ๋ผ FIFO๋ฐฉ์‹์ด ์•„๋‹Œ ๋‹ค๋ฅธ ๊ธฐ์ค€์œผ๋กœ ์š”์†Œ๋ฅผ dequeue ํ•˜๊ณ  ์‹ถ์„ ์ˆ˜๊ฐ€ ์žˆ๋‹ค.

์ด๋•Œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์ž๋ฃŒ ๊ตฌ์กฐ๊ฐ€ ์šฐ์„ ์ˆœ์œ„ ํ๋‹ค.

 

์šฐ์„ ์ˆœ์œ„ ํ๋Š” ๋ง ๊ทธ๋Œ€๋กœ ํŠน์ • ์šฐ์„  ์ˆœ์œ„์— ๋”ฐ๋ผ ์š”์†Œ๋ฅผ ์ œ๊ฑฐํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

์šฐ์„  ์ˆœ์œ„ ํ์˜ ๋™์ž‘์€ ์‘๊ธ‰์‹ค์—์„œ ์‘๊ธ‰์ฒ˜์น˜๊ฐ€ ์ด๋ฃจ์–ด์ง€๋Š” ์ˆœ์„œ์™€ ๋น„์Šทํ•˜๋‹ค.

์‘๊ธ‰์‹ค์—์„œ ํ™˜์ž๊ฐ€ ์ฒ˜์น˜๋˜๋Š” ์ˆœ์„œ๋Š” ๋จผ์ € ์˜ค๋Š” ํ™˜์ž ์ˆœ์ด ์•„๋‹ˆ๋ผ, ๊ธด๊ธ‰๋„๊ฐ€ ๋†’์€ ์ˆœ์œผ๋กœ ์ด๋ฃจ์–ด์ง€๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋™์ž‘ํ•œ๋‹ค.

 

ํ™˜์ž์˜ ์ƒํƒœ์— ๋”ฐ๋ผ ์šฐ์„ ์ˆœ์œ„๋ฅผ ๋ถ€์—ฌํ•˜๋Š” ์˜ˆ์ œ๋ฅผ ๊ตฌํ˜„ํ•ด ๋ณด์ž.

ํ™˜์ž์˜ ์‘๊ธ‰ ์ฝ”๋“œ๋ฅผ ๋‚˜ํƒ€๋‚ด๊ธฐ ์œ„ํ•ด ์ด์ „ queue์˜ ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•ด ๋ณด์ž.

class Patient{
	constructor(name, code){
    	this.name = name; // ํ™˜์ž์˜ ์ด๋ฆ„
        this.code = code; // ํ™˜์ž์˜ ์‘๊ธ‰ ์ƒํƒœ, ์ˆซ์ž๊ฐ€ ํด์ˆ˜๋ก ์šฐ์„  ์ˆœ์œ„, ์‘๊ธ‰๋„๊ฐ€ ๋†’๋‹ค.
    }
}

class PriorityQueue extends Queue{ // queue๋ฅผ ์ƒ์†ํ•˜๋Š” priorityQueue
	constructor(){
    	super(); // ๋ถ€๋ชจ์˜ ์†์„ฑ ์ƒ์†๋ฐ›์Œ
    }
	// ์šฐ์„  ์ˆœ์œ„์— ๋”ฐ๋ผ ๋ฐ์ดํ„ฐ ์ œ๊ฑฐ
    dequeue(){
		let priority = this.dataStore[0].code;
        for(let i=1; i< this.dataStore.length; ++i){
        	if(this.dataStore[i].code < priority){
            	priority = i;
            }
        }
        return this.dataStore.splice(priority,1);
	}

    toString(){
    	let stringifiedQueue = '';
        for(let i=0; i< this.dataStore.length; i++){
        	stringifiedQueue+=this.dataStore[i].name +' code' + this.dataStore[i].code + "\n";
        }
        return stringifiedQueue;
    }
    

}


// ํ™˜์ž๋ฅผ ์šฐ์„  ์ˆœ์œ„ ํ์— ์ถ”๊ฐ€
const patient1 = new Patient("Smith", 5);
priorityQueue.enqueue(patient1);

const patient2 = new Patient("Jones", 4);
priorityQueue.enqueue(patient2);

const patient3 = new Patient("Brown", 1);
priorityQueue.enqueue(patient3);

const patient4 = new Patient("Ingram", 1);
priorityQueue.enqueue(patient4);

print(priorityQueue.toString());
let treatedPatient = priorityQueue.dequeue();
print(`treated patient: ${treatedPatient[0].name}`);
print(`need treatment: ${priorityQueue.toString()}`);
treatedPatient = priorityQueue.dequeue();
print(`treated patient: ${treatedPatient[0].name}`);
print(`need treatment: ${priorityQueue.toString()}`);

/**
    Smith code5
    Jones code4
    Brown code1
    Ingram code1

    VM1184:40 treated patient: Jones
    VM1184:40 need treatment: Smith code5
    Brown code1
    Ingram code1

    VM1184:40 treated patient: Brown
    VM1184:40 need treatment: Smith code5
    Ingram code1
*/

 

๐Ÿ€ ๋งˆ์น˜๋ฉด์„œ

โ˜บ๏ธ ์˜ค๋Š˜์€ ํ๊ฐ€ ๋ฌด์—‡์ธ์ง€, ์–ด๋–ค ์ฃผ์š” ์—ฐ์‚ฐ์ด ์žˆ๊ณ , ํ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ •๋ ฌํ•˜๋Š” ์˜ˆ์‹œ์™€ ์šฐ์„ ์ˆœ์œ„ ํ์— ๋Œ€ํ•ด์„œ ์‚ดํŽด๋ดค๋‹ค.
์ด ์ฑ…์ด ์“ฐ์ด๋˜ 2014์—๋Š” ํด๋ž˜์Šค ๋ฌธ๋ฒ•์ด ๊ณต์‹ ๊ทœ์ •์— ์—†์—ˆ๋˜ ๋•Œ๋ผ function์œผ๋กœ ์“ฐ์ด๊ณ  ์žˆ๋‹ค. ๋ฌผ๋ก  ๊ทธ๋ƒฅ function์œผ๋กœ ์จ๋„ ๋˜์ง€๋งŒ ํด๋ž˜์Šค๋ฅผ ์“ธ ๊ฒฝ์šฐ๊ฐ€ ๋ณ„๋กค ์—†์–ด์„œ ํ™˜๊ธฐ ์ฐจ์›์—์„œ ์“ฐ๋‹ˆ๊นŒ ๋‚ซ๋ฐฐ๋“œ.
์ด์ „ ๋ฌตํ˜€๋’€๋˜ ํด๋ž˜์Šค ๋ฌธ๋ฒ•์„ ๋‹ค์‹œ ์‚ฌ์šฉํ•ด ๋ด์„œ ์ข‹์•˜๋‹ค.

๐Ÿ“š Reference

- Data Structures and Algorithms Using Javaโ€ Script by Michael McMillian (O’Reilly). Copyright 2014 Michael McMillan, 978-1-449-36493-9

https://en.wikipedia.org/wiki/Radix_sort

 

Radix sort - Wikipedia

From Wikipedia, the free encyclopedia Non-comparative integer sorting algorithm In computer science, radix sort is a non-comparative sorting algorithm. It avoids comparison by creating and distributing elements into buckets according to their radix. For el

en.wikipedia.org