learning the fundamentals of data structures

Exactly what is the data structure? look at this-

Related data is arranged in a computer's data structure for effective utilisation.

Various data structures are appropriate for various purposes, and some are highly specialised for particular tasks. For instance, queues can be used to create task schedulers, compiler implementations typically use hash tables to look up identifiers, binary trees are used in search algorithms, and graphs are used to represent connections on social websites (such as Twitter and Facebook). Trees are used to represent hierarchical data, such as files and folders in a filesystem.

Typically, the key to creating an effective algorithm is selecting the appropriate data structure.

The most popular data structures include the following: - Array - Linked List - Stack, Queue - Graph, Tree - Hash Table

Linked lists, for example, can be used to generate stacks and queues. Some data structures can be used to create other data structures.

istockphoto-1275954204-612x612.jpg

1) Linked list

Other data structures are frequently implemented using the linked list data structure. A linked list is a collection of nodes where each node contains a pointer (address) to the node after it as well as its own data. One node connects to another, creating what might be compared as a chain:

The final item in the list contains a link to NULL, signifying that the chain has come to an end.

The basic building block for constructing data structures like stacks, queues, trees, and graphs is typically a linked list.

1.PNG

2) Stack

Simple data structures like stacks add and remove components in a specific order. Each new element is placed at the "top" of the stack. Similar to a stack of plates, only a piece at the top of the stack can be removed. LIFO is the name of this behaviour (Last In, First Out).

Push is the term for adding a new element to the stack. Pop refers to the act of removing an element from the stack.

An array or a linked list can be used to implement a stack.

1.PNG

3)Queue

A simple data structure known as a queue allows components to be added from one end, referred to as the rear (also known as the tail), and deleted from the other end, referred to as the front (also called head). This behaviour is referred to as FIFO (First in First Out).

Enqueue refers to the action of adding new elements to the queue. Dequeue refers to the action of removing an entry from the queue. Either an array or a linked list can be used to implement a queue.

2.PNG

4)Graphs

Numerous real-world applications, including networks, a city's transportation system, and social networks like Facebook, where each user is a single node, are represented by graphs. Graphs are helpful in other computer science applications as well.

A graph is a collection of interconnected nodes, with each node being referred to as a vertex and each connecting node being referred to as an edge. A graph is defined as a type of data structure with finite vertices and edges.

Undirected (A) and directed (B) graphs are the two different types of graphs.

5)Binary tree

Binary trees are hierarchical data structures as opposed to linear ones like arrays, linked lists, stacks, and queues. They are made up of nodes that are connected. The root refers to the topmost node. The nodes that are immediately beneath a specific node are referred to as the node's offspring. Because each node can have a maximum of two children, the tree is known as a binary tree. A node's parent is the node right above it in the tree. Subtree refers to the tree that is a node's offspring. Leaves are elements that are childless. The height is the maximum number of nodes from root to leaf.

Binary trees come in a variety of forms, each with properties that are appropriate for the task at hand.

###Full Binary Tree If a binary tree has 0 or 2 children at each node, it is said to be full.

###Complete Binary Tree: If all but the last level of a binary tree are fully filled and the last level has all nodes as far to the left as feasible, the binary tree is said to be complete.

Optimal Binary Tree

If all internal nodes have two offspring and all leaves are on the same level, a binary tree is said to be perfect.

6)Hash Table

A structure that associates keys with values is a hash table. Let's start by defining the word "hash."

A technique called hashing is used to distinguish one particular object from a collection of related ones.

Here are some instances of how hashing is utilised in daily life:

• Each university student is given a special ID that may be used to store and retrieve data about them.

Libraries give each book a special number that is used to identify it on the shelves.

In both of these instances, hashing was employed to extract a unique number from the books and pupils. Any function that converts a set of data of any size into a set of data that fits into the hash table is referred to as a hash function. Hash values, hash codes, hash sums, or just hashes are the names given to the results of a hash function. To avoid collisions, the hash function must be able to produce a distinct hash for each element in the data set.

The hashes and the data they are connected with are kept in a hash table, which is a type of data structure. In our example, the books will be kept in the following manner: Associative arrays are frequently implemented using hash tables. table hashing Hash tables are used in database indexing, cache implementations, and so on.

7) Heap

In a heap, the root node key is compared to its offspring and the data is sorted in accordance with the results. If the heap is a max heap, the key at the root node is more than or equal to its children; if the heap is a min heap, the key is less than or equal to its children.

Thats all for now! do follow for more!