Post 6
This week we learned about Linked lists, which at first didn't seem useful. It seemed to be easier to just have a regular list. However, some of the problems in the lab made it clear that LinkedLists could be useful. For example, if you want to store an object in a specific place in the list and preserve the order, then you could not use a list. Also, if you wanted want to store the sum of two adjacent numbers in a list the in position of the first number, then you would need a LinkedList. The problems were quite tricky because the the sequence of LLNodes were stored in wrapper method called LinkedList. This was confusing since you had to be careful to make sure that each node pointed to the next correct node because the only thing stored in LinkedList was the start, the end and the size which meant the information of the nodes in the middle was inaccessible directly and you had to traverse through each node to find the one you were looking for. Sometimes you would want to change a Node before a certain node you were looking for, in which case you would traverse through the list using two variables, with one lagging behind the other. Once the first variable found the correct Node, the second one could alter the value of the previous node.
No comments:
Post a Comment