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.
Join the #python-forum IRC channel on irc.freenode.net for off-topic chat!

Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from :)
User avatar
Posts: 2118
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot], mudradi.mohan and 5 guests