About 331,000 results
Open links in new tab
  1. How can I use a Linked List in Python? - Stack Overflow

    Mar 3, 2017 · @MadPhysicist "It [deque] behaves like a linked list in almost every way, even if the name is different." — it is either wrong or meaningless: it is wrong because linked lists may provide different guarantees for time complexities e.g., you can remove an element (known position) from a linked list in O(1) while deque doesn't promise it (it is O(n)).

  2. Python - Linked List - Append - Stack Overflow

    Oct 16, 2017 · I'm trying to learn Linked Lists in python I've been given Linked List class and asked to create append method. Here is the code provided. class Node: def __init__(self, item, next): ...

  3. python - Converting a list to a linked list - Stack Overflow

    Jul 22, 2015 · I'm trying to figure out to convert a list to a linked list. I already have a class for the link but I'm trying to figure out how to convert a list to linked list, for example: def list_to_link(lst): """Takes a Python list and returns a Link with the same elements.

  4. Python Reverse a Linked List - Stack Overflow

    Oct 21, 2015 · I was thinking maybe I could use temporary values so I can someone append the beginning of the stack to a list and then somehow convert it back into a stack object. Edit for duplication: The goal of my program is use an existing Stack and reverse it. The linked post deals with a linked list that was already in a list format.

  5. Reversing a linked list in python - Stack Overflow

    @Ramya My point is: we cannot help you if you are using a library we don't know about. We can write pseudocode showing you how to do it, but that's all around in the Internet and textbooks, and if this is homework (and looks 100% like it), you should show at least a piece of code where you try this first, and then we may correct it -as a general …

  6. data structures - Sorted Linked List in Python - Stack Overflow

    May 10, 2016 · Current Code #!/usr/bin/env python class node: def __init__(self): self.data = None # contains the data self.next = None # contains the reference to the next node class linked_list: def __init__(self): self.cur_node = None def add_node(self, data): new_node = node() # create a new node new_node.data = data new_node.next = self.cur_node # link ...

  7. Python Linked List Queue - Stack Overflow

    Mar 24, 2014 · First thing that jumps out at me is when you enqueue you need to increment the length of the list. size() should just need to return the length of the list once you've done that. And then to access the first item of the list you appear to be trying to use list syntax which your list does not support (at least in the code I can see).

  8. Linked List in Python- Append, Index, Insert, and Pop functions.

    Mar 9, 2014 · This assignment asks us to implement the append, insert, index and pop methods for an unordered linked-list. (What I have so far) def main(): class Node: def __init__(self, data):

  9. arrays - How is Python's List Implemented? - Stack Overflow

    A list in Python is something like an array, where you can store multiple values. List is mutable that means you can change it. The more important thing you should know, when we create a list, Python automatically creates a reference_id for that list variable. If you change it by assigning others variable the main list will be change.

  10. python - Removing a node from a linked list - Stack Overflow

    Jan 11, 2011 · # Creating a class node where the value and pointer is stored # initialize the id and name parameter so it can be passed as Node(id, name) class Node: def __init__(self, id, name): # modify this class to take both id and name self.id = id self.name = name self.next = None # Create a class linkedlist to store the value in a node class LinkedList ...

Refresh