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:

  1. use realloc each time read row. way allocation phase slow computation phase easier index access.

  2. 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

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -