PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: [Cs223] Penalty for not ordering the triples
Date: Thursday, 16 Apr 2020, 07:43:03


    > Message Posted By: Unknown
    ...
    > I am just wondering what's the penalty be for not ordering the triples in
    > the secondary array by their positions? I understand it will slow down the
    > search. Will the program fail many of the private tests because of slow
    > time due to long searches>

The use of ordered arrays will be checked by looking at
the code, with the deduction being 2-3 points.
=====

    > If I am using a 2D array, just an array of triple array, I am not sure how
    > to efficiently moving struct triples? I can think of creating a new empty
    > triple array and copying the triples in, but that seems really slow.
    >
    > Any suggestions?

You can move a struct triple from one location to
another using a single assignment statement (versus
an assignment for each field).  See K&R, Chapter 6.

You have to realloc() the storage to accommodate the new
element, which will require copying all of the elements
unless the block of storage can be extended in place.
Thus "really slow" is not applicable.

--Stan-
PREV INDEX NEXT