Home Theory When to use which data structure?

When to use which data structure?

by nikoo28
0 comments 1 minutes read

We have discussed some very basic data structures. Sometimes, we need to decide which data structure to use at which place. Although is there is no hard and fast rule of using a data structure in a specific scenario, the below guidelines can help for general cases.
For our program to be very efficient we must be aware of the sample data, our code needs to handle and a data structure should be used accordingly.

Ordered Array :- If amount of data is small and predictable and search speed is more important than insertion speed.

Linked List:- If amount of data is small but not predictable and insertion speed is more important than search speed.

Hash Table:- If amount of data is not small. And both search & insertion speed must be very fast.

Binary Tree:- if amount of data is not small and search and insertion should be optimal not very fast but not very slow at the same time.

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More