This week we learned about linked lists, another Abstract Data Type .
A Linked list is a data structure where nodes are linked together. Each of these nodes holds data and has a reference to at least it's tail/next. Each node has a reference to its next but not its previous one. So trying to find out what is before that node would be impossible unless we introduce something called a doubly linked list. In a doubly linked list a node has a reference to its head/front and tail/back so it would be easy to iterate through a linked list no matter where you were.
Another interesting point that was brought up was how do you know which head is the actual head of a linked list where the nodes are linked into a circle.
The answer is there is no way because you would just be linked into a continuous circle.
The way you would do this is create a class node and a class linked list that takes in nodes as a container and have each node an attribute to its head if its singly linked and if its doubly linked an extra attribute linking to its tail.
This was after writing the midterm. I think the midterm was fair, even though if we were given 10 more minutes it would've helped a lot.

No comments:
Post a Comment