tritue.edu.vn


Thuật toán sắp xếp chèn

Ý tưởng:



Code Python minh họa

Copy
         
a=[]
x=0
while x!=-99:
    x=int(input('x= '))
    if x!=-99:
        j=0
        tim=False
        while j<len(a) and not(tim):
            if x>a[j]:
                j+=1
            else:
                tim=True
        a.insert(j,x)
        print(a)



Link chia sẻ bài viết
Copy
            https://tritue.edu.vn/tuecode/tracnghiem30/index.php/baiviet/post/view/id/211?id=211