answersLogoWhite

0

every monday to saturday mag jakol ka pohta sarap nun

User Avatar

Wiki User

12y ago

What else can I help you with?

Continue Learning about Engineering

How do you overcome the disadvantages of arrays?

There are many limitations of arrays. The greatest advantage of an array of course is performance. Arrays are by far the fastest means of referencing collection of items. That said, arrays suffer incredible limitations since they are generally very slow for adding items in a sorted manor. Unless you preallocate a large enough area of memory to store all possible items you wish to use, arrays have to be reallocated over and over. There are some hackish functions which can be used to exploit the MMU of the system to grow arrays by creating multiple logical contiguous regions of memory, but if this is performed on a fine grain, the logical descriptor tables of the system will grow and overall system performance will be negatively impacted. Even though you appear to want to program plain-C, there is no reason you can't develop in an object oriented manor. There are many libraries available for C which provide high-performance variable length collections. I am not familiar with all of them, but as part of the GNOME toolkit, there is GLib (if I recall) which provides excellent implementations of many of them. Alternatively, if you're interested in learning how they work in order to correctly choose the right one for each task, you may want to get a copy of Donald Knuth's "The Art of Computer Programming, Volume 1" which is effectively a bible of sorts on this specific topic and is quite easy to read. If you want to learn the ABCs and 123s without an overly prolonged investment in time, I recommend experimenting with an object oriented language with good class libraries like Java or my favorite, C#. They are both great starting points for experimenting with data structures.