Open main menu

CDOT Wiki β

Changes

Weekly Schedule 20121 - OOP344

416 bytes added, 05:32, 4 March 2012
Help
*:I was asking the same question in today's class... just want to get clear about adding a Node. On your example, you wrote, that removing a Node is happenning from _head of the linked list... which is after data3 on my above example... right, then why we are adding a Node from tail (ie. between data1 and NULL) of the linked list...?? if the adding on tail is right then, why we are removing from other side i mean.. head??? both process suppose to happen from same place... right? If we get this type of question on test or exam, it will definetly cofuse me. Please correct me if I understand wrongly. Thanks! If the adding is happenning on head, here is my code...--[[User:Tvirutthasalam|Tvirutthasalam]] 19:08, 23 February 2012 (EST)
*:* got the answer from Chris' notes. Actually, a queue operates on a first in, first out principle (FIFO). It means, adding haPpen on tail and remove happen on head... My bad.
*:* For a Stack addition and removal of nodes occurs only at the head. But for a simple linked-list addition of nodes occurs at the tail of the linked-list(as Fardad always gives an example of a queue at the Tim-Hortons where customers are removed from the queue from the head and are added at the back of the queue). But for a double linked-list, addition and removal of nodes can occur from anywhere in the queue.
=== Resources ===
1
edit