You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am starting to get in touch with linked lists and other data structures types,
A part ";" errors I found in the code, the problem is in the newlist [type List] there will be references of objects "nodes" of previous linked lists and not the "data", so I propose to you to use get_data() function when appending data to the temporary list instead of node object references which will simplify the code as below:
def sort_list(self, reverse_list = True):
if self.size > 1:
temp_list = []
current = self.root
temp_list.append(current.get_data())
while current.has_next_node():
current = current.get_next()
temp_list.append(current.get_data())
temp_list = sorted(temp_list, reverse = reverse_list)
sorted_Linked_List = LinkedList()
for element in temp_list:
sorted_Linked_List.add_node(element)
return sorted_Linked_List
return self
The text was updated successfully, but these errors were encountered:
Hi,
I am starting to get in touch with linked lists and other data structures types,
A part ";" errors I found in the code, the problem is in the newlist [type List] there will be references of objects "nodes" of previous linked lists and not the "data", so I propose to you to use get_data() function when appending data to the temporary list instead of node object references which will simplify the code as below:
def sort_list(self, reverse_list = True):
if self.size > 1:
temp_list = []
current = self.root
The text was updated successfully, but these errors were encountered: