In this tutorial, we are going to discuss clearly the Introduction to Data Structures with Advantages, Limitations of Arrays, and in further series of Data Structures deep explanation of every topic will be done. So, as a small suggestion from my side, if you can follow this series you can gain in-depth knowledge of Data Structures quickly and easily. So, let’s get started!
Data Structures Definition
Data Structure name itself indicates that organizing the data in the memory. There are many different ways to organize data in the structure. For example, in C Language we have seen Arrays. Arrays are also a collection of elements i.e; a collection of memory locations. But in Arrays, as we know the structure of data is sequential. It occupies a contiguous memory location. So, it is the collection of elements in contiguous memory locations. Data is organized using the Arrays. Now the exact definition of Data Structures is organizing the data in the memory locations in different ways. There are two types of Data Structures:
As we all know primitive data types from C, so the Primitive data structure is the primitive data types. Non-Primitive Data types are divided into two types Linear and Non-Linear. Linear Data types mean which are sequential i.e; data is arranged in a sequential manner such as Arrays, Lists, Stacks, Queues. Non-Linear data types mean which are arranged in a random manner such as Trees and Graphs. From the knowledge of the C language, you will be familiar with Arrays. So, we will here learn depth about how the data is arranged in Lists, Stacks, Queues, Trees, and Graphs.
Major/Common Operations of Data Structures
- Searching: We can search the data in the data types by using the searching operation.
- Sorting: Can sort the data in the data types using Sorting operations.
- Insertion: We can insert the data in the data types by the insertion operation.
- Deletion: We can delete the data from the data types using deletion.
- Updation: Can replace one element with the other element.
So, we use these common operations in the data types.
As you will be already aware of Primitive Data types from C language. So, now let’s discuss about Arrays from Non-Primitive Data types.
Arrays mean a collection of elements that are of similar data types. We can store multiple elements under the same name. Here the memory is occupied in a contiguous memory location. There are different operations that can be performed by arrays such as
- Searching is of linear and binary
- Sorting is also linear and binary
These operations you will also learn in Arrays. So, I am not giving a detailed explanation here.
Advantages of using Arrays
- It consists of similar data type elements i.e; n number of elements that can be stored under a single data type.
- We can access any element in the arrays with the help of index values i.e; random access is possible.
- It is suitable when the number of elements is already known.
- This is used in the implementation of other data structures like stacks and queues but not the lists.
Limitations of using Arrays
- The major disadvantage of using Arrays is Static Memory allocation that is during the compile-time only we have to specify the size of the array.No possibility of changing the array during compile time. For example, if we initially initialize the array size as 10 i.e; like a we cannot increase it during run time if it is required to increase, and also if we initialize as a and uses only a size of 10, the other 90 gets wasted.
- Insertion and Deletion are expensive i.e; it involves more completion loops.
- Due to these disadvantages, we are not using arrays in lists and use linked list concept.
Hope that you are clear with Advantages and Disadvantages of Arrays and clear with Introduction to Data Structures. If you have any doubts, please feel free to comment below. Comment box is always open for you. In the next tutorial you will understand about Linked Lists.