Data Structure and Algorithms – Deep Dive In

First we will look into few topics to understand basics of DataStructure

  • What is Data Structure?
  • Why do we need Data Structure?

Let’s start with first Question “What is Data Structure?

Data Structures are the programmatic way of storing data so that data can be used efficiently.

Data structures are the way we are able to store and retrieve data.

It is very similar to real-world systems that we use outside of the programming.

Imagine that you go to the grocery store. Most grocery stores have a clear order to the way the store is stocked and laid out. Similarly, data structures provide us with a way to organize information (including other data structures!) in a digital space.

Now we will discuss “Why do we need Data Structure?

As applications are getting complex and data rich, there are three common problems that applications face now-a-days.

  • Data Search − Consider an inventory of 1 million products of a store as Data. To find a single product, it has to search through million of products every time to get that specific product. As data grows, search will become slower.
  • Processor speed − Processor speed although being very high, falls limited if the data grows to billion records.
  • Multiple requests − As thousands of users can search data simultaneously on a web server, even the fast server fails while searching the data.

To solve these problems, data structures come to rescue. Data can be organized in a data structure in such a way that all items may not be required to be searched, and the required data can be searched almost instantly.

Here is the list of different data structures which we can use in our applications.

  • String
  • Array
  • Linked List
  • Stack
  • Queue
  • Binary Tree
  • Binary Search Tree
  • Heap
  • Hashing
  • Graph
  • Matrix
  • Trie:

Now it is important to know which data structure you should use for your application.

To determine that you need to assess following questions.

  • What is the intended purpose for the data?
  • Do any data structures have built-in functionality that is ideally suited for this purpose?
  • Do you want to search, sort, or iterate data in a way in which certain data structures would be better suited than others?
  • Do you want or need control over how memory is set aside to store your data?
  • How long will it take different data structures to accomplish various tasks relative to other data structures?
Data Structure as per Data Types

You can also select data structure as per Data types in your Application.

Algorithm:

Algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a certain order to get the desired output.

Here are the different operations like search, sort etc., where you can use appropriate algorithm as below.

  • Search − Algorithm to search an item in a data structure.
  • Sort − Algorithm to sort items in a certain order.
  • Insert − Algorithm to insert item in a data structure.
  • Update − Algorithm to update an existing item in a data structure.
  • Delete − Algorithm to delete an existing item from a data structure.

Here are the list of different algorithms you can use as per data structures and data types

  • Breadth First Search
  • Depth First Search
  • Binary Search
  • Merge Sort
  • Quick Sort
  • Tree Insert / Find / etc