Types of Data Structures
General categorization of Data Structures
Data structures are generally categorized into two classes
- Primitive data structures
- Non-primitive data structures
Primitive data structures are the fundamental data types that are supported by a programming language. Examples will make it crystal clear that is an integer, float, Boolean, etc.
Non-primitive data structures are those data structures that are created using primitive data structures. Examples are those we are going to learn in-depth such as stacks, queues, linked lists, etc.
But the non-primitive data structures can further be classified into two categories:
- Linear data structures
- Non-linear data structure
- Linear Data Structure: If the elements of a data structure are stored or arranged in a linear or sequential order, then it is a linear data structure.
Examples are arrays, linked lists, stacks, and queues.
Features of linear data structure
- Can be represented in memory in two different ways.
- One way is to have a linear relationship between elements using sequential memory locations.
- The other way is to have a linear relationship between elements through links.
2. Non–Linear Data Structure: If the elements of a data structure are not stored in sequential order, then it is a non-linear data structure.
Examples include trees and graphs.
Features of linear data structure
- The relationship of adjacency is not maintained between elements of a non-linear data structure.
STATIC AND DYNAMIC DATA STRUCTURES
Static Data Structure:- The size of the structure is fixed. The content of the data structure can be modified without changing the memory space allocated to it.
Advantages of the static data structure
- The size is fixed.
- Memory allocation before program execution.
- Stack is used.
- less efficient than a dynamic data structure.
- Overflow is not possible.
Dynamic Data Structure: The size of the structure is not fixed and can be modified during the operations performed on it. Dynamic data structures are designed to facilitate change of data structures in the run time.
Advantages of the dynamic data structure
- memory allocation is done during program execution
- Heap is used.
- more efficient than a static one.
- memory reuse
Before we start with STACK, QUEUE & LINKED LIST you should be familiar with some basic operations in data structures
OPERATIONS ON DATA STRUCTURES
- Traversing: It means accessing each data item exactly once so that it can be processed.
- Searching: It is used to find the location of one or more data items that satisfy the given constraint. Such a data item may or may not be present in the given collection of data items.
- Inserting: It is used to add new data items to the given list of data items.
- Deleting: It means to remove or delete a particular data item from the given collection of data items.
- Sorting: Data items can be arranged in some order like ascending order or descending order depending on the type of application.
- Merging: Lists of two sorted data items can be combined to form a single list of sorted data items.