Advertisement

Data Structure में Binary Tree क्या होता है? और उसके प्रकार

बाइनरी ट्री एक hierarchical data structure होता है जिसमे हर एक node के maximum दो child nodes होते है जिन्हे left node और right node से जाना जाता है। यह searching, sorting और hierarchical आदि जैसे data representation के लिए बहुत ज्यादा useful होता है।

Binary Tree जो है वह DSA का एक बहुत ही ज्यादा important concept है जो efficient data management में काफी मदत करता है। तो आज के इस पोस्ट में हम यही जानेगे की बाइनरी ट्री होता क्या है। बाइनरी ट्री के प्रकार। आदि जैसे टॉपिक पर चर्चा करने वाले है, तो चलिए शुरू करते है और जानते है।

What is Binary Tree in Hindi - बाइनरी ट्री क्या है।

बाइनरी ट्री जो है वह एक प्रकार का hierarchical data structure होता है जो कई सारे nodes का एक समूह (set) होता है, जिसमे हर एक node के अपने खुद के maximum दो child nodes होते है:

Advertisement

जो left child और right child के नाम से जाने जाते है। डाटा स्ट्रक्चर (Data Structure) में बाइनरी ट्री का उपयोग data को efficiently फॉर्म में store, search और manipulate करने के लिए किया जाता है।

आशान भाषा में कहे तो बाइनरी ट्री एक non-linear डाटा स्ट्रक्चर (data structure) होता है जो hierarchical form में होता है। इसका हर एक node जो होता है जो मुख्यता तीन भागो (parts) में contain करता है:

  1. Data - यह Node में अंदर की value को store करता है।
  2. Left Child - यह Left subtree का reference होता है।
  3. Right Child - यह Right subtree का reference होता है।

बाइनरी ट्री को हम बिल्कुल linked list की तरह प्रदर्शित (represent) कर सकते है, यानि इसको भी हम लिंक लिस्ट की तरह node में प्रदर्शित कर सकते है, जिसका हर एक नोड दूसरे nodes का reference रखता है।

Advertisement

Representation of Binary Tree

Data Structure में बाइनरी ट्री को मुख्यतः दो तरीकों से प्रस्तुत (Representation) किया जाता है:

1. Linked Representation

इस तकनीक (technique) में, हर एक node का अपना खुद का एक structure या class होता है, जिसमे डाटा (data) field, left pointer, और right pointer होते है, जो किसी निर्धारित क्रम में data store करने और left & right subtrees को reference प्रदान करने के लिए उपयोग (use) होते है।

Linked List Representation of Binary Tree
Linked List Representation of Binary Tree

2. Array Representation

बाइनरी ट्री को हम array के रूप में भी प्रदर्शित कर सकते है, जिसमें parent-child के जो relation होता है वह कुछ इस प्रकार होते हैं:

  • Parent node का index i उपस्थित होता है।
  • Left child का index = 2 * i + 1
  • Right child का index = 2 * i + 2
Array Representation of Binary Tree
Array Representation of Binary Tree

Types of Binary Tree in Hindi - बाइनरी ट्री के प्रकार

डाटा स्ट्रक्चर में बाइनरी ट्री के कई प्रकार होते है, जिनमे से कुछ ट्री को हमने नीचे परिभाषित किया है:

  1. Full Binary Tree
  2. Complete Binary Tree
  3. Perfect Binary Tree
  4. Balanced Binary Tree
  5. Skewed Binary Tree

1. Full Binary Tree

Full बाइनरी ट्री एक ऐसी tree होती है जिसमे प्रत्येक यानि हर एक node के पास या तो अपने खुद के exactly 2 child होते या फिर उनके पास कोई भी child उपस्थित नहीं होता है।

इस ट्री का उपयोग एक structured way में डाटा (data) को store और retrieve करने के लिए काफी हद तक किया जाता है, जिसकी सहायता searching और processing बहुत ज्यादा fast हो जाती है।

Full Binary Tree
Full Binary Tree

2. Complete Binary Tree

Complete बाइनरी ट्री एक इस तरह का tree है जिसमे हमेशा nodes को left side से right side की तरफ fill किया जाता है, और इसमें हमेशा डाटा left side भरना शुरू किया जाता है।

यानि इसमें पहले left साइड में सबसे छोटा डाटा fill होता है फिर उससे बड़ा डाटा right में fill होता है। यह tree Heap Data Structure में उपयोग की जाती है, जिससे efficient memory management और fast access possible हो पाटा है। इसको आप नीचे दिए गए चित्र की सहायता से आसानी से समझ सकते है।

Complete Binary Tree
Complete Binary Tree

3. Perfect Binary Tree

Perfect बाइनरी ट्री वो ट्री होता है जिसमे सभी उपस्थित internal nodes के बिल्कुल 2 child उपस्थित होते है, और सभी leaf nodes एक ही level पर होते है।

इस तरह का जो ट्री होता है वह पूरी तरह balanced होता है, जिसमे data की proper organization और retrieval होती है। Perfect बाइनरी ट्री का उपयोग मुख्यता computer networks और game trees में किया जाता है।

perfect-binary-tree-1

4. Balanced Binary Tree

Balanced बाइनरी ट्री जो है वह एक ऐसी tree होती है जिसमे हर एक node के left और right दोनों तरफ की subtrees की जो height होती है उसका difference कभी भी 1 से ज्यादा नहीं होता है।

इसका सबसे अच्छा (best) example "AVL Tree" है, जो database में indexing और memory management में उपयोग होता है।

यह ट्री searching और updating आदि जैसे operations को काफी fast बनता है, क्योकि insertion और deletion के बाद ही कोई tree balanced रह सकता है।

Balanced Binary Tree
Balanced Binary Tree

5. Skewed Binary Tree

Skewed बाइनरी ट्री वह ट्री होता है जिसमे nodes जो है वह एक ही दिशा (direction) में होते है, यानि इसमें जो tree होती है वह ज्यादातर linked list जैसी दिखती है।

  • Left Skewed Tree - जब सभी nodes left side में होते है।
  • Right Skewed Tree - जब सभी nodes right side में होते है।
Skewed Binary Tree
Skewed Binary Tree

यह ट्री तब बनती है जब unbalanced insertion होती है, जिसमे साइड काफी ज्यादा grow करता है और दूसरी तरफ पूरी तरह यानि almost खाली (empty) रहती है।

Conclusion (निष्कर्ष)

आज हमने इस पोस्ट की सहायता से यह जाना की Binary Tree क्या होता है, यह काम कैसे करता है और साथ ही यह जाना की इसके types कौन - कौन से होते है। Binary Tree DSA का एक बहुत ही महत्वपूर्ण (important) हिस्सा है जो डाटा को efficiently manage करने और algorithms को optimize करने के लिए काफी सहायता करता है।

उम्मीद है की आपको यह जानकारी useful लगी होगी और आपने इसकी सहायता से कुछ नया शीखा होगा साथ ही अगर आपको इस टॉपिक से सम्बंधित कोई सुझाब देना हो या फिर किसी दूसरे टॉपिक से सम्बंधित जानकारी चाहिए हो तो आप हमें comment या कॉन्टेक्ट form की सहायता से बता सकते है। ऐसे ही और भी interesting topics जानने के लिए जुड़े रहिए "HindiStudyHub" के साथ। Thank You!

Table of Contents

Close

Comments

Share to other apps

Report Content

Why are you reporting this content?

Your selection helps us review the content and take appropriate action.

Hate & Discrimination
Content that spreads hate or unfair treatment against a person or group because of who they are.
Abuse & Harassment
Content that insults, threatens, bullies, or makes someone uncomfortable.
Violence & Threats
Content that talks about hurting people, animals, or property, or supports violence.
Child Safety
Any content that harms, exploits, or puts children at risk.
Privacy Violation
Sharing someone’s personal information or photos without permission.
Illegal & Regulated Activities
Content that promotes or helps with illegal activities like drugs, weapons, or trafficking.
Spam & Misleading Content
Fake, misleading, or repeated content meant to trick users.
Suicide or Self-Harm
Content that encourages or explains self-harm or suicide.
Sensitive or Disturbing Content
Shocking or graphic content that may upset users.
Impersonation
Pretending to be another person or organization.
Extremism & Hate Groups
Content that supports violent groups or hateful ideas.
Civic Integrity
Content that spreads false information about elections or public processes.