Applications of Data Structures

Application of various data structures in operating system And DBMS

1. Arrays

Array एक linear data structure है, जिसमें समान type के elements contiguous memory locations में store होते हैं। Arrays में indexing possible होती है, जिससे किसी भी element को तुरंत access किया जा सकता है।

Applications :

  • Process Table Management : हर process का PCB (Process Control Block) manage करने के लिए arrays use होते हैं। इसमें PID, priority, state, CPU registers store किए जाते हैं।
  • Memory Management : Continuous memory allocation को track करने और manage करने के लिए arrays का use होता है।
  • File Descriptor Table : हर process के लिए open files का tracking array में किया जाता है।

2. Linked List

Linked List एक dynamic linear data structure है, जिसमें elements (nodes) memory में non-contiguous locations पर होते हैं। हर node में data + pointer होता है, जो next node को point करता है।

Applications :

  • Process Scheduling (Ready Queue) : OS में Ready Queue implement करने के लिए linked lists use होते हैं। जब process execute होने के लिए wait करता है, तो उसे dynamically add/remove किया जाता है।
  • Memory Management (Free List) : Free memory blocks को track करने के लिए OS linked list of free memory blocks maintain करता है।
  • Device Management : Device driver queues को linked list से implement किया जाता है।

3. Stack

Stack एक linear data structure है, जिसमें elements LIFO (Last In First Out) order में store और access होते हैं। इसका मतलब है, कि जो element last में add हुआ है, वह first remove होगा

Applications :

  • Function Call Management : OS में function calls manage करने के लिए call stack use होता है। जब function call होता है, return address stack में push किया जाता है और return होने पर pop किया जाता है।
  • Interrupt Handling : Stack temporarily current process state store करने के लिए use होता है।
  • Expression Evaluation & Syntax Parsing : Compilers और OS command interpreters stack का use करके arithmetic expressions और syntax parsing करते हैं।

4. Queue

Queue एक linear data structure है, जिसमें elements को FIFO (First In First Out) order में process किया जाता है। यानी सबसे पहले आया element सबसे पहले बाहर जाएगा

Applications :

  • Process Scheduling : Round Robin scheduling में ready processes को queue में store किया जाता है ताकि हर process को fair CPU time मिल सके।
  • Device Management : Printer, disk और अन्य I/O devices के requests queue में रखे जाते हैं, और FIFO order में process किए जाते हैं।
  • Memory Management : Paging, swapping या page-fault handling में processes queue में wait करते हैं, जब तक required memory/page available न हो जाए।

5. Trees

Tree एक non-linear, hierarchical data structure है, जिसमें data को parent–child relationship के form में organize किया जाता है। इसमें सबसे ऊपर एक root node होता है, और उसके नीचे multiple child nodes, जो आगे अपने children बना सकते हैं।

Applications :

  • File System Organization : File systems (जैसे Windows NTFS, Linux ext4) में directories और subdirectories को hierarchical tree structure में organize किया जाता है, जिससे files को manage और locate करना आसान होता है।
  • Process Hierarchy : OS में हर process का एक parent-child relationship होता है, जिसे process tree के रूप में represent किया जाता है।
  • Search Optimization : OS में search operations को तेज़ बनाने के लिए Binary Search Trees (BST), B-Trees या B+ Trees जैसी tree structures का use किया जाता है।

6. Graphs

Graph एक non-linear data structure है, जिसमें data को vertices (nodes) और उन्हें जोड़ने वाले edges के रूप में store किया जाता है। यह उन situations के लिए उपयोग होता है, जहाँ multiple objects एक-दूसरे से किसी न किसी तरीके से connected होते हैं।

Applications :

  • Deadlock Detection : OS Resource Allocation Graph (RAG) का use करके processes और resources के बीच dependencies को track करता है। अगर graph में cycle बनती है, तो deadlock detect हो जाता है।
  • Networking : OS में network topology, routing tables और shortest path algorithms (जैसे Dijkstra) को graph structure के रूप में model किया जाता है।
  • Process Communication : Inter-process communication (IPC), synchronization और process dependencies को graph-based models से visualize और analyze किया जाता है।

7. Hash Tables

Hash Table एक key–value आधारित data structure है, जिसमें data को hash function की मदद से fast तरीके से store और retrieve किया जाता है। Hash function key को एक unique index (hash code) में बदल देता है, जहाँ value को store किया जाता है।

Applications :

  1. Page Tables Mapping
    • Operating System में page table virtual address को physical address से map करता है।
    • यह mapping तेज़ बनाने के लिए Hash Table का उपयोग किया जाता है ताकि memory access time कम हो सके।
  2. File System Indexing
    • File system (जैसे NTFS, ext4 आदि) में files को जल्दी search और retrieve करने के लिए hash-based indexing use होती है।
    • इससे file lookup बहुत fast हो जाता है, और directory scan की आवश्यकता कम होती है।
  3.  Memory Allocation Management
    • Dynamic memory allocation में free memory blocks को track करना जरूरी होता है।
    • OS इन free blocks को efficiently manage करने के लिए Hash Table use करता है, ताकि allocation और deallocation जल्दी हो सके।
  4. System Caches (OS Cache Management)
    • OS cache (जैसे page cache, buffer cache) में frequently used data store होता है।
    • Cache entries को तेजी से locate करने के लिए भी hash tables का उपयोग किया जाता है।
  5. Kernel Data Structures
    • Operating System kernel में कई internal structures — जैसे open files list, process metadata, device info — को fast access के लिए hashing technique से manage किया जाता है।
error: Content is protected !!