The Need for Efficiency
Understand the importance of efficiency in data structures by analyzing the impact of naive implementations on performance with large data sets. Learn why organizing data cleverly leads to significant improvements in operation times, enabling faster searches and scalable applications.
We'll cover the following...
The operations supported by the most commonly used data structures are not hard to implement correctly. We can store the data in an array or a linked list. Each operation can be implemented by iterating over all the elements of the array or list and possibly adding or removing an element.
This kind of implementation is easy but not very efficient. Does this really matter? Computers are becoming faster and faster. Maybe the obvious implementation is good enough. Let’s do some rough calculations to find out.
Number of operations
Imagine an application with a moderately-sized data set, say of one million items. In most applications, it is reasonable to assume that the application will want to look up each item at least once. This means we can expect to do at least one million () searches in this data. If each of these searches inspects each of the ...