Operations linked lists

0
  • I'm with the subject of linked lists. Especially with the list simply linked. I have seen the typical operations that can be done with this type of structure: add by the beginning, by the end, eliminate nodes, display the list, search for elements etc. However, do things like adding at the beginning of the list in a simply linked list would we really be talking about a simply linked list or another type of list like the double linked ones?

    In a list simply linked each node points to the next and the last point to NULL so the only operation that could be done to add elements would be to insert at the end of the list or not? since if I add by the beginning we would no longer be talking about a list simply linked.

  • On the other hand, what operations can be carried out with a circular list that is simply linked that can not be done with a simply linked list?

    Thanks in advance

  • asked by ivan5 21.06.2018 в 19:12
    source

    1 answer

    1

    1) Although you can add nodes at the beginning of a list, it will still be a simply linked list (LSE). ¿Pq? By its own definition: " a simply linked list is one in which each node has a pointer to the next node, except the last node, which is NULL ".

    What you say about operations at the beginning or end of non-circular lists is used to help or facilitate certain operations. In fact, you could implement more auxiliary nodes if you need it. Imagine that you are implementing a dictionary of thousands of people (records sorted alphabetically). If you want to insert a new node in the LSE it will be easier to consult the letter, for example, "S", and find its correct position from that node instead of having to go through all the previous ones.

    2) In a simply linked circular list (LCSE) you can perform the same operations, since the only pointer that is usually referenced is the last one, that way we can insert a new end node or even if we advance to the next node. last, we would be in the first, and we could insert at the beginning of the list (circular).

    If something has not been clear, leave your question in the comments.

        
    answered by 21.06.2018 в 19:28