•알고리즘(Algorithm )

    [알고리즘] 삽입정렬 파이썬

    # 참고 Sorting (Bubble, Selection, Insertion, Merge, Quick, Counting, Radix) - VisuAlgo VisuAlgo is free of charge for Computer Science community on earth. If you like VisuAlgo, the only "payment" that we ask of you is for you to tell the existence of VisuAlgo to other Computer Science students/instructors that you know =) via Facebook/Twitte visualgo.net # 코드 def insertion_sort(input): data = inp..

    [알고리즘] 버블정렬 파이썬

    # 공부 - reversed 이용 range 뒤집기 # 코드 import random def swap(data,index): temp = data[index + 1] data[index + 1] = data[index] data[index] = temp print(data, index) def bubble_sort(input): size = len(input) data = input print(f"size {size}") for turn in reversed(range(size)): print(f"######### {turn}") for index in range(turn): if (input[index] > input[index + 1]): swap(data,index) print(f" sorted {..

    [정렬] 버블정렬(Bubble Sort) 알고리즘

    [정렬] 버블정렬(Bubble Sort) 알고리즘

    본 포스트는 개인 스터디에 대한 정리 및 기록의 용도로써, 오개념이 존재 할 수 있습니다. 글은 상시 수정되며, 지적사항에 대해서 검토 후 수정하겠습니다. 버블정렬 아마 가장 쉬운 정렬 알고리즘이지 않을까 싶다. 다른 정렬알고리즘을 몰랐을때 또는 자바나 C++의 내장 sort() 알고리즘의 사용법을 몰랐을때는 정렬해야하는 상황이 오면 함수로 만들어두고 사용했었다. 그러나 자료구조를 배우면서 시간복잡도를 배우게 됐는데, 상당히 비효율적인 알고리즘이었다. 처음 코딩을 배울때는 딱히 효율성을 생각하지 않아도 되기 때문에 사용했지만 요즘은 사용하지 않는다. 그러나 이 알고리즘을 사용하면서 for문에 대한 이해도가 생겼던 기억이 있다. 버블정렬의 속도 먼저 시작에 앞서 왜 비효율적이라고 했는지 버블정렬과 퀵소트 ..