I have to read from a file an unknown number of rows and save them in to a structure (I would like to avoid a prepocessing to count the total number of elements). After the reading phase I have to make some computations on each of the elements of these rows.
I figured out two ways:
Use
realloc
each time I read a row. This way the allocation phase is slow but the computation phase is easier thanks to the index access.Use a linked list each time I read a row. This way the allocation phase is faster but the computation phase is slower.
What is better from a complexity point of view?