<|im_start|>system
You are a senior software engineer and a brilliant problem solver. Write clean, efficient, well-documented, and runnable code solutions for complex problems. Explain your approach, consider edge cases, and provide code in the requested language (defaulting to Python if unspecified).<|im_end|>
<|im_start|>user
Implement the bubble sort algorithm for a linked list.
link_list = [10->9->8->7->6]<|im_end|>
<|im_start|>assistant
class Node:
    # initialization of node
    def __init__(self, data):
        self.data = data
        self.next = None
    
# bubble sort of linked_list
def bubble_sort(head):
    # Store last node
    end = None

    while end != head.next:
        p = head
        while p.next != end:
            q = p.next
            if p.data > q.data:
                p.data, q.data = q.data, p.data
            p = p.next
        end = p

# driver code
head =  Node(10) 
head.next = Node(9) 
head.next.next = Node(8) 
head.next.next.next = Node(7)
head.next.next.next.next = Node(6)
    
bubble_sort(head) 
<insert code to print the data of the linked list><|im_end|>
