How do I store linked list datas into an array?



How do I store linked list datas into an array? ..

Answer / mahesh

If you have the predetermined length of the number of nodes
in the linked list then you could have went for arrays
initialy only .

But still if you want to store the complete linked list
into an array i think dynamic arrays are best option.

Implementation : -
Loop through the linked list till enad and copy the data
members in the linked list except the NEXT or PREV pointers
into the array.

Is This Answer Correct ?    9 Yes 1 No

Post New Answer

More C++ Code Interview Questions

swap prog

3 Answers   TCS,


Write a simple encryption program using string function which apply the substitution method.

0 Answers  


write a program to sort 'n' elemnts using bubble sort

1 Answers   IBM,


1. Write a program using one dimensional array that calculates the sum and average of the five input values from the keyboard and prints the calculated sum and average.

2 Answers  


readers and writers problem

1 Answers   Cognizant,






Given 1 to n random number, find top 10 maximum numbers and explain the time complexity of the algorithm.

1 Answers   IMO, NetApp,


output for printf("printf");

0 Answers  


Faster Computers Suppose you have a computer that requires 1 minute to solve problem instances of size 1000. What instance sizes can be run in 1 minute if you buy a new computer that runs 1000 times faster than the old one, assuming the following time complexities T(n) for our algorithm? (a) T(n) = O(n). (b) T(n) = O(n3). (c) T(n) = O(10n).

1 Answers   Qatar University,


How can I Draw an ellipse in 3d space and color it by using graph3d?

0 Answers  


how to take time as input in the format (12:02:13) from user so that controls remains between these columns?

0 Answers  


3. Program to find the Sum of give series. a. (1)+(1+2)+(1+2+3)+(1+2+3+4)+……………………………….. b. 1/1+1/9+1/25+1/49+……………...

0 Answers  


program to find the magic square using array

1 Answers  


Categories