Javatpoint Logo
Javatpoint Logo

Fundamental of the Data Structure

A data structure is a specialized format of data for arranging and storing data so that any user can easily access and worked within an appropriate data to run a program efficiently. Computer memory data can be organized logically or mathematically, and this process is known as a data structure. In general, selecting a particular format of data depends on two factors. The data must be rich enough to satisfy the real relationships of the data in the real world. And on the other hand, the data structure should be so simple that one can easily process the data when it needs to be used.

Characteristics of data structures

Following are the characteristics of the data structures as follows:

  1. Linear: A linear describes data characteristics whether the data items are arranged in sequential form like an array.
  2. Non-Linear: A Non-Linear data structure describes the characteristics of data items that are not in sequential form like a tree, graph.
  3. Static: It is a static data structure that describes the size and structures of a collection of data items associated with a memory location at compile time that are fixed. Example - Array.
  4. Homogenous: It is a characteristic of data structures representing whether the data type of all elements is the same. Example- Array.
  5. Non-Homogenous: It is a characteristic of data structures representing whether the data type elements may or may not be the same.
  6. Dynamic: It is a dynamic data structure that defines the shrinking and expanding of data items at the run time or the program's execution. It is also related to the utilization of memory location that can be changed at the program's run time. Example: Linked list.
  7. It has some rules that define how the data items are related to each other.
  8. It defines some rules to display the relationship between data items and how they interact with each other.
  9. It has some operations used to perform on data items like insertion, searching, deletion, etc.
  10. It helps in reducing the usage of memory resources.
  11. Time Complexity: The execution time of a program in a data structure should be minimum as possible.
  12. Space Complexity: The memory usage through all data items in a data structure should be less possible.

Basic Operations of Data Structures

Some basic functions are chosen based on all types of data that occur in a data structure.

  1. Traversing: It is used to visit each variable once. It is also referred to as visiting elements in the data structure.
  2. Searching: It is used to find the location of a given element in the whole data structure. Example, an array.
  3. Insertion: It is used to insert an element at the specified position in data elements.
  4. Deletion: A deletion operation is used to delete an element from the specified location.
  5. Sorting: It is used to arrange or sort the data elements in ascending or descending order. However, the data items are arranged in some logical order, such as Name key, account number, etc.
  6. Merging: The Merge operation is used to join two or more sorted data elements to a data structure.

Needs of the data structures

Data is a basic fact or entity information that is used to calculate or manipulate. Two types of data are used in a data structure, such as numerical data and alphanumeric data. These data structures specify the nature of the data item undergoing some function. Integers and floating points are types of numeric data types. The data can be single or a set of values that are organized in a particular fashion. The data organization leads to memory that creates a logical relationship between data items and makes it necessary to use data structures.

Advantages of Data Structures

There are some advantages of data structure:

  1. Efficiency: The efficiency and organization of a program depend on the selection of the right data structures. Suppose we want to search for a particular item from a collection of data records. In that case, our data should be organized in linear like an array that helps to perform the sequential search, such as element by element. However, it is efficient but more time consuming because we need to arrange all elements and then search each element. Hence, we choose a better option in a data structure, making the search process more efficient, like a binary search tree, selection or hash tables.
  2. Reusability: In the data structure, many operations make the programs reusable. For example, when we write programs or implement a particular data structure, we can use it from any source location or place to get the same results.
  3. Abstraction: The data structure is maintained by the ADT, which provides different levels of abstraction. The client can interact with data structures only through the interface.
  4. The data structure helps to simplify the process of collection of data through the software systems.
  5. It is used to save collection data storage on a computer that can be used by various programs.

Disadvantages of data structures

  1. A user who has deep knowledge about the functionality of the data structure can make changes to it.
  2. If there is an error in the data structure, an expert can detect the bug; The original user cannot help themselves solve the problem and fix it.

Following are the data structures and their uses are as follows:

Array: An array data structure is a collection of elements of the same data type used to store data in contiguous memory locations. It has a fixed size collection of data elements that cannot be changed at runtime of a program. It is mostly used in a computer program to organize the data so that related items or values can be easily searched or sorted in a system.

Fundamental of the Data Structure

Linked List: It is a collection of data links called nodes where each node contains a data value and the address of the next link. All elements of the linked list are not stored in neighbouring memory locations. In simple words, it is a sequence of data nodes that connect through links. Each node of a list is consists of two items: the basic idea behind the uses of a linked list in a data structure is that each node within the structure includes a data part where we store values, and a pointer indicates the next node can be found. The linked list's starting point denotes the head of the list, and the endpoints represent the node's tail.

Fundamental of the Data Structure

Stack: It is a linear data structure that enables the elements to be inserted and deleted from one end, called the Top of Stack (TOS). A stack data structure follows the last in first out (LIFO) operation to insert and remove an element from the stack list. It is an abstract data type with two possible operations to insert and delete elements in the stack: push and pop. A push operation is used in the stack to insert elements at the top of the list, hide those elements that already available in the list, or initialize the stack if it is empty. The pop operation is used in the stack data structure to delete a data item from the top of the list.

Fundamental of the Data Structure

Queue: It is a linear data structure that enables the insertion at one end of the list, known as the rear, and the deletion of the elements occurred at another end of the list, called the front. It is a sequential collection of data elements based on the First in First out (FIFO) data structure, which means the first inserted elements in a queue will be removed first from the queue list.

These queue operations are described below:

  1. Enqueue(): It is a queue operation used to insert an element to the list.
  2. Dequeue(): It is a queue operation used to delete an item from the list.
  3. Peek(): It is used to get the first element of the queue list without removing it.
  4. IsFull(): It is an IsFull operation that indicates whether the list is full.
  5. IsEmpty(): It is an IsEmpty operation that represents whether the list is empty.
Fundamental of the Data Structure

Graphs: A graph is a non- linear data structure consisting of finite sets of vertices (nodes) and edges to create an illustrated representation of a set of objects. These edges and nodes are connecting through any two nodes in the graph. The connected node can be represented as a directed or undirected graph. In a directed graph, each node is directly connected with edges in only one direction. In an undirected graph, each node is connected with edges in all directions. Hence it is also known as a bidirectional node.

Fundamental of the Data Structure

Trees: It is a type of non-linear data structure representing the hierarchical data. It is a finite set of elements where one of these nodes or elements is called a root node, and the remaining elements of a data structure consisting of a value called Subtrees. Every node of the tree maintains the parent-child relationship, where only one parent node and the remaining node in the tree is the child node. A node can have multiple child nodes but has a single parent node. There are some types of trees, such as a binary tree, binary search tree, expression trees, AVL tree and B trees.

Fundamental of the Data Structure

Heap: A heap data structure is a special type of complete binary tree that satisfies the heap property and arranged the elements in a specific order. Max and Min heap are the types of heap data structures. In Max heap, the root node's value is always higher or equal to the value of all existing child nodes in the heap tree. While in Min heap, the value of the root node/element is always shorter than the existing elements of the heap node. Each child node's value in the min-heap is equal to or larger than the parent node's value.

Fundamental of the Data Structure

Hash Table: It is a non-linear type of data structure that holds and organizes data in key-value pairs to access the particular keys/data elements. A key is a null value that is mapped or linked to an element. Hashing makes our data structure much simpler and faster when performing insertion and search operations on various data elements, regardless of the data's size.

Fundamental of the Data Structure

Dictionary: A dictionary is a type of data structure that holds data elements in a group of objects and is similar to a hash table, except that it is an ordered or unordered collection of data elements in key-value pairs. Each key is associated with a single value. When we retrieve a key, the dictionary will return the associated value of a key.

For example, students = {'James' = 25, 'Jasmine' = '17', 'Rosy = '19', 'Margret' = '24', 'Price' = '28'}


Next TopicHash Table





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA