Zia ur Rahman
Zia ur Rahman

Reputation: 1431

Selection of an inefficient data structure, what problems it can create for us?

Suppose i have a software program which uses an inefficient data structure. Now how can i make it efficient. it seems that we should simply change the data structure but its not the case in reality. according to my point of view the whole software needs to be changed. what is your point of view?

Upvotes: 1

Views: 416

Answers (3)

mcdowella
mcdowella

Reputation: 19601

You need at least to know what will be cheap and what expensive with good algorithms. When Java was just out I saw somebody produce a Collections framework. They didn't know much about data-structures, and it was very inefficient. I mailed them and they said "Oh - I knew about that. Now that I have attracted people's interest to this problem, somebody else can make it work fast." But they had chosen operations for which there were no good (log n) implementation, and they hadn't provided operations which can be implemented efficiently and which would have been useful in that environment (I think I remember merging priority queues).

So there was no good way to take a program written with their unfortunate Collections framework and speed it up just by fixing the implementation of the framework.

Upvotes: 1

Pascal MARTIN
Pascal MARTIN

Reputation: 401012

The question might be a bit too vague for us to give a precise answer, but using an "inefficient" data structure can mean :

  • it'll take more time / more CPU to access data (be it for insertions/reads/deletions)
    • which might lead to performance problems ; i.e. a slow application
    • and time is money
  • it might take more time to write code that access that data structure
    • and developer's time costs money too


Should the whole application be changed, or should it be corrected to use the "right" data structure ?

Well :

  • How much would it cost to change data structure ?
  • And how much would it cost to change the whole application ?
    • Including the time required to migrate data, explain users how to use the new application, ...

Upvotes: 3

Adriaan Stander
Adriaan Stander

Reputation: 166396

This is very subjective and should probably marked be as such.

It would widely depend on which language you use, how big of a part this data structure plays in the application, how flexible the original code was written to allow for structure changes, and the actual type of the data structure.

In the most part, If your application was written correctly, you should easily be able to change, but you do find instances where the design would not allow for easy change, and a harder solution is the only at hand.

Upvotes: 1

Related Questions