in reply to Data structure efficiency
Just give us your professor's email address so we can send our answers directly to him. Why should you have to be involved in the process at all if someone else can do it for you? Your last post seemed a lot like homework too. A coincidence maybe, but although the questions you've posted above seem like homework type questions, it's hard to believe any teacher would be asking them without providing better context and clarification. Here's why:
Efficiency can take on many forms; computational efficiency, coding/programming efficiency, maintenance efficiency, memory efficiency, just to name a few. And even computational efficiency (speed) is difficult to define without knowing the application you're trying to implement. So question 1 is so vague that it could be answered many different ways, and could be interpreted a lot of ways. It needs to refine its criteria before an intelligent and meaningful answer can be given. That's one of the things that used to really frustrate me when I was in college; professors who posed test questions that could reasonably be interpreted several ways. Occasionally they sought a specific answer based on an interpretation that they failed to clarify.
Question 2 is still too vague, and at the same time too inclusive. You want to know all the cases where an array is more efficient? You want to know all the cases where a hash is more efficient? Assuming we actually know what type of efficiency you're requesting, we still will be here all month enumerating the situations. And that's assuming you can tell us what type of efficiency you're in need of, and how you're applying the use of these datastructures.
Question three is just goofy. I can only assume that you're talking about turning key/value pairs into co-elements of anonymous arrays indexed by a parent array. You want to know all the situations where that will fail? It will fail in any situation where a hash is the right tool for the job, and an array is not. Do you need an enumeration of all those situations? We'll be here awhile.
Let me recommend a good source of information on efficiency, on hashes, and that sort of thing: The O'Reilly & Associates book Mastering Algorithms with Perl. I found that to be an excellent book. It goes into just the right amount of detail explaining how hashes work, and where they might be useful. And its discussion of efficiency (including an introduction to Big-O notation) was also well written.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |