c - Realloc Vs Linked List Scanning -
i have read file unknown number of rows , save them in structure (i avoid prepocessing count total number of elements). after reading phase have make computations on each of elements of these rows.
i figured out 2 ways:
use
realloc
each time read row. way allocation phase slow computation phase easier index access.use linked list each time read row. way allocation phase faster computation phase slower.
what better complexity point of view?
how traverse linked list? if it's once go linked-list. few things: vill there lot of small allocations? make few smaller buffers let's 10 lines , link togeteher. that's question of profiling.
i'd simplest thing first , see if fits needs i'd think optimizing.
sometimes 1 wastes time thinking optimum when second best solution fits needs perfectly.
Comments
Post a Comment