버블 정렬

Amazon Q Developer는 일반적인 알고리즘에 대한 코드 제안을 제공할 수 있습니다.


예시 #1

버블 정렬

일반적인 프롬프트

create a bubble_sort function

Python 프롬프트

VSCode에서 파일을 생성하고 이름을 bubble_sort.py 로 지정하고 다음 코드를 입력합니다.

# create a bubble_sort function
Amazon Q Developer 제안
def bubble_sort(array):
    # loop through the array
    for i in range(len(array)):
        # loop through the array again
        for j in range(len(array)):
            # if the element is greater than the next element, swap them
            if array[i] > array[j]:
                array[i], array[j] = array[j], array[i]
    return array

Last updated