CS/Algorithm

[์•Œ๊ณ ๋ฆฌ์ฆ˜] ์ •๋ ฌ(Sorting Algorithm)์ด๋ž€?

๊ฐœ๋ฐœ๊ฐœ๊ตด๐Ÿธ 2022. 9. 25. 19:10

์ •๋ ฌ์ด๋ž€?

์ปดํ“จํ„ฐ ๊ณผํ•™์—์„œ ์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋ž€ ์›์†Œ๋“ค์„ ๋ฒˆํ˜ธ์ˆœ์ด๋‚˜ ์‚ฌ์ „ ์ˆœ์„œ์™€ ๊ฐ™์ด ์ผ์ •ํ•œ ์ˆœ์„œ๋Œ€๋กœ ์—ด๊ฑฐํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ž…๋‹ˆ๋‹ค.

  • ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌ : 1, 2, 3, ..., n-1, n
  • ๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌ : n, n-1 ... 3, 2, 1

์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ณต์žก๋„ ๊ณ„์‚ฐ

์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ๋งค์šฐ ๋‹ค์–‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ๊ฐ์˜ ํšจ์œจ์„ฑ์„ ๋น„๊ตํ•˜๊ธฐ ์œ„ํ•ด ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ณต์žก๋„๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.

  • ์‹œ๊ฐ„ ๋ณต์žก๋„ : ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์‹คํ–‰ ์†๋„ (์‹œ๊ฐ„ ํšจ์œจ์„ฑ)
  • ๊ณต๊ฐ„ ๋ณต์žก๋„ : ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์‚ฌ์šฉํ•˜๋Š” ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์ด์ฆˆ (๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„ ํšจ์œจ์„ฑ)

 

์ด๋Ÿฌํ•œ ์‹œ๊ฐ„/๊ณต๊ฐ„ ๋ณต์žก๋„๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ๋น…์˜ค(Big-O), ๋น…์˜ค๋ฉ”๊ฐ€(Big-Ω), ๋น…์„ธํƒ€(Big-Θ) ํ‘œ๊ธฐ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

๋น…์˜ค ํ‘œ๊ธฐ๋ฒ•(big-O notation)์ด๋ž€?

๋น…์˜ค ํ‘œ๊ธฐ๋ฒ•์€ ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ํšจ์œจ์„ฑ์„ ํ‘œ๊ธฐํ•ด์ฃผ๋Š” ๊ธฐ๋ฒ•์œผ๋กœ ์ƒํ•œ์„  ๊ธฐ์ค€(์ตœ์•…์˜ ์‹œ๊ฐ„)์˜ ์‹œ๊ฐ„๋ณต์žก๋„๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.

 

์ž…๋ ฅ n์— ๋”ฐ๋ผ ๋ช‡๋ฒˆ ๊ณ„์‚ฐ์ด ์‹คํ–‰๋˜๋Š”์ง€๋ฅผ ํ‘œํ˜„์‹์— ๊ฐ€์žฅ ํฐ ์˜ํ–ฅ์„ ๋ฏธ์น˜๋Š” n์˜ ๋‹จ์œ„๋กœ ํ‘œ๊ธฐํ•˜๋ฉฐ ์‹œ๊ฐ„์ด ๋น ๋ฅธ์ˆœ์œผ๋กœ ๋‚˜์—ดํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 

O(1) < O(logn) < O(n) < O(nlogn) < O(n²) < O(2โฟ) < O(n!)

 

 

*๋น…์˜ค๋ฉ”๊ฐ€๋Š” ํ•˜ํ•œ์„  ๊ธฐ์ค€, ๋น…์„ธํƒ€๋Š” ์ƒํ•œ์„ ๊ณผ ํ•˜ํ•œ์„ ์˜ ์‚ฌ์ด๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํ‘œ๊ธฐํ•จ


๋Œ€ํ‘œ์ ์ธ ์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜

 

๊ตํ™˜, ์„ ํƒ, ์‚ฝ์ž… 3๊ฐ€์ง€ ํ•ต์‹ฌ์š”์†Œ๋ฅผ ํ†ตํ•ด ์ •๋ ฌํ•˜๋Š” ๋Œ€ํ‘œ์ ์ธ ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 

Name Best Avg Worst
๊ฑฐํ’ˆ ์ •๋ ฌ (Bubble Sort) O(n²)  O(n²)  O(n²) 
์„ ํƒ ์ •๋ ฌ(Selection Sort) O(n²)  O(n²)  O(n²) 
์‚ฝ์ž… ์ •๋ ฌ(Insertion Sort) O(n) O(n²)  O(n²) 
ํ€ต ์ •๋ ฌ(Quick Sort) O(nlogn)  O(nlogn)  O(n²) 
๋ณ‘ํ•ฉ ์ •๋ ฌ(Merge Sort) O(nlogn)  O(nlogn)  O(nlogn) 
ํž™ ์ •๋ ฌ(Heap Sort) O(nlogn)  O(nlogn)  O(nlogn) 
๊ธฐ์ˆ˜ ์ •๋ ฌ(Radix Sort) O(n) O(n) O(n)
๊ณ„์ˆ˜ ์ •๋ ฌ(Counting Sort) O(n) O(n) O(n)

 

๊ฑฐํ’ˆ ์ •๋ ฌ (Bubble Sort)

๋ฒ„๋ธ” ์ •๋ ฌ์€ ์„œ๋กœ ์ธ์ ‘ํ•œ ๋‘ ์›์†Œ๋ฅผ ๋น„๊ตํ•˜์—ฌ, ์กฐ๊ฑด์— ๋งž์ง€ ์•Š๋‹ค๋ฉด ์ž๋ฆฌ๋ฅผ ๊ตํ™˜ํ•˜๋ฉฐ ์ •๋ ฌํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ž…๋‹ˆ๋‹ค.

(์ •๋ ฌ ๊ณผ์ •์—์„œ ์›์†Œ์˜ ์ด๋™์ด ๊ฑฐํ’ˆ์ด ์ˆ˜๋ฉด์œผ๋กœ ์˜ฌ๋ผ์˜ค๋Š” ๋“ฏํ•œ ๋ชจ์Šต์„ ๋ณด์ด๊ธฐ ๋•Œ๋ฌธ์— ๋ฒ„๋ธ”์ •๋ ฌ์ด๋ผ๋Š” ์ด๋ฆ„์ด ์ง€์–ด์ง)

  • ์‹œ๊ฐ„ ๋ณต์žก๋„ : O(n²) 
  • ๊ณต๊ฐ„ ๋ณต์žก๋„ : O(n)
  • ์žฅ๋‹จ์  : ๊ตฌํ˜„์ด ์‰ฝ์ง€๋งŒ ๋น„ํšจ์œจ์ 

์•„๋ž˜์™€ ๊ฐ™์ด 0๋ฒˆ index๋ถ€ํ„ฐ n-1๋ฒˆ index๊นŒ์ง€ n๋ฒˆ๊นŒ์ง€์˜ ๋ชจ๋“  index๋ฅผ ๋น„๊ตํ•˜๋ฉฐ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค.

 

 

function bubbleSort (arr) {

  for(let i = 0; i < arr.length; i++) {
  	for(let j = 0; j < arr.length -1 - i; j++) {
    	if(arr[j] > arr[j + 1]) {
        	let swap = arr[j]
            arr[j] = arr[j + 1]
          	arr[j + 1] = swap
        }
    }
  }
  return arr
}

 

 

์„ ํƒ ์ •๋ ฌ(Selection Sort)

์„ ํƒ ์ •๋ ฌ์€ ํ•ด๋‹น ์ˆœ์„œ์— ์›์†Œ๋ฅผ ๋„ฃ์„ ์œ„์น˜๋Š” ์ด๋ฏธ ์ •ํ•ด์ ธ ์žˆ๊ณ , ์–ด๋–ค ์›์†Œ๋ฅผ ๋„ฃ์„์ง€ ์„ ํƒํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ž…๋‹ˆ๋‹ค.

  • ์‹œ๊ฐ„ ๋ณต์žก๋„ : O(n²) 
  • ๊ณต๊ฐ„ ๋ณต์žก๋„ : O(n)
  • ์žฅ๋‹จ์  : ๊ตฌํ˜„์ด ์‰ฝ์ง€๋งŒ ๋น„ํšจ์œจ์ , ๋ฒ„๋ธ”๋ณด๋‹ค ์•ฝ๊ฐ„ ๋น ๋ฆ„

์•„๋ž˜์™€ ๊ฐ™์ด ์ฒซ ๋ฒˆ์งธ ๊ฐ’์„ ๋‘ ๋ฒˆ์งธ ๋ถ€ํ„ฐ ๋งˆ์ง€๋ง‰ ๊ฐ’๊นŒ์ง€ ์ฐจ๋ก€๋Œ€๋กœ ๋น„๊ตํ•˜์—ฌ ์ตœ์†Ÿ๊ฐ’์„ ์ฐพ์•„ ์ฒซ ๋ฒˆ์งธ์— ๋†“๊ณ , ๋‘ ๋ฒˆ์งธ ๊ฐ’์„ ์„ธ ๋ฒˆ์งธ ๋ถ€ํ„ฐ ๋งˆ์ง€๋ง‰ ๊ฐ’๊นŒ์ง€ ๋น„๊ตํ•˜์—ฌ ์ตœ์†Ÿ๊ฐ’์„ ์ฐพ์•„ ๋‘ ๋ฒˆ์งธ ์œ„์น˜์— ๋†“๋Š” ๊ณผ์ •์„ ๋ฐ˜๋ณตํ•˜๋ฉฐ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค.

 

 

function selectSort (arr) { 

    for(let i = 0; i < arr.length; i++) {
        let min = i
        for(let j = i + 1; j < arr.length; j++) {
            if(arr[min] > arr[j]) {
                min = j
            }
        }
        
        if(min !== i) {
            let swap = arr[min]
            arr[min] = arr[i]
            arr[i] = swap
        }
    }

    return arr 
}

 

 

์‚ฝ์ž… ์ •๋ ฌ(Insertion Sort)

์‚ฝ์ž… ์ •๋ ฌ์€ ๋‘ ๋ฒˆ์งธ ์›์†Œ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜์—ฌ ๊ทธ ์•ž(์™ผ์ชฝ)์˜ ์›์†Œ๋“ค๊ณผ ๋น„๊ตํ•˜์—ฌ ์‚ฝ์ž…ํ•  ์œ„์น˜๋ฅผ ์ง€์ •ํ•œ ํ›„, ์›์†Œ๋ฅผ ๋’ค๋กœ ์˜ฎ๊ธฐ๊ณ  ์ง€์ •๋œ ์ž๋ฆฌ์— ์ž๋ฃŒ๋ฅผ ์‚ฝ์ž…ํ•˜์—ฌ ์ •๋ ฌํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ž…๋‹ˆ๋‹ค.

  • ์‹œ๊ฐ„ ๋ณต์žก๋„ : O(n) (์ตœ์•…์˜ ๊ฒฝ์šฐ O(n²) )
  • ๊ณต๊ฐ„ ๋ณต์žก๋„ : O(n)
  • ์žฅ๋‹จ์  : ์„ฑ๋Šฅ์ด ์ข‹์•„์„œ ๋‹ค๋ฅธ ์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ์ผ๋ถ€๋กœ ์‚ฌ์šฉ๋˜๊ธฐ๋„ ํ•จ, ๋ฐ์ดํ„ฐ ์ƒํƒœ๋‚˜ ํฌ๊ธฐ์— ๋”ฐ๋ผ ํŽธ์ฐจ๊ฐ€ ์‹ฌํ•จ

 

function insertionSort(arr) {
    
    for(let i = 1; i < arr.length; i ++) {
        let cur = arr[i]
        let left = i - 1

        while(left >= 0) {
          if(arr[left] > arr[left + 1]) {
            arr[left + 1] = arr[left]
            arr[left] = cur
          }
            left--
        }        
    }

    return arr 
}

 

 

ํ€ต ์ •๋ ฌ(Quick Sort)

ํ€ต ์ •๋ ฌ์€ ๋ถ„ํ•  ์ •๋ณต ๋ฐฉ๋ฒ•์„ ํ†ตํ•ด ์ฃผ์–ด์ง„ ๋ฐฐ์—ด์„ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค. 

  • ์‹œ๊ฐ„ ๋ณต์žก๋„ : O(nlogn)  (์ตœ์•…์˜ ๊ฒฝ์šฐ O(n²) )
  • ๊ณต๊ฐ„ ๋ณต์žก๋„ : O(n)
  • ์žฅ๋‹จ์  : ๋งค์šฐ ๋น ๋ฅด์ง€๋งŒ ์ตœ์•…์˜ ํ”ผ๋ด‡์„ ์„ ํƒํ•  ๊ฒฝ์šฐ ์‹œ๊ฐ„๋ณต์žก๋„๊ฐ€ ๋งŽ์ด ๋Š˜์–ด๋‚จ

์•„๋ž˜์™€ ๊ฐ™์ด ํ”ผ๋ด‡์„ ์„ค์ •ํ•˜๊ณ  ํ”ผ๋ด‡๋ณด๋‹ค ํฐ ๊ฐ’๊ณผ ์ž‘์€ ๊ฐ’์œผ๋กœ ๋ถ„ํ• ํ•˜์—ฌ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค. ๋ณ‘ํ•ฉ ์ •๋ ฌ๊ณผ ๋‹ฌ๋ฆฌ ๋ฐฐ์—ด์„ ๋น„๊ท ๋“ฑํ•˜๊ฒŒ ๋ถ„ํ• ํ•œ๋‹ค๋Š” ํŠน์ง•์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

function quickSort(arr) {

if(arr.length <= 1) {
  return arr
}
  
   let cur = arr[0]
   let left = []
   let right = []
    
    for(let i = 1; i < arr.length; i++) {
      
    	if(cur > arr[i]) {
		left.push(arr[i])
	} else {
		right.push(arr[i])
	}
      
    }
  
  	let leftArr = quickSort(left)
	let rightArr = quickSort(right)
    
    return [...leftArr, cur, ...rightArr]
}

 

 

๋ณ‘ํ•ฉ ์ •๋ ฌ(Merge Sort)

๋ณ‘ํ•ฉ ์ •๋ ฌ์€ ํ•ฉ๋ณ‘ ์ •๋ ฌ์ด๋ผ๊ณ ๋„ ๋ถ€๋ฅด๋ฉฐ, ๋ถ„ํ• /์ •๋ณต ๋ฐฉ๋ฒ•์„ ํ†ตํ•ด ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.

  • ์‹œ๊ฐ„ ๋ณต์žก๋„ : O(nlogn)
  • ๊ณต๊ฐ„ ๋ณต์žก๋„ : O(n)
  • ์žฅ๋‹จ์  : ํ€ต ์ •๋ ฌ๊ณผ ๋‹ฌ๋ฆฌ ํ”ผ๋ด‡์„ ์„ค์ •ํ•˜์ง€ ์•Š์•„ ๊ธฐ๋ณต์ด ์—†์Œ, ์ถ”๊ฐ€์ ์ธ ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ํ•„์š”ํ•˜๋Š” ๋‹จ์ ์ด ์žˆ์Œ

์•„๋ž˜์™€ ๊ฐ™์ด ์ฃผ์–ด์ง„ ๋ฐฐ์—ด์„ ํฌ๊ธฐ๊ฐ€ 1์ธ ๋ฐฐ์—ด๋กœ ๋ถ„ํ• ํ•˜๊ณ  ํ•ฉ๋ณ‘ํ•˜๋ฉด์„œ ์ •๋ ฌ์„ ์ง„ํ–‰ํ•˜๋Š” ๋ถ„ํ• /์ •๋ณต ์•Œ๊ณ ๋ฆฌ์ฆ˜์ž…๋‹ˆ๋‹ค.

 

 

private void solve() {
    int[] array = { 230, 10, 60, 550, 40, 220, 20 };
 
    mergeSort(array, 0, array.length - 1);
 
    for (int v : array) {
        System.out.println(v);
    }
}
 
public static void mergeSort(int[] array, int left, int right) {
    if (left < right) {
        int mid = (left + right) / 2;
 
        mergeSort(array, left, mid);
        mergeSort(array, mid + 1, right);
        merge(array, left, mid, right);
    }
}
 
public static void merge(int[] array, int left, int mid, int right) {
    int[] L = Arrays.copyOfRange(array, left, mid + 1);
    int[] R = Arrays.copyOfRange(array, mid + 1, right + 1);
 
    int i = 0, j = 0, k = left;
    int ll = L.length, rl = R.length;
 
    while (i < ll && j < rl) {
        if (L[i] <= R[j]) {
            array[k] = L[i++];
        } else {
            array[k] = R[j++];
        }
        k++;
    }
 
    while (i < ll) {
        array[k++] = L[i++];
    }
 
    while (j < rl) {
        array[k++] = R[j++];
    }
}

 

ํž™ ์ •๋ ฌ(Heap Sort)

ํž™ ์ •๋ ฌ์€ *์™„์ „ ์ด์ง„ ํŠธ๋ฆฌ๋ฅผ ๊ธฐ๋ณธ์œผ๋กœ ํ•˜๋Š” ํž™ ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์ •๋ ฌํ•˜๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค.

  • ์‹œ๊ฐ„ ๋ณต์žก๋„ : O(nlogn)
  • ๊ณต๊ฐ„ ๋ณต์žก๋„ : O(n)
  • ์žฅ๋‹จ์  : ์ถ”๊ฐ€์ ์ธ ๋ฉ”๋จธ๋ฆฌ๋ฅผ ํ•„์š”๋กœ ํ•˜์ง€ ์•Š์Œ, ๋ฐ์ดํ„ฐ ์ƒํƒœ์— ๋น„ํ•ด ๋‹ค๋ฅธ ์ •๋ ฌ๋ณด๋‹ค ๋Š๋ฆฐ ๊ฒฝ์šฐ๊ฐ€ ์žˆ์Œ

*์™„์ „ ์ด์ง„ ํŠธ๋ฆฌ : ์‚ฝ์ž…ํ•  ๋•Œ ์™ผ์ชฝ๋ถ€ํ„ฐ ์ฐจ๋ก€๋Œ€๋กœ ์ถ”๊ฐ€ํ•˜๋Š” ์ด์ง„ ํŠธ๋ฆฌ

 

์•„๋ž˜์™€ ๊ฐ™์ด ์ฃผ์–ด์ง„ ๋ฐ์ดํ„ฐ๋ฅผ ํž™ ์ž๋ฃŒ๊ตฌ์กฐ๋กœ ๋งŒ๋“ค์–ด ์ตœ๋Œ“๊ฐ’ ๋˜๋Š” ์ตœ์†Ÿ๊ฐ’๋ถ€ํ„ฐ ํ•˜๋‚˜์”ฉ ๊บผ๋‚ด์„œ ์ •๋ ฌํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ž…๋‹ˆ๋‹ค.

 

 

private void solve() {
    int[] array = { 230, 10, 60, 550, 40, 220, 20 };
 
    heapSort(array);
 
    for (int v : array) {
        System.out.println(v);
    }
}
 
public static void heapify(int array[], int n, int i) {
    int p = i;
    int l = i * 2 + 1;
    int r = i * 2 + 2;
 
    if (l < n && array[p] < array[l]) {
        p = l;
    }
 
    if (r < n && array[p] < array[r]) {
        p = r;
    }
 
    if (i != p) {
        swap(array, p, i);
        heapify(array, n, p);
    }
}
 
public static void heapSort(int[] array) {
    int n = array.length;
 
    // init, max heap
    for (int i = n / 2 - 1; i >= 0; i--) {
        heapify(array, n, i);
    }
 
    // for extract max element from heap
    for (int i = n - 1; i > 0; i--) {
        swap(array, 0, i);
        heapify(array, i, 0);
    }
}
 
public static void swap(int[] array, int a, int b) {
    int temp = array[a];
    array[a] = array[b];
    array[b] = temp;
}

[์ฐธ๊ณ ]

https://ko.wikipedia.org/wiki/%EC%A0%95%EB%A0%AC_%EC%95%8C%EA%B3%A0%EB%A6%AC%EC%A6%98

 

์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜ - ์œ„ํ‚ค๋ฐฑ๊ณผ, ์šฐ๋ฆฌ ๋ชจ๋‘์˜ ๋ฐฑ๊ณผ์‚ฌ์ „

์œ„ํ‚ค๋ฐฑ๊ณผ, ์šฐ๋ฆฌ ๋ชจ๋‘์˜ ๋ฐฑ๊ณผ์‚ฌ์ „. ์ปดํ“จํ„ฐ ๊ณผํ•™๊ณผ ์ˆ˜ํ•™์—์„œ ์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜(sorting algorithm)์ด๋ž€ ์›์†Œ๋“ค์„ ๋ฒˆํ˜ธ์ˆœ์ด๋‚˜ ์‚ฌ์ „ ์ˆœ์„œ์™€ ๊ฐ™์ด ์ผ์ •ํ•œ ์ˆœ์„œ๋Œ€๋กœ ์—ด๊ฑฐํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋‹ค. ํšจ์œจ์ ์ธ ์ •๋ ฌ์€

ko.wikipedia.org

https://velog.io/@msriver/%EC%95%8C%EA%B3%A0%EB%A6%AC%EC%A6%98-%EC%A0%95%EB%A0%AC%EC%9D%B4%EB%9E%80

 

[์•Œ๊ณ ๋ฆฌ์ฆ˜] ์ •๋ ฌ์ด๋ž€?

์—‘์…€์ด๋‚˜ ๋ฌธ์„œ์ž‘์„ฑ ํ”„๋กœ๊ทธ๋žจ์„ ์‚ฌ์šฉํ•œ ์‚ฌ๋žŒ์ด๋ผ๋ฉด ๋ฐ์ดํ„ฐ๋ฅผ ์˜ค๋ฆ„์ฐจ์ˆœ ํ˜น์€ ๋‚ด๋ฆผ์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌ ํ•ด๋ณธ์ ์ด ์žˆ์„ ๊ฒƒ์ด๋‹ค. ์ •๋ ฌ์ด๋ž€ ๋ฐ์ดํ„ฐ์˜ ์ง‘ํ•ฉ์„ ์–ด๋– ํ•œ ๊ธฐ์ค€(ํ•ต์‹ฌํ•ญ๋ชฉ, key)์˜ ๋Œ€์†Œ๊ด€๊ณ„๋ฅผ ๋”ฐ์ ธ

velog.io

https://velog.io/@milkyway/javascript-%EC%A0%95%EB%A0%AC-%EC%95%8C%EA%B3%A0%EB%A6%AC%EC%A6%98-%EC%A2%85%ED%95%A9-%EC%A0%95%EB%A6%AC

 

javascript ์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ข…ํ•ฉ ์ •๋ฆฌ

๋ฐฐ์—ด ์š”์†Œ์˜ ๊ฐ’ ์ •๋ฆฌ๋ฅผ ์œ„ํ•œ ์•Œ๊ณ ๋ฆฌ์ฆ˜

velog.io

https://velog.io/@skawnkk/Big-O-Notation-%EB%B3%B5%EC%9E%A1%EB%8F%84-%EC%B8%A1%EC%A0%95%EB%B0%A9%EB%B2%95

 

Big-O Notation ๋ณต์žก๋„ - ์ •๋ ฌ

์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ณต์žก๋„ ๊ณ„์‚ฐ ํ•ญ๋ชฉ1\. ์‹œ๊ฐ„ ๋ณต์žก๋„: ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์‹คํ–‰ ์†๋„2\. ๊ณต๊ฐ„ ๋ณต์žก๋„: ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์‚ฌ์šฉํ•˜๋Š” ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์ด์ฆˆ์‹œ๊ฐ„์ด ์ค‘์š”ํ•˜๋‹ค.์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ตœ์•…์˜ ์‹คํ–‰ ์‹œ๊ฐ„์„ ํ‘œ๊ธฐํ•œ๋‹ค. (์ตœ์†Œ ์ด ์„ฑ๋Šฅ์„ ๋ณด

velog.io

https://noahlogs.tistory.com/27

 

๋น…์˜ค ํ‘œ๊ธฐ๋ฒ• (big-O notation) ์ด๋ž€

 ์ปดํ“จํ„ฐ ๊ณผํ•™(Computer Science) ์—์„œ ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ์–ด๋– ํ•œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•œ ๋ฐฉ๋ฒ•์ด๊ณ , ์–ด๋– ํ•œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐ ํ•˜๊ธฐ ์œ„ํ•œ ๋ฐฉ๋ฒ•์€ ๋‹ค์–‘ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐฉ๋ฒ•(์•Œ๊ณ ๋ฆฌ์ฆ˜) ๊ฐ„์— ํšจ์œจ์„ฑ์„ ๋น„๊ตํ•˜๊ธฐ ์œ„ํ•ด ๋น…์˜ค(

noahlogs.tistory.com

https://wooder2050.medium.com/%EC%A0%95%EB%A0%AC-%EC%95%8C%EA%B3%A0%EB%A6%AC%EC%A6%98-%EC%A0%95%EB%A6%AC-54349222f432

 

์ •๋ ฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ •๋ฆฌ

๋ฒ„๋ธ” ์ •๋ ฌ, ํ•ฉ๋ณ‘ ์ •๋ ฌ, ํ€ต ์ •๋ ฌ

wooder2050.medium.com

https://gyoogle.dev/blog/

 

๐Ÿ‘จ๐Ÿป‍๐Ÿ’ป Tech Interview

์ตœ์ข… ์ˆ˜์ • : 9/20/2022, 10:14:18 AM

gyoogle.dev