(855) 4-ESSAYS

Type a new keyword(s) and press Enter to search

C++ Algorithms


            Both methods of implementation have their associated strengths and weaknesses. In the first approach, the method of implementation uses an array of structs to hold the information of the cars. The problem with doing this is that an array's size is fixed at compile time. In this case the array size is specified to be 500. If the program doesn't use all 500 spaces, then the memory allocated at compile time is wasted. Also, since the size is fixed, no other cars can be added once the 500 have been used. One major advantage the array has over the linked list, (the approach used in the other method of implementation) is that searching and sorting algorithm complexity is considerably reduced. .
             Linked lists, as used in the second method of implementation, allocate elements one at a time as needed. This method uses memory a lot more efficiently than arrays, in that memory is dynamically allocated, so that you don't have to worry about wasting memory or going over the limit (in this case 500). Searching and sorting algorithms are generally more complex than that of the arrays because elements are in random places in memory unlike the array in which the memory location of each element is sequentially indexed. .
             Since the objective of this assignment is to select the "best" method of implementation, we first have to understand what "best" means. From a performance standpoint, the array implementation would be the best option due to the reduced complexity in the searching and sorting algorithms over the linked list implementation. In respect to memory allocation, the linked list does a far better job at using memory efficiently. With all things considered, I think that "best" means "what is the method of implementation that is most likely to be used in the real world." Considering that today, memory and processing power are relatively cheap, memory use efficiency and performance do not play that heavy of a role in this type of problem.


Essays Related to C++ Algorithms


Got a writing question? Ask our professional writer!
Submit My Question