c question

Leinier Cruz Salfran salfrancl.listas at gmail.com
Fri Apr 9 17:41:36 UTC 2010


On Fri, Apr 9, 2010 at 10:52 AM, Alexander Churanov
<alexanderchuranov at gmail.com> wrote:
> 2010/4/9 Leinier Cruz Salfran <salfrancl.listas at gmail.com>
>>
>> - use a matrix is faster than use a linked list?
>>
>> example:
>>
>> char *szColumnName[10];
>> unsigned short iColumnAge[10];
>>
>>
>> struct _llList {
>>  struct _llList *prev, *next;
>>  char szName[64];
>>  unsigned short iAge;
>>  };
>
>
> Leinier ,
> This depends on what kind of operations are performed. For sequential
> traversing, both are very appropriate. However, you can not perform a binary
> search on a list. You also can not combine two arrays into a single one with
> constant complexity.
> Lists also have greater memory overhead for small structures.
> My advice: always use arrays.
> Use lists if:
> 1) Copying items when the dynamic arrays grows is inappropriate.
> 2) List-specific operations like O(1) splicing or O(1) insertions and
> deletions are required.
> Alexander Churanov
>

hello alexander

i supposed that a matrix is much faster .. i coded my program to use
matrix in that portion but i sent the question to see what others
think about this

thanks


More information about the freebsd-hackers mailing list