Learn Data Structures From Scratch: 9 Complete Quick Facts

In this tutorial, we will discuss about data structures from the basics. We will understand the different types of data structures and their uses and how we can implement them.

What is data structure?

A data structure is a collection of data that can be stored in an organised manner so that the data can be accessed, modified efficiently.

Data Structures usages

  1. Data structures are used in different kinds of applications like relational databases, which use B-tree indexes to retrieve the data.
  2. Hash table is used in compiler design.
  3. These are used in different algorithms like searching, sorting.
  4. Internet indexing service uses data structures.

Types of the Data structures

Types of DSSub type
LinearArray
Linked List
Stack
Queue
TreeBinary Tree
Binary Search Tree
Heap
HashingHash Table
Hash Tree
GraphDecision Graph
Directed graph
Matrix

What is Linear data structure ?

A linear data structure is a type of data structure where data can be traversed sequentially. Array, Linked list, stack, queue are examples of linear data structure. Please go through below image for the details:

Linear data structures
Linear data structures

What is Tree Data Structure

A tree data structure is a hierarchical data structure. It has nodes that are connected by edges.Please go through below image for the details:

image1
Example of tree

What is hashing

Hashing is a data structure which uses a hash function to map the data in a key-value pair to retrieve the data faster. Examples of Hashing are Hash table, Hash tree. Please go through below image for the details:

image4
Example of Hashing

What is graph

A Graph is a non-linear, pictorial representation of data consisting of edges and vertices. Please go through below image for the details:

image5
example of graph

Difference between linear and non-linear data structure

Sl NoKey pointsLinear data structureNon-linear data structure
1Data alignmentData gets stored  sequentially Data gets stored in hierarchy form
2LevelsSingle level involvedMultiple level involved
3ComplexityEasy to implementImplementation is complex
4TraversalData can be traversed in single runData cannot be traversed in a single run rather need multiple runs
5Utilisation of memoryNot efficientEfficient
6ExamplesArray, Linked list, stack, queueGraph, tree
7ApplicationUsed in software developmentUsed in Image Processing, Voice Processing, Artificial Intelligence 
image3
DS flowchart

Some import Questions and Answers on Data Structure

Qn 1. What do you mean by ADT in Data structure?

Ans: ADT means Abstract Data type. Class or Objects are an example of ADT. When We use and Class or Object, we define the behavior by a set of values and a set of operations. ADT only tells us what operation has to perform. It does not tell us how the operation has been internally implemented.

For Example :

  • List
    • size() -> Size gives us the number of elements, but it does not show how internally it calculates to give the result.
    • insert(x) -> insert helps us to insert the element but does not tell how the logic is written.
    • remove(x) -> Similarly remove method is used to remove the elements without telling the implementation.
    • get(i) -> get is used to access the elements.

Qn 2. What are the advantages of data structure?

  1. Ans:
  2. Using Data Structure, we can efficiently store data in a storage device.
  3. Data structure gives an easy option to retrieve the data from a storage device.
  4. It can process small as well as large numbers of data efficiently
  5. Using data structures like graph we can solve real-life problems
  6. Database systems uses indexing using a hash table and array to retrieve the data efficiently.

Qn 3. What is primitive data structure?

Ans: Primitive data structures are system-defined data types supported by different programming languages. Example: int, double, float, boolean, character.

Qn 4. What is a Complex Data structure?

Ans: Data structures like Hash table, Tree, Heap, Graph are called a complex data structure. The implementation of these data structures is complex in nature.

Qn 5. What are the two main types of data structure?

Ans: Mainly, data structures are divided into two parts:

  1. Linear Data structure: Stack, Queue, Array, Linked List
  2. Non-linear Data Structure: Tree, Graph

Conclusion

Till now, We have covered the basics of Data Structure. In the next topic, we will write about the Array. For more details for this section, please refer to this link.