answersLogoWhite

0


Best Answer

Like this:

#define MAXLIST 100

int first, next [MAXLIST];

/* let the list be: #0 ---> #2 ---> #1 */

first= 0;

next[0]= 2;

next[2]= 1;

next[1]= -1; /* means end of list */

Note: you should track which elements are unused,

in the beginning every elements are unused:

int first_unused= 0;

for (i= 0; i<MAXLIST; ++i) next[i]= i+1;

next[MAXLIST-1]= -1; /* means end of list */

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

I was under the impression an array and double linked list where two different ways one could implement a specific abstract data types.

Why would you need to make a doubly linked list using an array? The elements in an array already are sequential in nature (therefore indicating their successor and predecessor with no coding required) and you can instantly access any index in the array with the array's predefined methods.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

yes it is possible

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Two linked list in a array is possible?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the Data structures used for stack?

A stack is a linear last-in first-out list type data structure. Several implementations are possible. Two examples are the array and the linked list. The array is quick, but is limited in size. The linked list requires overhead to allocate, link, unlink, and deallocate, but (except for total available memory) is not limited in size. One compromise might be a linked list of arrays. Another compromise might be to not necessarily unlink and delete when an element is popped off the stack.


Which one is the two way linked list a Circular link list b Node having header and trailer in the list C Array?

b Node having header and trailer in the list


Advantage of linked list over array?

The only real advantage a linked list has over an array is that it can grow much more efficiently, however this is only guaranteed when new elements are inserted at the head or the tail of the list where you have constant time access. Constant time random access is not possible, thus insertions within the body of the list may be slower than for an array because of the need to traverse to the insertion point. However an array must reallocate in order to make room for new elements which may result in the entire array being moved to new memory. This can be minimised by reserving memory in advance. But, more importantly, all elements from the insertion point must be moved forward in the array in order to make a gap for new elements. Thus inserting into an array can often be slower than for a list, particularly if the elements do not support move semantics (they must be copied instead). If you plan on performing many such insertions, then a list will probably be quicker overall because there is no need to move elements around in memory. However, if you require random access and compact storage, use an array instead and reserve as many elements as you require for your insertions.


What are the merits and demerits of array based implementation over linked implementation?

The merits of an array are that it provides the most compact storage mechanism of any data container, and enables constant-time, random access to that data. The demerits are that insertions and extractions can be costly in terms of performance due to the need to copy/move elements within the array. For large arrays, the cost can become prohibitive. Also, arrays can only be used to store elements of the same type.


What is difference between linked list and singly linked list?

Answersingly linked list has the node inserted only at one end. and the pointer corresponds to the next pointer.but in a doubly linked list, the node pointer points to the both previous and the next node.singly linked list has two nodesdoubly linked list has three nodesA doubly linked list makes sense when you need to traverse the list in both directions. You aren't able to do that with a singly linked list.

Related questions

What are the the two ways in representing the stack?

one-dimensional array, and doubly-linked list.


What is the Data structures used for stack?

A stack is a linear last-in first-out list type data structure. Several implementations are possible. Two examples are the array and the linked list. The array is quick, but is limited in size. The linked list requires overhead to allocate, link, unlink, and deallocate, but (except for total available memory) is not limited in size. One compromise might be a linked list of arrays. Another compromise might be to not necessarily unlink and delete when an element is popped off the stack.


Which one is the two way linked list a Circular link list b Node having header and trailer in the list C Array?

b Node having header and trailer in the list


Advantage of linked list over array?

The only real advantage a linked list has over an array is that it can grow much more efficiently, however this is only guaranteed when new elements are inserted at the head or the tail of the list where you have constant time access. Constant time random access is not possible, thus insertions within the body of the list may be slower than for an array because of the need to traverse to the insertion point. However an array must reallocate in order to make room for new elements which may result in the entire array being moved to new memory. This can be minimised by reserving memory in advance. But, more importantly, all elements from the insertion point must be moved forward in the array in order to make a gap for new elements. Thus inserting into an array can often be slower than for a list, particularly if the elements do not support move semantics (they must be copied instead). If you plan on performing many such insertions, then a list will probably be quicker overall because there is no need to move elements around in memory. However, if you require random access and compact storage, use an array instead and reserve as many elements as you require for your insertions.


What are the disadvantageds of linked lists?

ConsAll nodes in a linked list are sequential. To retrieve the Nth element, you must traverse N-1 nodes (for a singly linked list). In other words, O(N).There are better structures that are faster - balanced binary search trees O(log N).Side Remark:But if you always do work on the first node or top node, a linked list will work quite well. But at that point, it's not called a linked list anymore. It would be called a stack or a queue.


What are the merits and demerits of array based implementation over linked implementation?

The merits of an array are that it provides the most compact storage mechanism of any data container, and enables constant-time, random access to that data. The demerits are that insertions and extractions can be costly in terms of performance due to the need to copy/move elements within the array. For large arrays, the cost can become prohibitive. Also, arrays can only be used to store elements of the same type.


What is difference between linked list and singly linked list?

Answersingly linked list has the node inserted only at one end. and the pointer corresponds to the next pointer.but in a doubly linked list, the node pointer points to the both previous and the next node.singly linked list has two nodesdoubly linked list has three nodesA doubly linked list makes sense when you need to traverse the list in both directions. You aren't able to do that with a singly linked list.


How do you initialise a two dimentional array?

C provides rectangular multidimensional arrays. In C, a two-dimensional array is really a one-dimensional array, each of whose elements is an array. An array is initialized by a list of initializations in braces; each row of a two-dimensional array is initialized by a corresponding sub-list. Example of two dimensional array initialization: char array_example[2][4] = { {11, 12, 13, 14}, {21, 22, 23, 24} };


What is the difference between doubly linked list and circular linked list?

A doubly linked list allows traversal in both directions (forward and backward) by having each node point to both its next and previous nodes. A circular linked list is a type of linked list where the last node points back to the first node, forming a circular structure. This allows continuous traversal through the elements without a definitive end.


Advantage and disadvantage of linked list?

Linked list is a dynamic data structure that contains a "link" to the structure containing the next item. It is a collection of structures ordered not by their physical placement in memory (like array) but by logical links that are stored as part of the data in the structure itself.Advantages of Linked Lists- Dynamic structure (Mem. Allocated at run-time).- We can have more than one datatype.- Re-arrange of linked list is easy (Insertion-Deletion).- It doesn't waste memory.Disadvantages of Linked Lists- In linked list, if we want to access any node it is difficult.- It is occupying more memory.


How do you get the mean median and mode in c programming?

By writing in C code the mathematical methods for finding the mean, median and mode of your data taking into account how your data is stored (eg an array; two separate arrays one with data and the other with frequencies; a two dimensional array containing both data and frequencies; an array of structures containing the data instead of arrays; a linked list of structures; etc).


What are the advantages of linked list over arrays?

# Linked lists do not need contiguous blocks of memory; extremely large data sets stored in an array might not be able to fit in memory. # Linked list storage does not need to be preallocated (again, due to arrays needing contiguous memory blocks). # Inserting or removing an element into a linked list requires one data update, inserting or removing an element into an array requires n (all elements after the modified index need to be shifted).