with JavaScripts Study Days 9-11

with JavaScripts Study Days 9-11

210519 ์ˆ˜์š”์ผ 9~11์ผ์ฐจ

# 8์ผ์ฐจ ๋ณต์Šต

CH3 ๋ฆฌ์ŠคํŠธ

  • #1 :ย ํ˜„์žฌ ๋ฆฌ์ŠคํŠธ์˜ ๋ชจ๋“  ์š”์†Œ๋ณด๋‹ค ํด ๋•Œ๋งŒ ์š”์†Œ๋ฅผ ์‚ฝ์ž…ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ๊ตฌํ˜„ํ•˜์‹œ์˜ค. ์—ฌ๊ธฐ์„œ ํฌ๋‹ค๋Š” ์˜๋ฏธ๋Š” ์ˆซ์ž์ผ ๋•Œ๋Š” ํฌ๊ธฐ๋ฅผ ๋น„๊ตํ•˜๊ณ , ํ…์ŠคํŠธ์ผ ๋•Œ๋Š” ์•ŒํŒŒ๋ฒณ์ˆœ์œผ๋กœ ๋‚˜์ค‘์„ ์˜๋ฏธํ•œ๋‹ค.
ํ˜„์žฌ ๋ฆฌ์ŠคํŠธ์˜ ๋ชจ๋“  ์š”์†Œ๋ณด๋‹ค ํด ๋•Œ๋ผ๋Š” ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜๋Š” ์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•œ ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์—ˆ๋‹ค.
๋ชจ๋“  ์š”์†Œ๋ณด๋‹ค ํฌ๋ฉด true, ํฐ ์š”์†Œ๊ฐ€ ์กด์žฌํ•  ์‹œ ์ค‘๊ฐ„์— false๋ฅผ ๋ฐ˜ํ™˜ํ•ด์ฃผ๋Š” ํ•จ์ˆ˜๋ฅผ ๊ตฌํ˜„ํ–ˆ๋‹ค.
๋จผ์ € ์‚ฝ์ž…ํ•˜๊ณ ์ž ํ•˜๋Š” ์š”์†Œ (after)๋ฅผ findํ•จ์ˆ˜๋กœ ์ฐพ์•„์„œ ์ธ๋ฑ์Šค๋ฅผ ๋ฐ›์€ ๋‹ค์Œ ์ธ๋ฑ์Šค๊ฐ€ ์กด์žฌํ•œ๋‹ค๋ฉด ๊ทธ ์œ„์น˜์— sliceํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•ด์„œ ์‚ฝ์ž…ํ•˜์˜€๋‹ค. ์‚ฝ์ž… ํ›„์—๋Š” listSize๋ฅผ 1 ์ฆ๊ฐ€์‹œํ‚จ๋‹ค.
  • #2 ํ˜„์žฌ ๋ฆฌ์ŠคํŠธ์˜ ๋ชจ๋“  ์š”์†Œ๋ณด๋‹ค ์ž‘์„ ๋•Œ๋งŒ ์š”์†Œ๋ฅผ ์‚ฝ์ž…ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ๊ตฌํ˜„ํ•˜์‹œ์˜ค.
๋น„๊ต ์—ฐ์‚ฐ์ž๋งŒ ๋ฐ˜๋Œ€๋กœ ๋ฐ”๊พธ์–ด ๊ตฌํ˜„ํ•˜์˜€๋‹ค.
  • #3 ์‚ฌ๋žŒ์˜ ์ด๋ฆ„๊ณผ ์„ฑ๋ณ„์„ ์ €์žฅํ•˜๋Š” Person ํด๋ž˜์Šค๋ฅผ ๊ตฌํ˜„ํ•˜์‹œ์˜ค. ์ตœ์†Œํ•œ 10๊ฐœ์˜ Person ๊ฐ์ฒด๋ฅผ ํฌํ•จํ•˜๋Š” ๋ฆฌ์ŠคํŠธ๋ฅผ ๋งŒ๋“œ์‹œ์˜ค. ๋ฆฌ์ŠคํŠธ์—์„œ ๊ฐ™์€ ์„ฑ๋ณ„์„ ๊ฐ€์ง„ ์‚ฌ๋žŒ์„ ๋ชจ๋‘ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ๊ตฌํ˜„ํ•˜์‹œ์˜ค.
filter๋Š” ์ฃผ์–ด์ง„ ์กฐ๊ฑด์„ ํ†ต๊ณผํ•˜๋Š” ๋ชจ๋“  ์š”์†Œ๋ฅผ ๋ชจ์•„ ๋ฐฐ์—ด๋กœ ๋ฐ˜ํ™˜ํ•œ๋‹ค. ๋”ฐ๋ผ์„œ ์ด๋ฅผ ํ†ตํ•ด ์ธ์ž๋กœ ์ฃผ์–ด์ง„ ์„ฑ๋ณ„์„ ๊ฐ€์ง„ ๊ฐ์ฒด๋งŒ ๋ชจ์•„์„œ ๋ฐฐ์—ด์„ ๊ตฌ์„ฑํ•˜๋„๋ก ํ–ˆ๋‹ค.

CH4 ์Šคํƒ

  • ๊ฐ€์žฅ ์œ— ๋ถ€๋ถ„์—์„œ๋งŒ ์ž๋ฃŒ์˜ ์ถ”๊ฐ€/์‚ญ์ œ๊ฐ€ ์ผ์–ด๋‚˜๋ฏ€๋กœ ์‹คํ–‰์†๋„๊ฐ€ ๋น ๋ฅด๊ณ  ๊ตฌํ˜„์ด ์‰ฝ๋‹ค.
  • ํ›„์ž…์„ ์ถœ๋กœ ๋ฐ‘๋ฐ”๋‹ฅ์— ์žˆ๋Š” ์š”์†Œ์— ์ ‘๊ทผํ•˜๋ ค๋ฉด ๋ชจ๋“  ์š”์†Œ๋ฅผ ์ œ๊ฑฐํ•˜๋Š” ์ˆ˜ ๋ฐ–์— ์—†๋‹ค.
  • Top์€ pop์œผ๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ์ง€๋งŒ ์š”์†Œ๋ฅผ ๊บผ๋‚ด๊ธฐ ๋•Œ๋ฌธ์— peek์œผ๋กœ ๋‚ด์šฉ์„ ํ™•์ธํ•œ๋‹ค. peek์€ top - 1์˜ ์œ„์น˜์— ์ ‘๊ทผํ•ด ์Šคํƒ์˜ ํƒ‘ ์š”์†Œ๋ฅผ ํ™•์ธํ•œ๋‹ค. (์Šคํƒ์˜ ์š”์†Œ๊ฐ€ 3์ด๋ฉด top(length)๋Š” 3์ด๊ณ  ๋ฐฐ์—ด์˜ ๊ฐ€์žฅ ์˜ค๋ฅธ์ชฝ ๊ฐ’์€ ๊ฐ€์žฅ ์œ— ๊ฐ’์ด๋ฏ€๋กœ top-1์ด top์— ์žˆ๋Š” ์š”์†Œ์˜ ์ธ๋ฑ์Šค๋‹ค.
  • ์ง„๋ฒ• ๋ณ€ํ™˜
1. n์˜ ๊ฐ€์žฅ ์˜ค๋ฅธ์ชฝ ์ˆซ์ž๋Š” n%b์ด๋‹ค. ์ด ๊ฐ’์„ ์Šคํƒ์— ์ถ”๊ฐ€ํ•œ๋‹ค.
=> s.push(num % base);
2. n์„ n/b์œผ๋กœ ์น˜ํ™˜ํ•œ๋‹ค.
=>ย num = Math.floor((num /= base)); // Math.floor๋Š” ์†Œ์ˆ˜๊ฐ’์ด ์กด์žฌํ•  ๋•Œ ์†Œ์ˆ˜๊ฐ’์„ ๋ฒ„๋ ค์ฃผ๋Š” ๊ธฐ๋Šฅ
3. n=0 ์ด ๋˜๊ณ  ๋‚˜๋จธ์ง€๊ฐ€ ์—†์„ ๋•Œ๊นŒ์ง€ 1๋ฒˆ, 2๋ฒˆ ๊ณผ์ •์„ ๋ฐ˜๋ณตํ•œ๋‹ค.
=>ย do { } while( num > 0 ) ;
4. ์Šคํƒ์— ์ €์žฅ๋œ ์ˆซ์ž๋ฅผ ๋ชจ๋‘ ๊บผ๋‚ด ๋ณ€ํ™˜๋œ ์ˆซ์ž ๋ฌธ์ž์—ด์„ ๋งŒ๋“ ๋‹ค.
=>ย while(s.length() > 0 ) { converted += s.pop(); } // s์˜ ์š”์†Œ๊ฐ€ pop์„ ํ†ตํ•ด ์ค„์–ด๋“ค๋‹ค๊ฐ€ 0๊ฐœ๊ฐ€ ๋˜๋Š” ์ˆœ๊ฐ„ while๋ฌธ์€ ์ข…๋ฃŒ๋œ๋‹ค.
return converted;
  • ํšŒ๋ฌธ
๋ฌธ์ž์—ด์˜ ๋ฌธ์ž๋ฅผ ํ•˜๋‚˜์”ฉ ๋„ฃ๊ณ  ๋‹ค์‹œ ๊บผ๋‚ด๋ฉด์„œ ๋งŒ๋“ค์–ด์ง„ ๋ฌธ์ž์—ด๊ณผ ์›๋ณธ ๋ฌธ์ž์—ด์„ ๋น„๊ตํ•˜๋ฉด ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ์žฌ๊ท€
์Šคํƒ์— ์ถ”๊ฐ€ํ•œ ๋’ค ๋ฃจํ”„๋ฅผ ๋Œ๋ฉด์„œ ๊บผ๋‚ด์„œ ์ˆ˜ํ–‰ํ•˜๋ฉด ์žฌ๊ท€์ ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

210519 ์ˆ˜์š”์ผ 9~11์ผ์ฐจ

(์ฑ…์„ ๋ณด๋ฉด์„œ ์ฝ”๋”ฉ์€ ํ–ˆ๋Š”๋ฐ ์ธํ„ดํ•˜๋ฉด์„œ ๋ธ”๋กœ๊ทธ์— ์ž‘์„ฑํ•  ์‹œ๊ฐ„์ด ์—†์–ด ํ•œ๋ฒˆ์— ์ž‘์„ฑํ•จ)

CH5 ํ

ํ๋Š” ๋ฆฌ์ŠคํŠธ์˜ ์ผ์ข…์œผ๋กœ ๋๋ถ€๋ถ„์œผ๋กœ ๋ฐ์ดํ„ฐ๊ฐ€ ์‚ฝ์ž…๋˜๊ณ  ์•ž๋ถ€๋ถ„์—์„œ ๋ฐ์ดํ„ฐ๊ฐ€ ์‚ญ์ œ๋˜๋Š” ๊ตฌ์กฐ์ด๋‹ค. ์ผ์–ด๋‚œ ์ˆœ์„œ๋Œ€๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜์ง€๋งŒ ์Šคํƒ๊ณผ ๋ฐ˜๋Œ€๋กœ ๋จผ์ € ๋“ค์–ด์˜จ ์ˆœ์„œ๋Œ€๋กœ ์ฒ˜๋ฆฌํ•œ๋‹ค. ์€ํ–‰์—์„œ ๋จผ์ € ์˜จ ๊ณ ๊ฐ๋ถ€ํ„ฐ ์›ํ•˜๋Š” ์—…๋ฌด๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ฒƒ๊ณผ ๊ฐ™๋‹ค. ์„ ์ž…์„ ์ถœ(First In, First out). ์šด์˜์ฒด์ œ์˜ ํ”„๋กœ์„ธ์Šค ์ฒ˜๋ฆฌ ์ˆœ์„œ, ํ”„๋ฆฐํŠธ ์Šคํ’€๋Ÿฌ, ๋Œ€๊ธฐ์ค„ ๋“ฑ์— ์‚ฌ์šฉํ•œ๋‹ค.

5.1 ํ ๋™์ž‘

์ธํ๋Š” ํ์˜ ๋ ๋ถ€๋ถ„์— ์š”์†Œ ์ถ”๊ฐ€, ๋””ํ๋Š” ํ์˜ ์•ž๋ถ€๋ถ„์˜ ์š”์†Œ ์‚ญ์ œ, ํ์˜ ์•ž๋ถ€๋ถ„ ์š”์†Œ๋ฅผ ํ™•์ธํ•˜๋Š” peek, ์š”์†Œ ๊ฐœ์ˆ˜ length, ์ „์ฒด ์‚ญ์ œ clear

5.2 ๋ฐฐ์—ด ๊ธฐ๋ฐ˜์˜ Queue ํด๋ž˜์Šค ๊ตฌํ˜„

ํŠนํžˆ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋ฐฐ์—ด์€ Queue ํด๋ž˜์Šค ๊ตฌํ˜„์— ๋งŽ์€ ๋„์›€์„ ์ค€๋‹ค. ๋ฐฐ์—ด์˜ ๋๋ถ€๋ถ„์— ๋ฐ์ดํ„ฐ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” push() ํ•จ์ˆ˜, ๋ฐฐ์—ด์˜ ์•ž๋ถ€๋ถ„์˜ ์š”์†Œ๋ฅผ ์‚ญ์ œํ•˜๋Š” shift() ํ•จ์ˆ˜ ๋“ฑ์˜ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•œ๋‹ค.
function Queue() {
    this.dataStore = [];
    this.enqueue = enqueue;
    this.dequeue = dequeue;
    this.front = front;
    this.back = back;
    this.toString = toString;
    this.empty = empty;
}

function enqueue(element) {
    this.dataStore.push(element);
}

function dequeue() {
    return this.dataStore.shift();// ๋ฐฐ์—ด ์•ž๋ถ€๋ถ„์— ์ €์žฅ๋œ ์š”์†Œ๋ฅผ ์‚ญ์ œ
}

function front() {
    return this.dataStore[0];
}

function back() {
    return this.dataStore[this.dataStore.length - 1];
}
// ๋ชจ๋“  ์š”์†Œ ์ถœ๋ ฅfunction toString() {
    let retStr = "";
    for (let i = 0; i < this.dataStore.length; ++i) {
        retStr += this.dataStore[i] + "\n";
    }
    return retStr;
}
// ํ๊ฐ€ ๋น„์—ˆ๋Š”์ง€ ํ™•์ธfunction empty() {
    if (this.dataStore.length === 0) {
        return true;
    } else {
        return false;
    }
}

let q = new Queue();
q.enqueue("M");
q.enqueue("C");
q.enqueue("J");
console.log(q.toString());
q.dequeue();
console.log(q.toString());
console.log("Front of queue: " + q.front());
console.log("Back of queue: " + q.back());
notion image
MCJ๋ฅผ ์ธํํ•˜๊ณ  ๋””ํ๋ฅผ ํ•œ๋ฒˆ ์ˆ˜ํ–‰ํ•˜๊ณ  ๋‚˜๋ฉด ๋งจ ์•ž์˜ ์š”์†Œ์ธ M์ด ์‚ฌ๋ผ์ง„ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.
front()๋Š” ๋งจ ์•ž์˜ ์š”์†Œ, back()์€ ๋งจ ๋’ค์˜ ์š”์†Œ๋ฅผ ๋ณด์—ฌ์ค€๋‹ค.

5.3 Queue ํด๋ž˜์Šค ์‚ฌ์šฉํ•˜๊ธฐ : ์Šคํ€˜์–ด ๋Œ„์Šค ํŒŒํ‹ฐ์—์„œ ํŒŒํŠธ๋„ˆ ์ •ํ•˜๊ธฐ

ํŒŒํ‹ฐ๊ฐ€ ์‹œ์ž‘๋˜๋ฉด ์ฒซ ๋ฒˆ์งธ ๋‚จ์ž์™€ ์—ฌ์ž๊ฐ€ ํŒŒํŠธ๋„ˆ๊ฐ€ ๋œ๋‹ค. ๋‹ค์Œ์œผ๋กœ ๊ฐ๊ฐ์˜ ์„ฑ๋ณ„์—์„œ ๋‹ค์Œ์œผ๋กœ ์ค„์„ ์„  ๋‚จ์ž๊ฐ€ ์•ž์œผ๋กœ ๋‚˜์˜ค๊ณ  ์ด๋ฆ„์ด ์†Œ๊ฐœ๋œ๋‹ค. ๋‚จ๋…€์˜ ์ค„์ด ์ค„์–ด๋“ค๋ฉด์„œ ๋งจ ์•ž์ค„์˜ ๋‚จ์€ ๋‚จ์ž๊ฐ€ ํ•˜๋‚˜๋„ ์—†์œผ๋ฉด ์ด ์‚ฌ์‹ค์„ ๊ณต์ง€ํ•œ๋‹ค.
function Queue() {
    this.dataStore = [];
    this.enqueue = enqueue;
    this.dequeue = dequeue;
    this.front = front;
    this.back = back;
    this.toString = toString;
    this.empty = empty;
    this.count = count;
}

function enqueue(element) {
    this.dataStore.push(element);
}

function dequeue() {
    return this.dataStore.shift();// ๋ฐฐ์—ด ์•ž๋ถ€๋ถ„์— ์ €์žฅ๋œ ์š”์†Œ๋ฅผ ์‚ญ์ œ
}

function front() {
    return this.dataStore[0];
}

function back() {
    return this.dataStore[this.dataStore.length - 1];
}
// ๋ชจ๋“  ์š”์†Œ ์ถœ๋ ฅfunction toString() {
    let retStr = "";
    for (let i = 0; i < this.dataStore.length; ++i) {
        retStr += this.dataStore[i] + "\n";
    }
    return retStr;
}
// ํ๊ฐ€ ๋น„์—ˆ๋Š”์ง€ ํ™•์ธfunction empty() {
    if (this.dataStore.length === 0) {
        return true;
    } else {
        return false;
    }
}

function Dancer(name, sex) {
    this.name = name;
    this.sex = sex;
}

function getDancers(males, females) {
// # : text file ์ฝ๊ธฐconst fs = require("fs");
    const names = fs.readFileSync("dancers.txt").toString().split("\n");

// # : trim()์œผ๋กœ ์•ž๋’ค๋กœ ๋ถ™์–ด ์žˆ๋Š” ๊ณต๋ฐฑ์„ ์—†์• ์ค€๋‹ค.for (let i = 0; i < names.length; ++i) {
        names[i] = names[i].trim();
    }

    for (let i = 0; i < names.length; ++i) {
// # : ๊ฐ ํ–‰์„ sex, name์œผ๋กœ ๊ตฌ๋ถ„ํ•˜๊ฒŒ ํ•œ๋‹ค.let dancer = names[i].split(" ");
// console.log(dancer[0], dancer[1]);let sex = dancer[0];
        let name = dancer[1];
        if (sex === "F") {
            females.enqueue(new Dancer(name, sex));
        } else {
            males.enqueue(new Dancer(name, sex));
        }
    }
}

function dance(males, females) {
    console.log("The dance partners are: \n");
    while (!females.empty() && !males.empty()) {
// # : ๋‚จ์ž, ์—ฌ์ž ๋Œ„์„œ๋ฅผ ์ง ์ง“๊ณ  ๊ณตํ‘œํ•œ๋‹ค.let person1 = females.dequeue();
        let person2 = males.dequeue();
        console.log(
            "Female dancer is: " + person1.name,
            "and the male dancer is: " + person2.name
        );
    }
}

let maleDancers = new Queue();
let femaleDancers = new Queue();
getDancers(maleDancers, femaleDancers);
dance(maleDancers, femaleDancers);
// if (!femaleDancers.empty()) {//     console.log(femaleDancers.front().name + " is waiting to dance.");// }// if (!maleDancers.empty()) {//     console.log(maleDancers.front().name + " is waiting to dance.");// }// # : ์—ฌ๊ธฐ์„œ๋Š” ์–ผ๋งˆ๋‚˜ ๋งŽ์€ ์ˆ˜์˜ ๋Œ„์„œ๊ฐ€ ๊ธฐ๋‹ค๋ฆฌ๊ณ  ์žˆ๋Š”์ง€ ์•Œ ์ˆ˜ ์—†๋‹ค. ํ์˜ ์š”์†Œ ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.function count() {
    return this.dataStore.length;
}

if (femaleDancers.count() > 0) {
    console.log(
        "There are " +
            femaleDancers.count() +
            " female dancers waiting to dance."
    );
}
if (maleDancers.count() > 0) {
    console.log(
        "There are " + maleDancers.count() + " male dancers waiting to dance."
    );
}
notion image
notion image
์œ„์˜ ํ…์ŠคํŠธ ํŒŒ์ผ์„ ์ฝ์–ด์™€์„œ ์ค„์„ ์„ธ์šด ๋’ค ์ง์„ ์ง€์–ด ์ฃผ์—ˆ๋Š”๋ฐ M(๋‚จ์„ฑ) 3๋ช…์ด ๋‚จ์•„์žˆ๋‹ค๊ณ  ๊ณต์ง€ํ•œ๋‹ค.

5.4 ํ๋กœ ๋ฐ์ดํ„ฐ ์ •๋ ฌํ•˜๊ธฐ

ํ๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ธฐ์ˆ˜์ •๋ ฌ์„ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค. ๊ธฐ์ˆ˜์ •๋ ฌ์€ ๋‘ ๋ฒˆ์˜ ๊ณผ์ •์„ ๊ฑฐ์ณ ๋ฐ์ดํ„ฐ๋ฅผ ์ •๋ ฌํ•œ๋‹ค. 0~99 ์ •์ˆ˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ด์šฉํ•œ๋‹ค. ์ฒ˜์Œ์—๋Š” 1์˜ ์ž๋ฆฌ ์ˆซ์ž๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์ˆซ์ž๋ฅผ ์ •๋ ฌํ•˜๊ณ  ๋‘ ๋ฒˆ์งธ๋Š” 10์˜ ์ž๋ฆฌ ์ˆซ์ž๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ •๋ ฌํ•œ๋‹ค.
function Queue() {
    this.dataStore = [];
    this.enqueue = enqueue;
    this.dequeue = dequeue;
    this.front = front;
    this.back = back;
    this.toString = toString;
    this.empty = empty;
    this.count = count;
}

function enqueue(element) {
    this.dataStore.push(element);
}

function dequeue() {
    return this.dataStore.shift();// ๋ฐฐ์—ด ์•ž๋ถ€๋ถ„์— ์ €์žฅ๋œ ์š”์†Œ๋ฅผ ์‚ญ์ œ
}

function front() {
    return this.dataStore[0];
}

function back() {
    return this.dataStore[this.dataStore.length - 1];
}
// ๋ชจ๋“  ์š”์†Œ ์ถœ๋ ฅfunction toString() {
    let retStr = "";
    for (let i = 0; i < this.dataStore.length; ++i) {
        retStr += this.dataStore[i] + "\n";
    }
    return retStr;
}
// ํ๊ฐ€ ๋น„์—ˆ๋Š”์ง€ ํ™•์ธfunction empty() {
    if (this.dataStore.length === 0) {
        return true;
    } else {
        return false;
    }
}

function count() {
    return this.dataStore.length;
}

// @ : ํ๋กœ ๋ฐ์ดํ„ฐ ์ •๋ ฌํ•˜๊ธฐ, ๊ธฐ์ˆ˜ ์ •๋ ฌ, 1์˜ ์ž๋ฆฌ ๊ธฐ์ค€์œผ๋กœ ์ˆซ์ž ์ •๋ ฌ ํ›„ 10์˜ ์ž๋ฆฌ ๊ธฐ์ค€์œผ๋กœ ์ˆซ์ž ์ •๋ ฌ. ๊ฐ ์ˆซ์ž๋‹น 1๊ฐœ์˜ ํ์ด๋ฏ€๋กœ 9๊ฐœ์˜ ํ๊ฐ€ ํ•„์š”ํ•˜๋‹ค.function distribute(nums, queues, n, digit) {
    for (let i = 0; i < n; ++i) {
        if (digit === 1) {
            queues[nums[i] % 10].enqueue(nums[i]);
        } else {
            queues[Math.floor(nums[i] / 10)].enqueue(nums[i]);
        }
    }
}
// @ : ํ์— ์ €์žฅ๋œ ์ˆซ์ž๋ฅผ ์ˆ˜์ง‘ํ•˜๋Š” ํ•จ์ˆ˜function collect(queues, nums) {
    let i = 0;
    for (let digit = 0; digit < 10; ++digit) {
        while (!queues[digit].empty()) {
            nums[i++] = queues[digit].dequeue();
        }
    }
}

function dispArray(arr) {
    for (let i = 0; i < arr.length; ++i) {
        console.log(arr[i] + " ");
    }
}

let queues = [];
for (let i = 0; i < 10; ++i) {
    queues[i] = new Queue();
}
let nums = [];
for (let i = 0; i < 10; ++i) {
    nums[i] = Math.floor(Math.floor(Math.random() * 101));
}
console.log("Before radix sort: ");
dispArray(nums);
distribute(nums, queues, 10, 1);
collect(queues, nums);
distribute(nums, queues, 10, 10);
collect(queues, nums);
console.log("\n\nAfter radix sort: ");
dispArray(nums);
notion image
๋žœ๋คํ•œ ์ˆซ์ž๋ฅผ ๋„ฃ์–ด์„œ ๊ธฐ์ˆ˜์ •๋ ฌ๋œ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์ค€๋‹ค.

5.5 ์šฐ์„ ์ˆœ์œ„ ํ

๋ณดํ†ต ํ์—์„œ๋Š” ๋จผ์ € ๋„ฃ์€ ์š”์†Œ๋ถ€ํ„ฐ ์‚ญ์ œ๋œ๋‹ค. ํ•˜์ง€๋งŒ ์„ ์ž…์„ ์ถœ์ด ์•„๋‹ˆ๋ผ ์šฐ์„ ์ˆœ์œ„๊ฐ™์€ ๋‹ค๋ฅธ ๊ธฐ์ค€์œผ๋กœ ์š”์†Œ๋ฅผ ์‚ญ์ œํ•ด์•ผ ํ•˜๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜๋„ ์žˆ๋‹ค. ์ด๋Ÿด ๋•Œ ์šฐ์„ ์ˆœ์œ„ ํ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค.
์‘๊ธ‰์‹ค์—์„œ๋Š” ํ™˜์ž์˜ ์ƒํƒœ๋ฅผ ํ‰๊ฐ€ํ•ด ์šฐ์„ ์ˆœ์œ„ ์ฝ”๋“œ๋ฅผ ๋ถ€์—ฌํ•œ๋‹ค. ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋†’์€ ์ฝ”๋“œ๋ฅผ ๋ฐ›์€ ํ™˜์ž๋Š” ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋‚ฎ์€ ์ฝ”๋“œ๋ฅผ ๋ฐ›์€ ํ™˜์ž๋ณด๋‹ค ๋จผ์ € ์ง„๋ฃŒ๋ฅผ ๋ฐ›๋Š”๋‹ค. ํ•˜์ง€๋งŒ ๊ฐ™์€ ์šฐ์„ ์ˆœ์œ„ ์ฝ”๋“œ์ธ ๊ฒฝ์šฐ ์„ ์ž…์„ ์ถœ ๊ทœ์น™์„ ์ ์šฉํ•œ๋‹ค.
code๋Š” ์šฐ์„ ์ˆœ์œ„๋ฅผ ๋‚˜ํƒ€๋‚ด๋ฉฐ ๊ฐ€์žฅ ๋†’์€ ์šฐ์„ ์ˆœ์œ„๋Š” 1, 2, 3, 4,,, ์ˆœ์„œ์ด๋‹ค.(์ˆซ์ž๊ฐ€ ๋‚ฎ์„์ˆ˜๋ก ์šฐ์„ ์ˆœ์œ„๋Š” ๋†’๋‹ค)
dequeue ํ•จ์ˆ˜๋ฅผ ์ˆ˜์ •ํ•˜์—ฌ ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๊ฐ€์žฅ ๋†’์€ ์ฝ”๋“œ๋ฅผ ์ฐพ๋Š”๋‹ค.
function Queue() {
    this.dataStore = [];
    this.enqueue = enqueue;
    this.dequeue = dequeue;
    this.front = front;
    this.back = back;
    this.toString = toString;
    this.empty = empty;
    this.count = count;
}

function enqueue(element) {
    this.dataStore.push(element);
}

function dequeue() {
    return this.dataStore.shift();// ๋ฐฐ์—ด ์•ž๋ถ€๋ถ„์— ์ €์žฅ๋œ ์š”์†Œ๋ฅผ ์‚ญ์ œ
}

function front() {
    return this.dataStore[0];
}

function back() {
    return this.dataStore[this.dataStore.length - 1];
}
// ๋ชจ๋“  ์š”์†Œ ์ถœ๋ ฅfunction toString() {
    let retStr = "";
    for (let i = 0; i < this.dataStore.length; ++i) {
        retStr += this.dataStore[i] + "\n";
    }
    return retStr;
}
// ํ๊ฐ€ ๋น„์—ˆ๋Š”์ง€ ํ™•์ธfunction empty() {
    if (this.dataStore.length === 0) {
        return true;
    } else {
        return false;
    }
}

function count() {
    return this.dataStore.length;
}

// # : ์šฐ์„ ์ˆœ์œ„ ํ// # : ์˜ˆ์ง„ ๊ฐ„ํ˜ธ์‚ฌ๊ฐ€ ํ™˜์ž ๊ฒ€์‚ฌ >> ํ™˜์ž์ƒํƒœํ‰๊ฐ€๋กœ ์šฐ์„ ์ˆœ์œ„ ์ฝ”๋“œ ๋ถ€์—ฌ >> ์šฐ์„ ์ˆœ์œ„ ๋†’์œผ๋ฉด ๋จผ์ € ์ง„๋ฃŒ๋ฐ›์Œ(์šฐ์„ ์ˆœ์œ„ ์ฝ”๋“œ๊ฐ€ ๊ฐ™์œผ๋ฉด ์„ ์ž…์„ ์ถœ)function Patient(name, code) {
    this.name = name;
    this.code = code;// ์šฐ์„ ์ˆœ์œ„ or ์‹ฌ๊ฐ์„ฑ
}
// # : ๊ฐ€์žฅ ๋†’์€ ์šฐ์„ ์ˆœ์œ„(1 > 2 > 3 > 4 > ,,,) ์‚ญ์ œfunction dequeue() {
    let entry = 0;
    for (let i = 0; i < this.dataStore.length; ++i) {
        if (this.dataStore[i].code < this.dataStore[entry].code) {
            console.log(
                "deq",
                this.dataStore[i].code,
                this.dataStore[entry].code
            );

            entry = i;
            console.log("ent: ", entry);
        }
    }
    return this.dataStore.splice(entry, 1);
}
// # : ์ถœ๋ ฅfunction toString() {
    let retStr = "";
    for (let i = 0; i < this.dataStore.length; ++i) {
        retStr +=
            this.dataStore[i].name + " code: " + this.dataStore[i].code + "\n";
    }
    return retStr;
}
// # : worklet p = new Patient("Smith", 5);
let ed = new Queue();
ed.enqueue(p);
p = new Patient("Jones", 4);
ed.enqueue(p);
p = new Patient("Fehrenbach", 6);
ed.enqueue(p);
p = new Patient("Brown", 1);
ed.enqueue(p);
p = new Patient("Ingram", 1);
ed.enqueue(p);
console.log(ed.toString());
let seen = ed.dequeue();
console.log("Patient being treated: " + seen[0].name);
console.log("Patients waiting to be seen: ");
console.log(ed.toString());
// ๋‹ค์Œ ํ™˜์ž ์น˜๋ฃŒ
seen = ed.dequeue();
console.log("Patient being treated: " + seen[0].name);
console.log("Patients waiting to be seen: ");
console.log(ed.toString());
seen = ed.dequeue();
console.log("Patient being treated: " + seen[0].name);
console.log("Patients waiting to be seen: ");
console.log(ed.toString());
notion image

5.6 ์—ฐ์Šต๋ฌธ์ œ

# 1. Queue ํด๋ž˜์Šค๋ฅผ ๊ณ ์ณ์„œ Deque ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“œ์‹œ์˜ค. Deque๋Š” ํ์™€ ๋น„์Šทํ•œ ์ž๋ฃŒ๊ตฌ์กฐ๋กœ ๋ฆฌ์ŠคํŠธ์˜ ์•ž๋ถ€๋ถ„๊ณผ ๋๋ถ€๋ถ„ ๋ชจ๋‘์—์„œ ์š”์†Œ์˜ ์‚ฝ์ž…๊ณผ ์‚ญ์ œ๊ฐ€ ์ผ์–ด๋‚œ๋‹ค. ํ”„๋กœ๊ทธ๋žจ์„ ์ด์šฉํ•ด ๊ตฌํ˜„ํ•œ Deque ํด๋ž˜์Šค๋ฅผ ํ…Œ์ŠคํŠธํ•˜์‹œ์˜ค.
push_front ๋Š” ๋งจ ์•ž ์ธ๋ฑ์Šค(0)์— ์š”์†Œ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ฒŒ๋” splice ๋ฉ”์„œ๋“œ๋ฅผ ์ด์šฉํ•ด ๊ตฌํ˜„ํ•˜์˜€๊ณ  pop_back ์€ length ํ”„๋กœํผํ‹ฐ๋ฅผ ์ด์šฉํ•ด์„œ ๋งจ ๋’ค์˜ ์š”์†Œ์˜ ์ธ๋ฑ์Šค๋ฅผ length-1๋กœ ๊ฐ€์ ธ์™€์„œ ํ•ด๋‹น ์œ„์น˜์˜ ์š”์†Œ๋ฅผ 1๊ฐœ ์ง€์šฐ๋„๋ก splice ๋ฉ”์„œ๋“œ๋ฅผ ์ด์šฉํ•ด ๊ตฌํ˜„ํ•˜์˜€๋‹ค.
// # : # 1. Queue ํด๋ž˜์Šค๋ฅผ ๊ณ ์ณ์„œ Deque ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“œ์‹œ์˜ค.// # : Deque๋Š” ํ์™€ ๋น„์Šทํ•œ ์ž๋ฃŒ๊ตฌ์กฐ๋กœ ๋ฆฌ์ŠคํŠธ์˜ ์•ž๋ถ€๋ถ„๊ณผ ๋๋ถ€๋ถ„ ๋ชจ๋‘์—์„œ ์š”์†Œ์˜ ์‚ฝ์ž…๊ณผ ์‚ญ์ œ๊ฐ€ ์ผ์–ด๋‚œ๋‹ค.// # : ํ”„๋กœ๊ทธ๋žจ์„ ์ด์šฉํ•ด ๊ตฌํ˜„ํ•œ Deque ํด๋ž˜์Šค๋ฅผ ํ…Œ์ŠคํŠธํ•˜์‹œ์˜ค.function Deque() {
    this.dataStore = [];
    this.push_front = push_front;
    this.push_back = push_back;
    this.pop_front = pop_front;
    this.pop_back = pop_back;
    this.front = front;
    this.back = back;
    this.toString = toString;
    this.empty = empty;
}
// # :  push_front() : ๋งจ ์•ž์— ์ƒˆ๋กœ์šด ์š”์†Œ๋ฅผ ์‚ฝ์ž…ํ•œ๋‹ค.// # :  push_back() : ๋งจ ๋’ค์— ์ƒˆ๋กœ์šด ์š”์†Œ๋ฅผ ์‚ฝ์ž…ํ•œ๋‹ค.// # :  pop_front() : ๋งจ ์•ž์— ์š”์†Œ๋ฅผ ์ œ๊ฑฐํ•œ๋‹ค.// # :  pop_back() : ๋งจ ๋’ค์— ์š”์†Œ๋ฅผ ์ œ๊ฑฐํ•œ๋‹ค.// ! : splice(๋งจ ์•ž ์ธ๋ฑ์Šค, 0, ์ถ”๊ฐ€ํ•˜๋ ค๋Š” ์š”์†Œ)๋ฅผ ์ด์šฉํ•œ๋‹ค. ๋‘ ๋ฒˆ์งธ ์ธ์ž์˜ ๊ธธ์ด๋งŒํผ ์‚ญ์ œํ•˜์ง€๋งŒ 0์ด๋ฉด ์ถ”๊ฐ€.function push_front(element) {
    this.dataStore.splice(0, 0, element);
}
function push_back(element) {
    this.dataStore.push(element);
}
function pop_front() {
    return this.dataStore.shift();// ๋ฐฐ์—ด ์•ž๋ถ€๋ถ„์— ์ €์žฅ๋œ ์š”์†Œ๋ฅผ ์‚ญ์ œ
}
// ! : backํ•จ์ˆ˜์—์„œ length-1์„ ์‚ฌ์šฉํ•˜๋“ฏ ๋งจ ๋’ค์˜ ์š”์†Œ์— ๋Œ€ํ•œ ์ธ๋ฑ์Šค๋ฅผ ๊ฐ€์ ธ์™€์„œ ํ•ด๋‹น ์ธ๋ฑ์Šค๋ฅผ splice๋กœ ์‚ญ์ œํ•œ๋‹ค.function pop_back() {
    return this.dataStore.splice(this.dataStore.length - 1, 1);// ๋ฐฐ์—ด ์•ž๋ถ€๋ถ„์— ์ €์žฅ๋œ ์š”์†Œ๋ฅผ 1๊ฐœ ์‚ญ์ œ
}

function front() {
    return this.dataStore[0];
}

function back() {
    return this.dataStore[this.dataStore.length - 1];
}
// ๋ชจ๋“  ์š”์†Œ ์ถœ๋ ฅfunction toString() {
    let retStr = "";
    for (let i = 0; i < this.dataStore.length; ++i) {
        retStr += this.dataStore[i] + "\n";
    }
    return retStr;
}
// ํ๊ฐ€ ๋น„์—ˆ๋Š”์ง€ ํ™•์ธfunction empty() {
    if (this.dataStore.length === 0) {
        return true;
    } else {
        return false;
    }
}

let dq = new Deque();
dq.push_front("M");
dq.push_front("C");
dq.push_front("J");
console.log(dq.toString());
dq.pop_front();
console.log(dq.toString());
dq.pop_back();
console.log(dq.toString());
dq.push_back("A");
dq.push_back("B");
console.log(dq.toString());
console.log("Front of dequeue: " + dq.front());
console.log("Back of dequeue: " + dq.back());
notion image
# 2. 1๋ฒˆ์—์„œ ๊ตฌํ˜„ํ•œ Deque ํด๋ž˜์Šค๋ฅผ ์ด์šฉํ•ด ์ฃผ์–ด์ง„ ๋‹จ์–ด๊ฐ€ ํšŒ๋ฌธ์ธ์ง€ ๊ฒ€์‚ฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“œ์‹œ์˜ค.
// # : # 2. 1๋ฒˆ์—์„œ ๊ตฌํ˜„ํ•œ Deque ํด๋ž˜์Šค๋ฅผ ์ด์šฉํ•ด ์ฃผ์–ด์ง„ ๋‹จ์–ด๊ฐ€ ํšŒ๋ฌธ์ธ์ง€ ๊ฒ€์‚ฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“œ์‹œ์˜ค.function Deque() {
    this.dataStore = [];
    this.push_front = push_front;
    this.push_back = push_back;
    this.pop_front = pop_front;
    this.pop_back = pop_back;
    this.front = front;
    this.back = back;
    this.toString = toString;
    this.empty = empty;
}
function push_front(element) {
    this.dataStore.splice(0, 0, element);
}
function push_back(element) {
    this.dataStore.push(element);
}
function pop_front() {
    return this.dataStore.shift();// ๋ฐฐ์—ด ์•ž๋ถ€๋ถ„์— ์ €์žฅ๋œ ์š”์†Œ๋ฅผ ์‚ญ์ œ
}
function pop_back() {
    return this.dataStore.splice(this.dataStore.length - 1, 1);// ๋ฐฐ์—ด ์•ž๋ถ€๋ถ„์— ์ €์žฅ๋œ ์š”์†Œ๋ฅผ 1๊ฐœ ์‚ญ์ œ
}
function front() {
    return this.dataStore[0];
}
function back() {
    return this.dataStore[this.dataStore.length - 1];
}
// # : ๋ฌธ์ž์—ด์ด ํ•œ์ค„๋กœ ๋‚˜์˜ค๋„๋ก ์ˆ˜์ •function toString() {
    let retStr = "";
    for (let i = 0; i < this.dataStore.length; ++i) {
        retStr += this.dataStore[i];
    }
    return retStr;
}
function empty() {
    if (this.dataStore.length === 0) {
        return true;
    } else {
        return false;
    }
}
function palindrome(str) {
    let dq = new Deque();

    for (let i = 0; i < str.length; ++i) {
        dq.push_front(str[i]);
    }
    console.log(dq.toString());
    if (str === dq.toString()) {
        console.log("ํšŒ๋ฌธ์ž…๋‹ˆ๋‹ค.");
    } else {
        console.log("ํšŒ๋ฌธ ์•„๋‹™๋‹ˆ๋‹ค.");
    }
}

palindrome("reaer");
palindrome("alsdjfalsdjf");
palindrome("racecar");
palindrome("hello");
notion image
# 3. 5.5์˜ ์šฐ์„ ์ˆœ์œ„ ํ ์˜ˆ์ œ์—์„œ ๋‚ฎ์€ ์ˆ˜๊ฐ€ ์•„๋‹ˆ๋ผ ๋†’์€ ์ˆซ์ž๋ฅผ ๋†’์€ ์šฐ์„ ์ˆœ์œ„๋ฅผ ๊ฐ–๋„๋ก ํ”„๋กœ๊ทธ๋žจ์„ ๊ณ ์น˜์‹œ์˜ค. ํ…Œ์ŠคํŠธ ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ ์ œ๋Œ€๋กœ ์ž‘๋™ํ•˜๋Š”์ง€ ํ™•์ธํ•˜์‹œ์˜ค.
function Queue() {
    this.dataStore = [];
    this.enqueue = enqueue;
    this.dequeue = dequeue;
    this.front = front;
    this.back = back;
    this.toString = toString;
    this.empty = empty;
    this.count = count;
}

function enqueue(element) {
    this.dataStore.push(element);
}

function dequeue() {
    return this.dataStore.shift();// ๋ฐฐ์—ด ์•ž๋ถ€๋ถ„์— ์ €์žฅ๋œ ์š”์†Œ๋ฅผ ์‚ญ์ œ
}

function front() {
    return this.dataStore[0];
}

function back() {
    return this.dataStore[this.dataStore.length - 1];
}
// ๋ชจ๋“  ์š”์†Œ ์ถœ๋ ฅfunction toString() {
    let retStr = "";
    for (let i = 0; i < this.dataStore.length; ++i) {
        retStr += this.dataStore[i] + "\n";
    }
    return retStr;
}
// ํ๊ฐ€ ๋น„์—ˆ๋Š”์ง€ ํ™•์ธfunction empty() {
    if (this.dataStore.length === 0) {
        return true;
    } else {
        return false;
    }
}

function count() {
    return this.dataStore.length;
}

// # : ์šฐ์„ ์ˆœ์œ„ ํ// # : ์˜ˆ์ง„ ๊ฐ„ํ˜ธ์‚ฌ๊ฐ€ ํ™˜์ž ๊ฒ€์‚ฌ >> ํ™˜์ž์ƒํƒœํ‰๊ฐ€๋กœ ์šฐ์„ ์ˆœ์œ„ ์ฝ”๋“œ ๋ถ€์—ฌ >> ์šฐ์„ ์ˆœ์œ„ ๋†’์œผ๋ฉด ๋จผ์ € ์ง„๋ฃŒ๋ฐ›์Œ(์šฐ์„ ์ˆœ์œ„ ์ฝ”๋“œ๊ฐ€ ๊ฐ™์œผ๋ฉด ์„ ์ž…์„ ์ถœ)function Patient(name, code) {
    this.name = name;
    this.code = code;// ์šฐ์„ ์ˆœ์œ„ or ์‹ฌ๊ฐ์„ฑ
}
// ! : ๊ฐ€์žฅ ๋†’์€ ์šฐ์„ ์ˆœ์œ„(,,, > 4 > 3 > 2 > 1) ์‚ญ์ œfunction dequeue() {
    let entry = 0;
    for (let i = 0; i < this.dataStore.length; ++i) {
        if (this.dataStore[i].code > this.dataStore[entry].code) {
            console.log(
                "deq",
                this.dataStore[i].code,
                this.dataStore[entry].code
            );

            entry = i;
            console.log("ent: ", entry);
        }
    }
    return this.dataStore.splice(entry, 1);
}
// # : ์ถœ๋ ฅfunction toString() {
    let retStr = "";
    for (let i = 0; i < this.dataStore.length; ++i) {
        retStr +=
            this.dataStore[i].name + " code: " + this.dataStore[i].code + "\n";
    }
    return retStr;
}
// # : worklet p = new Patient("Smith", 5);
let ed = new Queue();
ed.enqueue(p);
p = new Patient("Jones", 4);
ed.enqueue(p);
p = new Patient("Fehrenbach", 6);
ed.enqueue(p);
p = new Patient("Brown", 1);
ed.enqueue(p);
p = new Patient("Ingram", 1);
ed.enqueue(p);
console.log(ed.toString());
let seen = ed.dequeue();
console.log("Patient being treated: " + seen[0].name);
console.log("Patients waiting to be seen: ");
console.log(ed.toString());
// ๋‹ค์Œ ํ™˜์ž ์น˜๋ฃŒ
seen = ed.dequeue();
console.log("Patient being treated: " + seen[0].name);
console.log("Patients waiting to be seen: ");
console.log(ed.toString());
seen = ed.dequeue();
console.log("Patient being treated: " + seen[0].name);
console.log("Patients waiting to be seen: ");
console.log(ed.toString());
(ํ’€์–ด๋ณด๊ธฐ)# 4. ์‚ฌ์šฉ์ž๊ฐ€ ์‘๊ธ‰์‹ค์˜ ํ™œ๋™์„ ์ œ์–ดํ•  ์ˆ˜ ์žˆ๋„๋ก ์‘๊ธ‰์‹ค ์˜ˆ์ œ(5.5)๋ฅผ ๊ณ ์น˜์‹œ์˜ค. ์‚ฌ์šฉ์ž๊ฐ€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ™œ๋™์„ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋„๋ก ์‹œ์Šคํ…œ ๋ฉ”๋‰ด๋ฅผ ๋งŒ๋“ค์–ด ์ œ๊ณตํ•˜์‹œ์˜ค.
a. ํ™˜์ž๊ฐ€ ์‘๊ธ‰์‹ค์— ๋“ค์–ด์˜ด.
b. ์˜์‚ฌ๊ฐ€ ํ™˜์ž๋ฅผ ๊ฒ€์‚ฌํ•จ.
c. ๋Œ€๊ธฐ ํ™˜์ž ๋ชฉ๋ก์„ ์ถœ๋ ฅํ•จ.