Non-Linear Structures#

image

Overview#

Non-linear data structures are data structures that do not follow a sequential or linear order, such as arrays or lists. Non-linear data structures are essential for solving complex problems and modeling real-world scenarios.

Trees#

Trees are hierarchical data structures that consist of nodes connected by edges. Each node can have zero or more child nodes, and every node in the tree is connected to exactly one parent node, except for the root node. Trees are used in many algorithms, including search algorithms, sorting algorithms, and path-finding algorithms.

Graphs#

Graphs are a more general data structure that consists of vertices or nodes connected by edges. Graphs can be directed or undirected and can contain cycles. Graphs are used to model many real-world scenarios, including social networks, transportation systems, and computer networks.

Hash tables#

Hash tables are data structures that allow for fast insertion, deletion, and retrieval of key-value pairs. In a hash table, each key is mapped to a unique index using a hash function. Hash tables are commonly used in database management systems, caching systems, and compilers.

Heaps#

Heaps are binary trees that satisfy the heap property, where the parent node is either greater than or less than its child nodes. Heaps are used to implement priority queues, where the elements are processed in order of their priority.

Tries#

Tries are tree-like data structures used for efficient searching and retrieval of key-value pairs. In a trie, each node represents a prefix of one or more keys.

Bloom filters#

Bloom filters are probabilistic data structures used for set membership testing. Bloom filters use a hash function to map elements to a bit array, allowing for efficient insertion and query operations.

Common algorithms#

Tree traversal algorithms#

Ex. in-order, pre-order, and post-order traversal

Shortest path algorithms#

Ex. Dijkstra’s algorithm and Bellman-Ford algorithm

Minimum spanning tree algorithms#

Ex. Kruskal’s algorithm and Prim’s algorithm

Graph search algorithms #

Ex. breadth-first search and depth-first search

Hashing algorithms#

Ex. SHA-1 and MD5

Sorting algorithms#

Ex. heapsort and quicksort

Overall, non-linear data structures and algorithms are essential for solving complex problems in computer science. Understanding the properties, use cases, and associated algorithms of non-linear data structures is crucial for computer scientists and programmers.