Bubble Sort Linked List

This is the place for queries that don't fit in any of the other categories.

Bubble Sort Linked List

Postby dezeray112 » Thu Dec 12, 2013 2:17 am

Hi, I am currently trying to program a singly linked list by sorting the nodes in ascending order using the Bubble Sort Algorithm in Python.

Code: Select all

def (sort):
while a1 != None:
while ap:
if ap.val>ap2.val:
print a1.val
print l1

The code I've implemented was able to change the nodes, however it was not able to loop through and it will not add in the next value as it only prints out 2 values. Can someone tell me is there something that I am missing in my code?
Last edited by micseydel on Thu Dec 12, 2013 5:51 am, edited 1 time in total.
Reason: Locked.
Posts: 1
Joined: Thu Dec 12, 2013 2:12 am

Re: Bubble Sort Linked List

Postby micseydel » Thu Dec 12, 2013 6:05 am

You should read this. We need to see your indentation.
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot] and 13 guests