Growing Arrays in CArraysWhat are Growing Arrays?Comparisons to C++/JavaStructWhy Grow Arrays?Why not use Growing Arrays?Benefits of Growing ArraysDrawbacks of Growing ArraysDeleting a NameQuestions???Robert ShieldsArraysAn array is basically a variable that contains a listArrays are one of the simplest data structures in CThey have many uses and a broad range of tools associated with themWhat are Growing Arrays?Growing Arrays are arrays that are constantly having new sorted values added to themThey are used in situations where we need to keep track of a variableOften overshadowed by hash tables due to the amount of resources needed for large arraysComparisons to C++/JavaIn C++ or Java, Growing Arrays would be replaced by classes from standard librariesIn C, these Growing Arrays are constructed using a structstruct { char cname[8]; char sname[16];char exam[16]; char grade; } record;StructA struct is used to declare a new data typeThis basically means grouping variables togetherSimilar to enum in C++Why Grow Arrays?Growing arrays is usually a resource hungry operationUsed when elements added (n) is relatively smallVery convenient data structureFixed size data sets, arrays idealWhy not use Growing Arrays?Changing set of values in arrays can be expensiveNumber of elements unpredictableNumber of elements potentially largenBenefits of Growing ArraysArrays are simplest way to group dataMost languages have efficient and convenient tools for arraysArrays work well with sorting algorithmsProvide easy access to any itemDrawbacks of Growing ArraysCannot handle large amounts of data changeRequires resorting of entire array upon deletion of elementsElements can sometimes be overwritten by fast “squeezing” algorithmsMust decide on correctness or speedDeleting a NameDeleting a name in an array is trickyDeleting the name results in a gap in the arrayEasiest solution is to swap last element into the gapMore complicated if order
View Full Document