DATA STRUCTURE

DATA STRUCTURE


What is Data Structure?

The data structure name indicates itself that organizing the data in memory. There are many ways of organizing the data in the memory as we have already seen one of the data structures, i.e., array in C language. Array is a collection of memory elements in which data is stored sequentially, i.e., one after another. In other words, we can say that array stores the elements in a continuous manner. This organization of data is done with the help of an array of data structures. There are also other ways to organize the data in memory.

There are two types of data structures:

  • Primitive data structure
  • Non-primitive data structure

Primitive Data structure

The primitive data structures are primitive data types. The int, char, float, double, and pointer are the primitive data structures that can hold a single value.

Non-Primitive Data structure

The non-primitive data structure is divided into two types:

  • Linear data structure
  • Non-linear data structure

Major Operations

  • Searching: We can search for any element in a data structure.
  • Sorting: We can sort the elements of a data structure either in an ascending or descending order.
  • Insertion: We can also insert the new element in a data structure.
  • Updation: We can also update the element, i.e., we can replace the element with another element.
  • Deletion: We can also perform the delete operation to remove the element from the data structure.

The following are the advantages of a data structure:

  • Efficiency: If the choice of a data structure for implementing a particular ADT is proper, it makes the program very efficient in terms of time and space.
  • Reusability: The data structure provides reusability means that multiple client programs can use the data structure.
  • Abstraction: The data structure specified by an ADT also provides the level of abstraction. The client cannot see the internal working of the data structure, so it does not have to worry about the implementation part. The client can only see the interface.

Types of Linear Data Structures

1. Arrays

An Array is a data structure used to collect multiple data elements of the same data type into one variable. Instead of storing multiple values of the same data types in separate variable names, we could store all of them together into one variable. This statement doesn't imply that we will have to unite all the values of the same data type in any program into one array of that data type. But there will often be times when some specific variables of the same data types are all related to one another in a way appropriate for an array.

An Array is a list of elements where each element has a unique place in the list. The data elements of the array share the same variable name; however, each carries a different index number called a subscript. We can access any data element from the list with the help of its location in the list. Thus, the key feature of the arrays to understand is that the data is stored in contiguous memory locations, making it possible for the users to traverse through the data elements of the array using their respective indexes.

2. Linked Lists

A Linked List is another example of a linear data structure used to store a collection of data elements dynamically. Data elements in this data structure are represented by the Nodes, connected using links or pointers. Each node contains two fields, the information field consists of the actual data, and the pointer field consists of the address of the subsequent nodes in the list. The pointer of the last node of the linked list consists of a null pointer, as it points to nothing. Unlike the Arrays, the user can dynamically adjust the size of a Linked List as per the requirements.

3. Stacks

A Stack is a Linear Data Structure that follows the LIFO (Last In, First Out) principle that allows operations like insertion and deletion from one end of the Stack, i.e., Top. Stacks can be implemented with the help of contiguous memory, an Array, and non-contiguous memory, a Linked List. Real-life examples of Stacks are piles of books, a deck of cards, piles of money, and many more.

4. Queues

A Queue is a linear data structure similar to a Stack with some limitations on the insertion and deletion of the elements. The insertion of an element in a Queue is done at one end, and the removal is done at another or opposite end. Thus, we can conclude that the Queue data structure follows FIFO (First In, First Out) principle to manipulate the data elements. Implementation of Queues can be done using Arrays, Linked Lists, or Stacks. Some real-life examples of Queues are a line at the ticket counter, an escalator, a car wash, and many more.

Types of Non-Linear Data Structures

1. Trees

A Tree is a Non-Linear Data Structure and a hierarchy containing a collection of nodes such that each node of the tree stores a value and a list of references to other nodes (the "children").

The Tree data structure is a specialized method to arrange and collect data in the computer to be utilized more effectively. It contains a central node, structural nodes, and sub-nodes connected via edges. We can also say that the tree data structure consists of roots, branches, and leaves connected.

2. Graphs

A Graph is another example of a Non-Linear Data Structure comprising a finite number of nodes or vertices and the edges connecting them. The Graphs are utilized to address problems of the real world in which it denotes the problem area as a network such as social networks, circuit networks, and telephone networks. For instance, the nodes or vertices of a Graph can represent a single user in a telephone network, while the edges represent the link between them via telephone.

Basic Operations of Data Structures

we will discuss the different types of operations that we can perform to manipulate data in every data structure:

  1. Traversal: Traversing a data structure means accessing each data element exactly once so it can be administered. For example, traversing is required while printing the names of all the employees in a department.
  2. Search: Search is another data structure operation which means to find the location of one or more data elements that meet certain constraints. Such a data element may or may not be present in the given set of data elements. For example, we can use the search operation to find the names of all the employees who have the experience of more than 5 years.
  3. Insertion: Insertion means inserting or adding new data elements to the collection. For example, we can use the insertion operation to add the details of a new employee the company has recently hired.
  4. Deletion: Deletion means to remove or delete a specific data element from the given list of data elements. For example, we can use the deleting operation to delete the name of an employee who has left the job.
  5. Sorting: Sorting means to arrange the data elements in either Ascending or Descending order depending on the type of application. For example, we can use the sorting operation to arrange the names of employees in a department in alphabetical order or estimate the top three performers of the month by arranging the performance of the employees in descending order and extracting the details of the top three.
  6. Merge: Merge means to combine data elements of two sorted lists in order to form a single list of sorted data elements.
  7. Create: Create is an operation used to reserve memory for the data elements of the program. We can perform this operation using a declaration statement. The creation of data structure can take place either during the following: Compile-time Run-time For example, the malloc() function is used in C Language to create data structure.
  8. Selection: Selection means selecting a particular data from the available data. We can select any particular data by specifying conditions inside the loop.
  9. Update: The Update operation allows us to update or modify the data in the data structure. We can also update any particular data by specifying some conditions inside the loop, like the Selection operation.
  10. Splitting: The Splitting operation allows us to divide data into various subparts decreasing the overall process completion time.


要查看或添加评论,请登录

NISHANTH S的更多文章

  • "Unlocking Global Opportunities: Insights from the Mancomp Overseas Education Session at SNS College of Engineering"

    "Unlocking Global Opportunities: Insights from the Mancomp Overseas Education Session at SNS College of Engineering"

    Hey dear connections : this article is my vision Insights from the Mancomp Overseas Education Session at SNS College of…

  • "Building a Community of Innovators: The Vision Behind IMUN Club at SNS College of Engineering"

    "Building a Community of Innovators: The Vision Behind IMUN Club at SNS College of Engineering"

    Hey dear connections: My Vision Behind IMUN Club at SNS College of Engineering. Introduction: In today’s fast-paced…

  • Mac OS

    Mac OS

    Introduction macOS, the proprietary operating system for Apple's Macintosh computers, has evolved significantly since…

  • BEN 10

    BEN 10

    Introduction Ben 10, a franchise that has captivated the hearts and imaginations of children and adults alike since its…

  • COMPONENTS Of CPU

    COMPONENTS Of CPU

    The CPU, or Central Processing Unit, serves as the brain of a computer, orchestrating millions of operations per second…

  • GTA VI

    GTA VI

    Grand Theft Auto VI (GTA VI), the highly anticipated installment in the iconic video game series, has captured the…

  • INTRODUCTION C#

    INTRODUCTION C#

    C# is an object-oriented, component-oriented programming language. C# provides language constructs to directly support…

  • Design Thinking and 5 Pillars of SNS Institutions

    Design Thinking and 5 Pillars of SNS Institutions

    Design Thinking is a mindset and approach to learning, collaboration, and problem solving. In practice, the design…

  • 5G

    5G

    5th generation mobile network. It is a new global wireless standard after 1G, 2G, 3G, and 4G networks.

  • CLOUD COMPUTING

    CLOUD COMPUTING

    Cloud computing is the delivery of different services through the Internet, including data storage, servers, databases,…

社区洞察

其他会员也浏览了