Doubly-linked list/Element definition: Difference between revisions
Content added Content deleted
(Started the double-linked list page, using single-linked list as model.) |
|||
Line 2: | Line 2: | ||
Define the data structure for a [[Linked List|doubly-linked list]] element. The element should include a data member to hold its value and pointers to both the next element in the list and the previous element in the list. The pointers should be mutable. |
Define the data structure for a [[Linked List|doubly-linked list]] element. The element should include a data member to hold its value and pointers to both the next element in the list and the previous element in the list. The pointers should be mutable. |
||
==[[Ada]]== |
|||
[[Category:Ada]] |
|||
type Link; |
|||
type Link_Access is access Link; |
|||
type Link is record |
|||
Next : Link_Access := null; |
|||
Prev : Link_Access := null; |
|||
Data : Integer; |
|||
end record; |
|||
==[[C]]== |
==[[C]]== |
Revision as of 04:24, 8 May 2007
Doubly-linked list/Element definition
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
Define the data structure for a doubly-linked list element. The element should include a data member to hold its value and pointers to both the next element in the list and the previous element in the list. The pointers should be mutable.
Ada
type Link; type Link_Access is access Link; type Link is record Next : Link_Access := null; Prev : Link_Access := null; Data : Integer; end record;
C
struct link { struct * link next; struct * link prev; int data; };