Thursday, July 30, 2009

How to write a code to remove a row from the array in C language?

About the best you can do, if it has to be an array, is to move each later row back one entry.





Arrays have lousy performance for removing entries for this reason, and another data structure may be a better choice if this will be a common operation in your application.





Possibly better options, depending on the details are things like:


Linked lists.


B-Trees (or a variant like R/B trees, depending on data ordering).


Skip lists.





All are in the literature.





HTH.





Regards, Dan.

How to write a code to remove a row from the array in C language?
Well it all depends on how the array is stored. If it is a plain 2d array with syntax [][] then it is very cubersome an the best way is to move the contents around to the upper row.


basically from the row to delete and last but one row move the next row's data in the row above.


If it is in a linked list then you might have to rearrange the pointers to achieve this.


No comments:

Post a Comment