• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

GKPAD.COM

ONLINE HINDI EDUCATION PORTAL

  • Home
  • Blog
  • Sarkari Result
  • University Books
  • University Papers
  • University Syllabus
  • About Us

IGNOU MCS-208 Solved Question Paper PDF Download

The IGNOU MCS-208 Solved Question Paper PDF Download page is designed to help students access high-quality exam resources in one place. Here, you can find ignou solved question paper IGNOU Previous Year Question paper solved PDF that covers all important questions with detailed answers. This page provides IGNOU all Previous year Question Papers in one PDF format, making it easier for students to prepare effectively.

  • IGNOU MCS-208 Solved Question Paper in Hindi
  • IGNOU MCS-208 Solved Question Paper in English
  • IGNOU Previous Year Solved Question Papers (All Courses)

Whether you are looking for IGNOU Previous Year Question paper solved in English or ignou previous year question paper solved in hindi, this page offers both options to suit your learning needs. These solved papers help you understand exam patterns, improve answer writing skills, and boost confidence for upcoming exams.

IGNOU MCS-208 Solved Question Paper PDF

IGNOU Previous Year Solved Question Papers

This section provides IGNOU MCS-208 Solved Question Paper PDF in both Hindi and English. These ignou solved question paper IGNOU Previous Year Question paper solved PDF include detailed answers to help you understand exam patterns and improve your preparation. You can also access IGNOU all Previous year Question Papers in one PDF for quick and effective revision before exams.


IGNOU MCS-208 Previous Year Solved Question Paper in Hindi

Q1. (a) एल्गोरिथ्म क्या है? इसके गुण क्या हैं? एल्गोरिथ्म की स्पेस और टाइम कॉम्प्लेक्सिटी के बीच ट्रेडऑफ की व्याख्या करें। लीनियर सर्च एल्गोरिथ्म की टाइम कॉम्प्लेक्सिटी की व्याख्या करें। (b) स्टैक क्या है? ऐरे का उपयोग करके स्टैक को कार्यान्वित करें। (c) निम्नलिखित ट्री के प्रीऑर्डर और पोस्टऑर्डर ट्रैवर्सल लिखें: [Image of a tree] (d) लिंक लिस्ट क्या है? लिंक लिस्ट में एलिमेंट डालने और हटाने के लिए एल्गोरिथ्म लिखें।

Ans.

(a) एल्गोरिथ्म और इसकी कॉम्प्लेक्सिटी

एल्गोरिथ्म: एक एल्गोरिथ्म किसी समस्या को हल करने या किसी गणना को करने के लिए अच्छी तरह से परिभाषित, चरण-दर-चरण निर्देशों का एक परिमित सेट है। यह एक रेसिपी की तरह है जो बताती है कि किसी विशेष कार्य को पूरा करने के लिए क्या करना है।

एल्गोरिथ्म के गुण:

  • परिमितता (Finiteness): एक एल्गोरिथ्म को हमेशा सीमित संख्या में चरणों के बाद समाप्त होना चाहिए।
  • निश्चितता (Definiteness): एल्गोरिथ्म का प्रत्येक चरण स्पष्ट और असंदिग्ध होना चाहिए।
  • इनपुट (Input): एक एल्गोरिथ्म में शून्य या अधिक अच्छी तरह से परिभाषित इनपुट हो सकते हैं।
  • आउटपुट (Output): एक एल्गोरिथ्म में एक या अधिक अच्छी तरह से परिभाषित आउटपुट होने चाहिए, जो इनपुट से संबंधित हों।
  • प्रभावशीलता (Effectiveness): प्रत्येक निर्देश इतना बुनियादी होना चाहिए कि उसे सिद्धांत रूप में, किसी व्यक्ति द्वारा केवल कागज और पेंसिल का उपयोग करके किया जा सके।

स्पेस-टाइम ट्रेडऑफ: यह कंप्यूटर विज्ञान में एक मूलभूत अवधारणा है। इसका मतलब है कि अक्सर एक एल्गोरिथ्म को तेज़ बनाने (समय कम करने) के लिए अधिक मेमोरी (स्पेस) का उपयोग करना पड़ता है, या मेमोरी उपयोग को कम करने के लिए इसे अधिक समय तक चलाना पड़ता है। उदाहरण के लिए, डेटा की गणना करने के बजाय उसे एक लुकअप टेबल (अधिक स्पेस) में संग्रहीत करने से प्रोसेसिंग (समय) तेज हो सकती है।

लीनियर सर्च की टाइम कॉम्प्लेक्सिटी: लीनियर सर्च एक ऐरे में किसी आइटम को खोजने के लिए एक सरल तरीका है। यह ऐरे की शुरुआत से शुरू होता है और वांछित एलिमेंट मिलने तक या ऐरे के अंत तक पहुंचने तक प्रत्येक एलिमेंट की क्रमिक रूप से जांच करता है।

  • बेस्ट केस कॉम्प्लेक्सिटी: O(1) – यह तब होता है जब खोजा जाने वाला एलिमेंट ऐरे का पहला एलिमेंट होता है।
  • वर्स्ट केस कॉम्प्लेक्सिटी: O(n) – यह तब होता है जब एलिमेंट ऐरे का अंतिम एलिमेंट होता है या ऐरे में मौजूद नहीं होता है। इस मामले में, सभी ‘n’ एलिमेंट्स की जांच करनी पड़ती है।
  • एवरेज केस कॉम्प्लेक्सिटी: O(n) – औसतन, एल्गोरिथ्म को एलिमेंट खोजने के लिए ऐरे के आधे हिस्से को स्कैन करना पड़ता है।

इस प्रकार, लीनियर सर्च की समग्र टाइम कॉम्प्लेक्सिटी को O(n) माना जाता है।

(b) स्टैक और इसका ऐरे कार्यान्वयन

स्टैक: स्टैक एक रैखिक डेटा संरचना है जो LIFO (लास्ट-इन, फर्स्ट-आउट) सिद्धांत का पालन करती है। इसका मतलब है कि जो एलिमेंट सबसे अंत में जोड़ा जाता है, उसे सबसे पहले हटाया जाता है। यह प्लेटों के ढेर की तरह काम करता है। मुख्य ऑपरेशन हैं:

  • Push: स्टैक के शीर्ष पर एक एलिमेंट जोड़ना।
  • Pop: स्टैक के शीर्ष से एक एलिमेंट हटाना।
  • Peek (या Top): शीर्ष एलिमेंट को हटाए बिना उसे देखना।

ऐरे का उपयोग करके कार्यान्वयन:

हम एक ऐरे और एक `top` नामक वैरिएबल का उपयोग करके स्टैक को लागू कर सकते हैं जो स्टैक के शीर्ष एलिमेंट को ट्रैक करता है। #define MAX_SIZE 100 int stack[MAX_SIZE]; int top = -1; // ओवरफ्लो की जांच करने के लिए फंक्शन int isFull() { return top == MAX_SIZE – 1; } // अंडरफ्लो की जांच करने के लिए फंक्शन int isEmpty() { return top == -1; } // स्टैक में एलिमेंट पुश करने के लिए एल्गोरिथ्म void push(int item) { if (isFull()) { printf(“Stack Overflow\n”); return; } top = top + 1; stack[top] = item; } // स्टैक से एलिमेंट पॉप करने के लिए एल्गोरिथ्म int pop() { if (isEmpty()) { printf(“Stack Underflow\n”); return -1; // त्रुटि मान } int item = stack[top]; top = top – 1; return item; }

(c) ट्री ट्रैवर्सल

दिए गए ट्री के लिए (मानक लेबलिंग A, B, C… का उपयोग करते हुए), ट्रैवर्सल इस प्रकार हैं: (माना गया ट्री: रूट A; B और C, A के बच्चे हैं; D और F, B के बच्चे हैं; G, C का बच्चा है; E, D का बच्चा है; H और I, E के बच्चे हैं)

प्रीऑर्डर ट्रैवर्सल (रूट, लेफ्ट, राइट): इस ट्रैवर्सल में, हम पहले रूट नोड पर जाते हैं, फिर बाएं सबट्री को रिकर्सिव रूप से ट्रैवर्स करते हैं, और अंत में दाएं सबट्री को रिकर्सिव रूप से ट्रैवर्स करते हैं। क्रम: A → B → D → E → H → I → F → C → G

पोस्टऑर्डर ट्रैवर्सल (लेफ्ट, राइट, रूट): इस ट्रैवर्सल में, हम पहले बाएं सबट्री को रिकर्सिव रूप से ट्रैवर्स करते हैं, फिर दाएं सबट्री को रिकर्सिव रूप से ट्रैवर्स करते हैं, और अंत में रूट नोड पर जाते हैं। क्रम: H → I → E → D → F → B → G → C → A

(d) लिंक लिस्ट

लिंक लिस्ट: एक लिंक लिस्ट एक रैखिक डेटा संरचना है जहां एलिमेंट्स को सन्निहित (contiguous) मेमोरी स्थानों में संग्रहीत नहीं किया जाता है। इसके बजाय, प्रत्येक एलिमेंट एक ‘नोड’ होता है जिसमें दो भाग होते हैं: डेटा और अगले नोड का एक पॉइंटर (या लिंक) । यह गतिशील मेमोरी आवंटन की अनुमति देता है।

लिंक लिस्ट में एलिमेंट डालने के लिए एल्गोरिथ्म (शुरुआत में):

1. `newNode` नामक एक नए नोड के लिए मेमोरी आवंटित करें।

2. `newNode` के डेटा भाग में मान सेट करें।

3. `newNode` के `next` पॉइंटर को वर्तमान `head` नोड पर इंगित करें।

4. `head` को `newNode` पर इंगित करने के लिए अपडेट करें। void insertAtBeginning(int data) { // नोड संरचना: struct Node { int data; struct Node* next; }; // हेड एक वैश्विक पॉइंटर है struct Node newNode = (struct Node )malloc(sizeof(struct Node)); newNode->data = data; newNode->next = head; head = newNode; }

लिंक लिस्ट से एलिमेंट हटाने के लिए एल्गोरिथ्म (शुरुआत से):

1. जांचें कि क्या लिस्ट खाली है (`head` NULL है)। यदि हां, तो बाहर निकलें।

2. `temp` नामक एक अस्थायी पॉइंटर बनाएं और उसे `head` पर इंगित करें।

3. `head` को अगले नोड पर ले जाएं (`head = head->next`)।

4. `temp` द्वारा इंगित मेमोरी को मुक्त करें। void deleteFromBeginning() { if (head == NULL) { printf(“List is empty.\n”); return; } struct Node* temp = head; head = head->next; free(temp); }

Q2. (a) बाइनरी ट्री क्या है? इसके गुण क्या हैं? एक उपयुक्त कोड की मदद से बताएं कि बाइनरी ट्री कैसे बनाया जाता है। (b) क्यू डेटा संरचना क्या है? इसके गुण क्या हैं? लिंक्ड लिस्ट का उपयोग करके क्यू को कार्यान्वित करें। आवश्यक धारणाएं बनाएं।

Ans.

(a) बाइनरी ट्री

बाइनरी ट्री: एक बाइनरी ट्री एक पदानुक्रमित डेटा संरचना है जिसमें प्रत्येक नोड में अधिकतम दो बच्चे हो सकते हैं, जिन्हें लेफ्ट चाइल्ड और राइट चाइल्ड कहा जाता है। सबसे ऊपर के नोड को रूट कहा जाता है। जिन नोड्स का कोई बच्चा नहीं होता है, उन्हें लीफ नोड्स कहा जाता है।

बाइनरी ट्री के गुण:

  • ऊंचाई ‘h’ (रूट 0 पर) वाले बाइनरी ट्री में नोड्स की अधिकतम संख्या 2 h+1 – 1 होती है।
  • लेवल ‘l’ पर नोड्स की अधिकतम संख्या 2 l होती है।
  • ‘N’ नोड्स वाले बाइनरी ट्री की न्यूनतम संभव ऊंचाई log₂(N+1) – 1 है।
  • एक गैर-खाली बाइनरी ट्री में यदि n₀ लीफ नोड्स की संख्या है और n₂ दो बच्चों वाले नोड्स की संख्या है, तो n₀ = n₂ + 1 ।

बाइनरी ट्री बनाना:

बाइनरी ट्री बनाने के लिए, हम पहले एक नोड संरचना को परिभाषित करते हैं। फिर, हम नोड्स बनाने और उन्हें एक साथ जोड़ने के लिए एक फ़ंक्शन का उपयोग करते हैं। #include

/* 1 / \ NULL NULL */ // बच्चे जोड़ना root->left = createNode(2); root->right = createNode(3); /* 1 / \ 2 3 */ // बाएं बच्चे के लिए एक और बच्चा जोड़ना root->left->left = createNode(4);

/* 1 / \ 2 3 / 4 */ printf(“बाइनरी ट्री सफलतापूर्वक बनाया गया।\n”); printf(“रूट नोड का मान: %d\n”, root->data); printf(“रूट के बाएं बच्चे का मान: %d\n”, root->left->data);

return 0; }

(b) क्यू और इसका लिंक्ड लिस्ट कार्यान्वयन

क्यू डेटा संरचना: क्यू एक रैखिक डेटा संरचना है जो FIFO (फर्स्ट-इन, फर्स्ट-आउट) सिद्धांत पर काम करती है। इसका मतलब है कि जो एलिमेंट सबसे पहले डाला जाता है, उसे सबसे पहले हटाया जाता है। यह एक कतार (लाइन) में खड़े लोगों की तरह है।

क्यू के गुण:

  • इसमें दो सिरे होते हैं: फ्रंट और रियर ।
  • एलिमेंट्स रियर सिरे पर डाले जाते हैं (इस ऑपरेशन को Enqueue कहा जाता है)।
  • एलिमेंट्स फ्रंट सिरे से हटाए जाते हैं (इस ऑपरेशन को Dequeue कहा जाता है)।
  • यदि क्यू खाली है, तो फ्रंट और रियर दोनों NULL होते हैं।

लिंक्ड लिस्ट का उपयोग करके कार्यान्वयन:

लिंक्ड लिस्ट क्यू के लिए आदर्श है क्योंकि यह गतिशील रूप से बढ़ और घट सकती है। हम दो पॉइंटर्स, `front` और `rear`, का उपयोग करेंगे। #include

Q3. (a) ऐरे क्या है? उदाहरणों के साथ ऐरे के रो मेजर और कॉलम मेजर रिप्रेजेंटेशन की व्याख्या करें। (b) फ़ाइल संगठन की आवश्यकता क्या है? फ़ाइल संगठन के लिए मुख्य ड्राइवर क्या हैं? इंडेक्स्ड सीक्वेंशियल फ़ाइल संगठन की व्याख्या करें।

Ans.

(a) ऐरे और इसका मेमोरी रिप्रेजेंटेशन

ऐरे: एक ऐरे एक रैखिक डेटा संरचना है जो एक ही प्रकार के डेटा आइटम्स का एक संग्रह है जो सन्निहित (contiguous) मेमोरी स्थानों में संग्रहीत होता है। प्रत्येक आइटम को एक इंडेक्स नंबर का उपयोग करके एक्सेस किया जा सकता है। यह कई वेरिएबल्स को एक ही नाम के तहत संग्रहीत करने की अनुमति देता है।

मल्टी-डायमेंशनल ऐरे, जैसे 2D ऐरे, को रैखिक मेमोरी में मैप करने के दो मुख्य तरीके हैं:

1. रो-मेजर रिप्रेजेंटेशन (Row-Major Representation): इस विधि में, 2D ऐरे के एलिमेंट्स को पंक्ति-दर-पंक्ति संग्रहीत किया जाता है। पहली पंक्ति के सभी एलिमेंट्स को पहले संग्रहीत किया जाता है, उसके बाद दूसरी पंक्ति के सभी एलिमेंट्स, और इसी तरह। ‘C’, ‘C++’, और ‘Python’ जैसी भाषाएँ रो-मेजर ऑर्डर का उपयोग करती हैं। एक `m x n` ऐरे `A` के लिए एलिमेंट `A[i][j]` का पता इस सूत्र का उपयोग करके गणना की जा सकती है: Address(A[i][j]) = BaseAddress + (i n + j) size जहाँ `BaseAddress` ऐरे का प्रारंभिक पता है, `i` पंक्ति इंडेक्स है, `j` कॉलम इंडेक्स है, `n` कॉलम की कुल संख्या है, और `size` प्रत्येक एलिमेंट का आकार है। उदाहरण: एक 3×3 ऐरे `int A[3][3]` मेमोरी में इस तरह दिखेगा: A[0][0], A[0][1], A[0][2], A[1][0], A[1][1], A[1][2], A[2][0], A[2][1], A[2][2]

2. कॉलम-मेजर रिप्रेजेंटेशन (Column-Major Representation): इस विधि में, 2D ऐरे के एलिमेंट्स को कॉलम-दर-कॉलम संग्रहीत किया जाता है। पहले कॉलम के सभी एलिमेंट्स को पहले संग्रहीत किया जाता है, उसके बाद दूसरे कॉलम के सभी एलिमेंट्स, और इसी तरह। ‘Fortran’ और ‘MATLAB’ जैसी भाषाएँ कॉलम-मेजर ऑर्डर का उपयोग करती हैं। एलिमेंट `A[i][j]` का पता इस सूत्र का उपयोग करके गणना की जा सकती है: Address(A[i][j]) = BaseAddress + (j m + i) size जहाँ `m` पंक्तियों की कुल संख्या है। उदाहरण: वही 3×3 ऐरे `int A[3][3]` मेमोरी में इस तरह दिखेगा: A[0][0], A[1][0], A[2][0], A[0][1], A[1][1], A[2][1], A[0][2], A[1][2], A[2][2]

(b) फ़ाइल संगठन

फ़ाइल संगठन की आवश्यकता: फ़ाइल संगठन उस तरीके को संदर्भित करता है जिसमें रिकॉर्ड (डेटा) सेकेंडरी स्टोरेज डिवाइस जैसे डिस्क पर संग्रहीत होते हैं। कुशल फ़ाइल संगठन की आवश्यकता निम्न कारणों से होती है:

  • तेजी से डेटा एक्सेस: रिकॉर्ड को जल्दी से खोजने और पुनर्प्राप्त करने में लगने वाले समय को कम करने के लिए।
  • कुशल भंडारण: भंडारण स्थान का इष्टतम उपयोग करने और बर्बादी को कम करने के लिए।
  • आसान अपडेट: रिकॉर्ड्स को आसानी से डालने, हटाने और संशोधित करने की अनुमति देने के लिए।
  • डेटा अखंडता: यह सुनिश्चित करने के लिए कि संग्रहीत डेटा सुसंगत और सटीक है।
  • सुरक्षा और सुरक्षा: डेटा को अनधिकृत पहुंच और सिस्टम विफलताओं से बचाने के लिए।

मुख्य ड्राइवर:

फ़ाइल संगठन की पसंद कई कारकों पर निर्भर करती है, जिन्हें मुख्य ड्राइवर कहा जाता है:

  • एक्सेस पैटर्न: क्या डेटा को क्रमिक रूप से (एक के बाद एक) या यादृच्छिक रूप से (किसी भी क्रम में) एक्सेस किया जाएगा?
  • अपडेट आवृत्ति: डेटा कितनी बार संशोधित होता है?
  • प्रतिक्रिया समय: उपयोगकर्ताओं को कितनी जल्दी डेटा की आवश्यकता होती है?
  • भंडारण लागत: उपलब्ध भंडारण की लागत और क्षमता।

इंडेक्स्ड सीक्वेंशियल फ़ाइल संगठन (Indexed Sequential File Organization): यह विधि सीक्वेंशियल फ़ाइल संगठन और डायरेक्ट (या रैंडम) फ़ाइल संगठन दोनों के लाभों को जोड़ती है। इसे ISAM (इंडेक्स्ड सीक्वेंशियल एक्सेस मेथड) के रूप में भी जाना जाता है।

  • संरचना: रिकॉर्ड्स को एक कुंजी फ़ील्ड (जैसे कर्मचारी आईडी) के आधार पर भौतिक रूप से क्रमिक रूप से संग्रहीत किया जाता है।
  • इंडेक्स: रिकॉर्ड्स तक तेजी से पहुंच प्रदान करने के लिए एक इंडेक्स बनाया जाता है। इंडेक्स में कुंजी मानों और डिस्क पर संबंधित रिकॉर्ड के पतों की प्रविष्टियाँ होती हैं। किसी रिकॉर्ड को खोजने के लिए, सिस्टम पहले इंडेक्स को खोजता है ताकि रिकॉर्ड वाले ब्लॉक का अनुमानित स्थान मिल सके, और फिर उस ब्लॉक को क्रमिक रूप से खोजता है।
  • लाभ: यह क्रमिक प्रसंस्करण (जैसे पेरोल) और यादृच्छिक प्रसंस्करण (जैसे किसी विशिष्ट ग्राहक के रिकॉर्ड को पुनः प्राप्त करना) दोनों के लिए कुशल है।
  • नुकसान: इंडेक्स को बनाए रखने के लिए अतिरिक्त स्थान की आवश्यकता होती है। जब कई रिकॉर्ड डाले या हटाए जाते हैं तो प्रदर्शन कम हो सकता है, जिसके लिए फ़ाइल के बार-बार पुनर्गठन की आवश्यकता होती है।

Q4. (a) बबल सॉर्ट एल्गोरिथ्म का उपयोग करके निम्नलिखित सूचियों को सॉर्ट करें। मध्यवर्ती चरण दिखाएं: 25 8 22 90 80 60 0 (b) ग्राफ क्या है? निम्नलिखित ग्राफ का एडजेसेंसी मैट्रिक्स रिप्रेजेंटेशन लिखें: [Image of a graph] (c) बी-ट्री क्या हैं? इसके अनुप्रयोग क्या हैं?

Ans.

(a) बबल सॉर्ट एल्गोरिथ्म

बबल सॉर्ट एक सरल सॉर्टिंग एल्गोरिथ्म है जो सूची के माध्यम से बार-बार कदम उठाता है, आसन्न तत्वों की तुलना करता है और यदि वे गलत क्रम में हैं तो उन्हें स्वैप करता है। यह प्रक्रिया तब तक दोहराई जाती है जब तक कि सूची सॉर्ट न हो जाए।

मूल सूची: [25, 8, 22, 90, 80, 60, 0]

मध्यवर्ती चरण:

पास 1: [ 8, 25 , 22, 90, 80, 60, 0] (25 > 8, स्वैप) [8, 22, 25 , 90, 80, 60, 0] (25 > 22, स्वैप) [8, 22, 25, 80, 90 , 60, 0] (90 > 80, स्वैप) [8, 22, 25, 80, 60, 90 , 0] (90 > 60, स्वैप) [8, 22, 25, 80, 60, 0, 90 ] (90 > 0, स्वैप) पास 1 के बाद: [8, 22, 25, 80, 60, 0, 90 ]

पास 2: [8, 22, 25, 60, 80 , 0, 90] (80 > 60, स्वैप) [8, 22, 25, 60, 0, 80 , 90] (80 > 0, स्वैप) पास 2 के बाद: [8, 22, 25, 60, 0, 80, 90 ]

पास 3: [8, 22, 25, 0, 60 , 80, 90] (60 > 0, स्वैप) पास 3 के बाद: [8, 22, 25, 0, 60, 80, 90 ]

पास 4: [8, 22, 0, 25 , 60, 80, 90] (25 > 0, स्वैप) पास 4 के बाद: [8, 22, 0, 25, 60, 80, 90 ]

पास 5: [8, 0, 22 , 25, 60, 80, 90] (22 > 0, स्वैप) पास 5 के बाद: [8, 0, 22, 25, 60, 80, 90 ]

पास 6: [ 0, 8 , 22, 25, 60, 80, 90] (8 > 0, स्वैप) पास 6 के बाद: [0, 8, 22, 25, 60, 80, 90]

सॉर्ट की गई सूची: [0, 8, 22, 25, 60, 80, 90]

(b) ग्राफ और एडजेसेंसी मैट्रिक्स

ग्राफ: एक ग्राफ एक गैर-रैखिक डेटा संरचना है जिसमें वर्टिसेस (या नोड्स) का एक सेट और उन वर्टिसेस को जोड़ने वाले एजेज (या आर्क्स) का एक सेट होता है। एक ग्राफ G को G = (V, E) के रूप में दर्शाया जाता है, जहाँ V वर्टिसेस का सेट है और E एजेज का सेट है। ग्राफ का उपयोग नेटवर्क, सर्किट और विभिन्न संबंधों को मॉडल करने के लिए किया जाता है।

एडजेसेंसी मैट्रिक्स रिप्रेजेंटेशन: यह एक ग्राफ का प्रतिनिधित्व करने का एक तरीका है जिसमें एक 2D मैट्रिक्स `A` का उपयोग किया जाता है, जहाँ `A[i][j]` का मान यह दर्शाता है कि वर्टेक्स `i` और वर्टेक्स `j` के बीच एक एज है या नहीं।

  • यदि वर्टेक्स `i` और `j` के बीच एक एज है, तो `A[i][j] = 1`।
  • अन्यथा, `A[i][j] = 0`।

दिए गए ग्राफ (एक पूर्ण ग्राफ K₄) के लिए, जिसमें 4 वर्टिसेस हैं (मान लें 1, 2, 3, 4), और प्रत्येक वर्टेक्स हर दूसरे वर्टेक्स से जुड़ा हुआ है।

एडजेसेंसी मैट्रिक्स:

1 2 3 4 1[0 1 1 1] 2[1 0 1 1] 3[1 1 0 1] 4[1 1 1 0] यह मैट्रिक्स सममित (symmetric) है क्योंकि ग्राफ अप्रत्यक्ष (undirected) है।

(c) बी-ट्री

बी-ट्री: एक बी-ट्री एक सेल्फ-बैलेंसिंग सर्च ट्री है जिसे डिस्क जैसे सेकेंडरी स्टोरेज डिवाइस पर संग्रहीत डेटा के लिए खोज समय को कम करने के लिए डिज़ाइन किया गया है। बाइनरी सर्च ट्री के विपरीत, बी-ट्री के नोड्स में दो से अधिक बच्चे हो सकते हैं।

बी-ट्री के गुण:

  • सभी लीफ नोड्स एक ही स्तर पर होते हैं।
  • एक बी-ट्री को एक न्यूनतम डिग्री ‘t’ (t ≥ 2) द्वारा परिभाषित किया जाता है।
  • रूट को छोड़कर प्रत्येक नोड में कम से कम `t-1` कुंजियाँ (keys) होनी चाहिए। रूट में कम से कम 1 कुंजी हो सकती है।
  • प्रत्येक नोड में अधिकतम `2t-1` कुंजियाँ हो सकती हैं।
  • एक आंतरिक नोड में कुंजियों की संख्या से एक अधिक बच्चे होते हैं।

ये गुण सुनिश्चित करते हैं कि ट्री संतुलित और अपेक्षाकृत उथला रहता है, जिससे डिस्क एक्सेस की संख्या कम हो जाती है।

बी-ट्री के अनुप्रयोग: बी-ट्री का व्यापक रूप से उन प्रणालियों में उपयोग किया जाता है जिन्हें बड़ी मात्रा में डेटा को पढ़ना और लिखना पड़ता है।

  • डेटाबेस सिस्टम: लगभग सभी आधुनिक डेटाबेस (जैसे Oracle, MySQL, PostgreSQL) तालिकाओं पर तेजी से डेटा पुनर्प्राप्ति के लिए इंडेक्स को लागू करने के लिए बी-ट्री या उनके वेरिएंट (जैसे B+ ट्री) का उपयोग करते हैं।
  • फ़ाइल सिस्टम: कई फ़ाइल सिस्टम (जैसे NTFS, HFS+, JFS) फ़ाइलों और निर्देशिकाओं को कुशलतापूर्वक प्रबंधित करने और खोजने के लिए बी-ट्री का उपयोग करते हैं।
  • बड़े डेटासेट में खोज: किसी भी एप्लिकेशन में जहां डेटा डिस्क पर रहता है और तेजी से खोज की आवश्यकता होती है, बी-ट्री एक उपयुक्त विकल्प है।

Q5. (a) AVL ट्री क्या है? AVL ट्री में एक नोड के इंसर्शन की व्याख्या करें। (b) बाइनरी सर्च एल्गोरिथ्म लिखें। (c) स्पैनिंग ट्री क्या है? न्यूनतम लागत स्पैनिंग ट्री खोजने के लिए प्रिम के एल्गोरिथ्म को लिखें और समझाएं। स्पैनिंग ट्री के अनुप्रयोग भी लिखें।

Ans.

(a) AVL ट्री

AVL ट्री: एक AVL ट्री (इसके आविष्कारकों Adelson-Velsky और Landis के नाम पर) एक सेल्फ-बैलेंसिंग बाइनरी सर्च ट्री (BST) है। इसमें, किसी भी नोड के लिए, बाएं और दाएं सबट्री की ऊंचाइयों का अंतर 1 से अधिक नहीं हो सकता है। इस गुण को बैलेंस फैक्टर द्वारा मापा जाता है। बैलेंस फैक्टर = height(बायां सबट्री) – height(दायां सबट्री) एक AVL ट्री में प्रत्येक नोड का बैलेंस फैक्टर -1, 0, या 1 होना चाहिए।

AVL ट्री में नोड का इंसर्शन: एक AVL ट्री में एक नोड डालने की प्रक्रिया में दो चरण होते हैं: 1. मानक BST इंसर्शन: सबसे पहले, नए नोड को उसी तरह डाला जाता है जैसे एक मानक बाइनरी सर्च ट्री में। 2. पुनर्संतुलन (Rebalancing): इंसर्शन के बाद, हम डाले गए नोड से रूट तक के रास्ते पर वापस जाते हैं। इस रास्ते पर प्रत्येक नोड के लिए, हम बैलेंस फैक्टर की जांच करते हैं। यदि कोई नोड असंतुलित हो जाता है (बैलेंस फैक्टर -1, 0, या 1 नहीं है), तो ट्री को संतुलित करने के लिए रोटेशन किया जाता है।

चार प्रकार के असंतुलन और संबंधित रोटेशन हैं:

  • लेफ्ट-लेफ्ट (LL) केस: नए नोड को असंतुलित नोड ‘z’ के बाएं बच्चे ‘y’ के बाएं सबट्री में डाला जाता है। इसे एक राइट रोटेशन द्वारा ठीक किया जाता है।
  • राइट-राइट (RR) केस: नए नोड को ‘z’ के दाएं बच्चे ‘y’ के दाएं सबट्री में डाला जाता है। इसे एक लेफ्ट रोटेशन द्वारा ठीक किया जाता है।
  • लेफ्ट-राइट (LR) केस: नए नोड को ‘z’ के बाएं बच्चे ‘y’ के दाएं सबट्री में डाला जाता है। इसे पहले ‘y’ पर एक लेफ्ट रोटेशन और फिर ‘z’ पर एक राइट रोटेशन (एक डबल रोटेशन ) द्वारा ठीक किया जाता है।
  • राइट-लेफ्ट (RL) केस: नए नोड को ‘z’ के दाएं बच्चे ‘y’ के बाएं सबट्री में डाला जाता है। इसे पहले ‘y’ पर एक राइट रोटेशन और फिर ‘z’ पर एक लेफ्ट रोटेशन (एक डबल रोटेशन ) द्वारा ठीक किया जाता है।

ये रोटेशन BST गुण को बनाए रखते हुए ट्री की ऊंचाई को पुनर्संतुलित करते हैं।

(b) बाइनरी सर्च एल्गोरिथ्म

बाइनरी सर्च एक कुशल एल्गोरिथ्म है जो एक सॉर्टेड ऐरे में एक मान खोजने के लिए उपयोग होता है। यह बार-बार खोज अंतराल को आधा करके काम करता है।

एल्गोरिथ्म: 1. ऐरे के मध्य तत्व के साथ लक्ष्य मान की तुलना करें। 2. यदि लक्ष्य मान मध्य तत्व से मेल खाता है, तो उसका इंडेक्स लौटाएं। 3. यदि लक्ष्य मान मध्य तत्व से कम है, तो खोज को निचले आधे (बाईं ओर) में जारी रखें। 4. यदि लक्ष्य मान मध्य तत्व से अधिक है, तो खोज को ऊपरी आधे (दाईं ओर) में जारी रखें। 5. यह प्रक्रिया तब तक दोहराई जाती है जब तक कि मान नहीं मिल जाता या अंतराल खाली नहीं हो जाता।

C-जैसी भाषा में पुनरावृत्ति (Iterative) एल्गोरिथ्म:

int binarySearch(int arr[], int size, int key) { int left = 0; int right = size – 1; while (left <= right) { // ओवरफ्लो से बचने के लिए mid की गणना int mid = left + (right – left) / 2; // जांचें कि क्या key मध्य में मौजूद है if (arr[mid] == key) { return mid; // तत्व मिला } // यदि key मध्य से बड़ी है, तो बाएं आधे को अनदेखा करें if (arr[mid] < key) { left = mid + 1; } // यदि key मध्य से छोटी है, तो दाएं आधे को अनदेखा करें else { right = mid – 1; } } // यदि हम यहां पहुंचते हैं, तो तत्व मौजूद नहीं था return -1; } बाइनरी सर्च की टाइम कॉम्प्लेक्सिटी O(log n) है, जो इसे बड़े डेटासेट के लिए बहुत तेज बनाती है।

(c) स्पैनिंग ट्री और प्रिम का एल्गोरिथ्म

स्पैनिंग ट्री: एक कनेक्टेड, अप्रत्यक्ष (undirected) ग्राफ G का एक स्पैनिंग ट्री एक सबग्राफ है जो एक ट्री है और इसमें G के सभी वर्टिसेस शामिल हैं। इसमें न्यूनतम संभव संख्या में एजेज होते हैं जो सभी वर्टिसेस को जोड़ते हैं, जिसका अर्थ है कि इसमें कोई साइकिल नहीं होती है।

न्यूनतम लागत स्पैनिंग ट्री (MST): एक भारित ग्राफ के लिए, न्यूनतम लागत स्पैनिंग ट्री (MST) एक स्पैनिंग ट्री है जिसका कुल भार (सभी एजेज के भार का योग) सभी संभव स्पैनिंग ट्री में से न्यूनतम या बराबर होता है।

प्रिम का एल्गोरिथ्म: प्रिम का एल्गोरिथ्म MST खोजने के लिए एक लालची (greedy) एल्गोरिथ्म है। यह ट्री को एक वर्टेक्स से शुरू करके बढ़ाता है, और प्रत्येक चरण में, यह ट्री में पहले से मौजूद वर्टिसेस को उन वर्टिसेस से जोड़ने वाला सबसे सस्ता संभव एज जोड़ता है जो अभी तक ट्री में नहीं हैं।

एल्गोरिथ्म के चरण: 1. एक MST सेट बनाएं जो शुरू में खाली हो। 2. सभी वर्टिसेस को असाइन करने के लिए एक `key` ऐरे बनाएं, जो MST में वर्टेक्स को जोड़ने वाले एज के भार को संग्रहीत करता है। सभी कुंजियों को अनंत (infinity) पर प्रारंभ करें और पहले वर्टेक्स की कुंजी को 0 पर सेट करें। 3. एक `parent` ऐरे बनाएं जो MST का निर्माण करेगा। 4. जब तक सभी वर्टिसेस MST सेट में शामिल न हो जाएं: a. एक वर्टेक्स `u` चुनें जो MST सेट में नहीं है और जिसकी कुंजी का मान न्यूनतम है। b. `u` को MST सेट में जोड़ें। c. `u` के सभी आसन्न वर्टिसेस `v` के लिए, यदि एज `(u, v)` का भार `v` की वर्तमान कुंजी से कम है, तो `v` की कुंजी को एज `(u, v)` के भार से अपडेट करें और `u` को `v` का पैरेंट सेट करें।

स्पैनिंग ट्री के अनुप्रयोग:

  • नेटवर्क डिजाइन: शहरों को न्यूनतम लागत पर केबल, फाइबर ऑप्टिक्स या सड़कों से जोड़ने जैसे कंप्यूटर नेटवर्क और दूरसंचार नेटवर्क को डिजाइन करने में।
  • क्लस्टर विश्लेषण: डेटा बिंदुओं को क्लस्टर में समूहित करने के लिए।
  • सर्किट डिजाइन: एक सर्किट बोर्ड पर पिनों को न्यूनतम तार लंबाई के साथ जोड़ने के लिए।
  • अनुमानित एल्गोरिदम: ट्रैवलिंग सेल्समैन जैसी NP-हार्ड समस्याओं के लिए अनुमानित समाधान खोजने में।

IGNOU MCS-208 Previous Year Solved Question Paper in English

Q1. (a) What is an algorithm ? What are its properties ? Explain tradeoff between space and time complexity of algorithms. Explain time complexity of linear search algorithm. (b) What is Stack ? Implement stack using array. (c) Write preorder and postorder traversals of the following tree: [Image of a tree] (d) What is Link List ? Write algorithms for inserting and deleting element in link list.

Ans. (a) Algorithm and its Complexity Algorithm: An algorithm is a finite set of well-defined, step-by-step instructions to solve a problem or perform a computation. It is like a recipe that specifies exactly what to do to complete a specific task. Properties of an Algorithm:

  • Finiteness: An algorithm must always terminate after a finite number of steps.
  • Definiteness: Each step of the algorithm must be precise and unambiguous.
  • Input: An algorithm may have zero or more well-defined inputs.
  • Output: An algorithm must have one or more well-defined outputs, which are related to the input.
  • Effectiveness: Every instruction must be basic enough to be carried out, in principle, by a person using only paper and pencil.


Space-Time Tradeoff:

This is a fundamental concept in computer science. It means that often, one has to use more memory (space) to make an algorithm faster (reduce time), or conversely, make it run for a longer time to reduce memory usage. For example, storing pre-computed data in a lookup table (more space) can speed up processing (time) compared to calculating it on the fly.


Time Complexity of Linear Search:

Linear search is a simple method for finding an item in an array. It starts from the beginning of the array and checks each element sequentially until the desired element is found or the end of the array is reached.

  • Best Case Complexity: O(1) – This occurs when the element being searched for is the very first element of the array.
  • Worst Case Complexity: O(n) – This occurs when the element is the last element of the array or is not present in the array at all. In this case, all ‘n’ elements must be checked.
  • Average Case Complexity: O(n) – On average, the algorithm has to scan half of the array to find the element.

Thus, the overall time complexity of a linear search is considered to be

O(n)

.


(b) Stack and its Array Implementation

Stack:

A stack is a linear data structure that follows the

LIFO (Last-In, First-Out)

principle. This means the element that is added last is the one to be removed first. It works like a stack of plates.

The main operations are:

  • Push: Adding an element to the top of the stack.
  • Pop: Removing an element from the top of the stack.
  • Peek (or Top): Viewing the top element without removing it.


Implementation using Array:

We can implement a stack using an array and a variable called `top` that tracks the top element of the stack.

#define MAX_SIZE 100int stack[MAX_SIZE];int top = -1;

// Function to check for overflowint isFull() { return top == MAX_SIZE - 1;}

// Function to check for underflowint isEmpty() { return top == -1;}

// Algorithm to push an element into the stackvoid push(int item) { if (isFull()) { printf("Stack Overflow\n"); return; } top = top + 1; stack[top] = item;}

// Algorithm to pop an element from the stackint pop() { if (isEmpty()) { printf("Stack Underflow\n"); return -1; // Error value } int item = stack[top]; top = top - 1; return item;}


(c) Tree Traversal

For the given tree (using standard labeling A, B, C…), the traversals are as follows:

(Assumed tree: Root A; B and C are children of A; D and F are children of B; G is child of C; E is child of D; H and I are children of E)


Preorder Traversal (Root, Left, Right):

In this traversal, we first visit the root node, then recursively traverse the left subtree, and finally recursively traverse the right subtree.


Order: A → B → D → E → H → I → F → C → G

Postorder Traversal (Left, Right, Root):

In this traversal, we first recursively traverse the left subtree, then recursively traverse the right subtree, and finally visit the root node.


Order: H → I → E → D → F → B → G → C → A

(d) Linked List

Linked List:

A linked list is a linear data structure where elements are not stored in contiguous memory locations. Instead, each element is a ‘node’ that contains two parts: the

data

and a

pointer (or link)

to the next node in the sequence. This allows for dynamic memory allocation.


Algorithm for Inserting Element (at the beginning):

1. Allocate memory for a new node called `newNode`.

2. Set the data part of the `newNode` to the value.

3. Point the `next` pointer of the `newNode` to the current `head` node.

4. Update the `head` to point to the `newNode`.

void insertAtBeginning(int data) { // Node structure: struct Node { int data; struct Node* next; }; // head is a global pointer struct Node newNode = (struct Node)malloc(sizeof(struct Node)); newNode->data = data; newNode->next = head; head = newNode;}

Algorithm for Deleting Element (from the beginning): 1. Check if the list is empty (`head` is NULL). If so, exit. 2. Create a temporary pointer `temp` and point it to the `head`. 3. Move the `head` to the next node (`head = head->next`). 4. Free the memory pointed to by `temp`.

void deleteFromBeginning() { if (head == NULL) { printf("List is empty.\n"); return; } struct Node* temp = head; head = head->next; free(temp);}

Q2. (a) What is a binary tree ? What are its properties ? Explain how to create a binary tree with the help of a suitable code. (b) What is queue data structure ? What are its properties ? Implement queue using linked list. Make necessary assumptions.

Ans. (a) Binary Tree Binary Tree: A binary tree is a hierarchical data structure in which each node can have at most two children, referred to as the left child and the right child . The topmost node is called the root . Nodes that have no children are called leaf nodes . Properties of a Binary Tree:

  • The maximum number of nodes in a binary tree of height ‘h’ (root at 0) is 2 h+1 – 1 .
  • The maximum number of nodes at level ‘l’ is 2 l .
  • The minimum possible height for a binary tree with ‘N’ nodes is log₂(N+1) – 1 .
  • In a non-empty binary tree, if n₀ is the number of leaf nodes and n₂ is the number of nodes with two children, then n₀ = n₂ + 1 .


Creating a Binary Tree:

To create a binary tree, we first define a node structure. Then, we use a function to create nodes and link them together.

#include <stdio.h>#include <stdlib.h>

// Structure of a binary tree nodestruct Node { int data; struct Node* left; struct Node* right;};

// A helper function to create a new nodestruct Node* createNode(int data) { struct Node newNode = (struct Node)malloc(sizeof(struct Node)); newNode->data = data; newNode->left = NULL; newNode->right = NULL; return newNode;}

int main() { // Create the tree // Root node struct Node* root = createNode(1); /* 1 / \ NULL NULL */

// Add children root->left = createNode(2); root->right = createNode(3);

/* 1 / \ 2 3 */

// Add another child to the left child root->left->left = createNode(4); /* 1 / \ 2 3 / 4 */

printf("Binary tree created successfully.\n"); printf("Value of root node: %d\n", root->data); printf("Value of root's left child: %d\n", root->left->data); return 0;}


(b) Queue and its Linked List Implementation

Queue Data Structure:

A queue is a linear data structure that operates on a

FIFO (First-In, First-Out)

principle. This means the first element inserted is the first one to be removed. It is like people standing in a queue (line).


Properties of a Queue:

  • It has two ends: Front and Rear .
  • Elements are inserted at the Rear end (this operation is called Enqueue ).
  • Elements are removed from the Front end (this operation is called Dequeue ).
  • If the queue is empty, both Front and Rear are NULL.


Implementation using Linked List:

A linked list is ideal for a queue as it can grow and shrink dynamically. We will use two pointers, `front` and `rear`.

#include <stdio.h>#include <stdlib.h>

// Structure of a nodestruct Node { int data; struct Node* next;};

// Front and Rear pointers of the queuestruct Node *front = NULL;struct Node *rear = NULL;

// To add an element to the queue (Enqueue)void enqueue(int value) { struct Node newNode = (struct Node)malloc(sizeof(struct Node)); newNode->data = value; newNode->next = NULL;

// If queue is empty, new node is both front and rear if (rear == NULL) { front = rear = newNode; return; }

// Add the new node at the end of the existing rear node rear->next = newNode; rear = newNode;}

// To remove an element from the queue (Dequeue)int dequeue() { // If queue is empty, it's an underflow if (front == NULL) { printf("Queue Underflow\n"); return -1; }

// Store front node and move front to the next struct Node* temp = front; int item = temp->data; front = front->next;

// If front becomes NULL, also make rear NULL if (front == NULL) { rear = NULL; }

free(temp); // free the old front node return item;}

Q3. (a) What is array ? Explain row major and column major representations of array with examples. (b) What is need of file organisation ? What are key drivers for file organization ? Explain indexed sequential file organization.

Ans. (a) Array and its Memory Representation Array: An array is a linear data structure that is a collection of data items of the same type stored in contiguous memory locations . Each item can be accessed using an index number. It allows storing multiple variables under a single name. There are two main ways to map multi-dimensional arrays, like 2D arrays, into linear memory: 1. Row-Major Representation: In this method, the elements of a 2D array are stored row by row. All elements of the first row are stored first, followed by all elements of the second row, and so on. Languages like ‘C’, ‘C++’, and ‘Python’ use row-major order. The address of an element `A[i][j]` for an `m x n` array `A` can be calculated using the formula: Address(A[i][j]) = BaseAddress + (i n + j) size where `BaseAddress` is the initial address of the array, `i` is the row index, `j` is the column index, `n` is the total number of columns, and `size` is the size of each element. Example: A 3×3 array `int A[3][3]` would look like this in memory: A[0][0], A[0][1], A[0][2], A[1][0], A[1][1], A[1][2], A[2][0], A[2][1], A[2][2] 2. Column-Major Representation: In this method, the elements of a 2D array are stored column by column. All elements of the first column are stored first, followed by all elements of the second column, and so on. Languages like ‘Fortran’ and ‘MATLAB’ use column-major order. The address of the element `A[i][j]` can be calculated using the formula: Address(A[i][j]) = BaseAddress + (j m + i) size where `m` is the total number of rows. Example: The same 3×3 array `int A[3][3]` would look like this in memory: A[0][0], A[1][0], A[2][0], A[0][1], A[1][1], A[2][1], A[0][2], A[1][2], A[2][2] (b) File Organization Need for File Organization: File organization refers to the way records (data) are stored on secondary storage devices like disks. Efficient file organization is needed for:

  • Fast Data Access: To reduce the time it takes to find and retrieve records quickly.
  • Efficient Storage: To make optimal use of storage space and reduce wastage.
  • Easy Updates: To allow for easy insertion, deletion, and modification of records.
  • Data Integrity: To ensure that the data stored is consistent and accurate.
  • Safety and Security: To protect data from unauthorized access and system failures.


Key Drivers:

The choice of file organization depends on several factors, known as key drivers:

  • Access Pattern: Will the data be accessed sequentially (one after another) or randomly (in any order)?
  • Update Frequency: How often is the data modified?
  • Response Time: How quickly do users need the data?
  • Storage Cost: The cost and capacity of the available storage.


Indexed Sequential File Organization:

This method combines the benefits of both sequential file organization and direct (or random) file organization. It is also known as

ISAM (Indexed Sequential Access Method)

.

  • Structure: Records are stored physically in a sequential order based on a key field (e.g., employee ID).
  • Index: An index is created to provide faster access to records. The index contains entries of key values and their corresponding addresses of the records on the disk. To find a record, the system first searches the index to find the approximate location of the block containing the record, and then searches that block sequentially.
  • Advantages: It is efficient for both sequential processing (like payroll) and random processing (like retrieving a specific customer’s record).
  • Disadvantages: It requires extra space for maintaining the index. Performance can degrade when many records are inserted or deleted, requiring frequent reorganization of the file.

Q4. (a) Sort the following lists using Bubble Sort Algorithm. Showing intermediate steps: 25 8 22 90 80 60 0 (b) What is graph ? Write adjacency matrix representation of the following graph : [Image of a graph] (c) What are B-trees ? What are its applications ?

Ans. (a) Bubble Sort Algorithm Bubble sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. This process is repeated until the list is sorted. Original List: [25, 8, 22, 90, 80, 60, 0] Intermediate Steps: Pass 1: [ 8, 25 , 22, 90, 80, 60, 0] (25 > 8, swap) [8, 22, 25 , 90, 80, 60, 0] (25 > 22, swap) [8, 22, 25, 80, 90 , 60, 0] (90 > 80, swap) [8, 22, 25, 80, 60, 90 , 0] (90 > 60, swap) [8, 22, 25, 80, 60, 0, 90 ] (90 > 0, swap) After Pass 1: [8, 22, 25, 80, 60, 0, 90 ] Pass 2: [8, 22, 25, 60, 80 , 0, 90] (80 > 60, swap) [8, 22, 25, 60, 0, 80 , 90] (80 > 0, swap) After Pass 2: [8, 22, 25, 60, 0, 80, 90 ] Pass 3: [8, 22, 25, 0, 60 , 80, 90] (60 > 0, swap) After Pass 3: [8, 22, 25, 0, 60, 80, 90 ] Pass 4: [8, 22, 0, 25 , 60, 80, 90] (25 > 0, swap) After Pass 4: [8, 22, 0, 25, 60, 80, 90 ] Pass 5: [8, 0, 22 , 25, 60, 80, 90] (22 > 0, swap) After Pass 5: [8, 0, 22, 25, 60, 80, 90 ] Pass 6: [ 0, 8 , 22, 25, 60, 80, 90] (8 > 0, swap) After Pass 6: [0, 8, 22, 25, 60, 80, 90] Sorted List: [0, 8, 22, 25, 60, 80, 90] (b) Graph and Adjacency Matrix Graph: A graph is a non-linear data structure consisting of a set of vertices (or nodes) and a set of edges (or arcs) that connect these vertices. A graph G is represented as G = (V, E), where V is the set of vertices and E is the set of edges. Graphs are used to model networks, circuits, and various relationships. Adjacency Matrix Representation: This is a way of representing a graph using a 2D matrix `A`, where the value of `A[i][j]` indicates whether there is an edge between vertex `i` and vertex `j`.

  • If there is an edge between vertex `i` and `j`, then `A[i][j] = 1`.
  • Otherwise, `A[i][j] = 0`.

For the given graph (a complete graph K₄), which has 4 vertices (let’s assume 1, 2, 3, 4), and every vertex is connected to every other vertex.


Adjacency Matrix:

 1 2 3 4 1[0 1 1 1] 2[1 0 1 1] 3[1 1 0 1] 4[1 1 1 0]

This matrix is symmetric because the graph is undirected. (c) B-Trees B-Tree: A B-tree is a self-balancing search tree designed to minimize search times for data stored on secondary storage devices like disks. Unlike binary search trees, nodes of a B-tree can have more than two children. Properties of a B-Tree:

  • All leaf nodes are at the same level.
  • A B-tree is defined by a minimum degree ‘t’ (t ≥ 2).
  • Every node except the root must have at least `t-1` keys. The root may have at least 1 key.
  • Every node can have at most `2t-1` keys.
  • An internal node has one more child than its number of keys.

These properties ensure that the tree remains balanced and relatively shallow, thus reducing the number of disk accesses. Applications of B-Trees: B-trees are widely used in systems that need to read and write large amounts of data.

  • Database Systems: Almost all modern databases (e.g., Oracle, MySQL, PostgreSQL) use B-trees or their variants (like B+ trees) to implement indexes on tables for fast data retrieval.
  • File Systems: Many file systems (e.g., NTFS, HFS+, JFS) use B-trees to efficiently manage and locate files and directories.
  • Searching in Large Datasets: In any application where data resides on disk and needs to be searched quickly, B-trees are a suitable choice.

Q5. (a) What is AVL tree ? Explain insertion of a node into an AVL tree. (b) Write binary search algorithm. (c) What is spanning tree ? Write and explain Prim’s algorithm to find minimum cost spanning tree. Also, write the applications of spanning tree.

Ans. (a) AVL Tree AVL Tree: An AVL tree (named after its inventors Adelson-Velsky and Landis) is a self-balancing Binary Search Tree (BST) . In it, for any node, the difference between the heights of the left and right subtrees cannot be more than 1. This property is measured by the Balance Factor . Balance Factor = height(left subtree) – height(right subtree) Every node in an AVL tree must have a balance factor of -1, 0, or 1. Insertion of a Node into an AVL Tree: The process of inserting a node into an AVL tree involves two stages: 1. Standard BST Insertion: First, the new node is inserted in the same way as in a standard Binary Search Tree. 2. Rebalancing: After insertion, we trace the path back from the inserted node to the root. For each node on this path, we check its balance factor. If a node becomes unbalanced (balance factor is not -1, 0, or 1), a rotation is performed to rebalance the tree. There are four types of imbalances and corresponding rotations:

  • Left-Left (LL) Case: The new node is inserted into the left subtree of the left child of the unbalanced node ‘z’. This is fixed by a single Right Rotation .
  • Right-Right (RR) Case: The new node is inserted into the right subtree of the right child of ‘z’. This is fixed by a single Left Rotation .
  • Left-Right (LR) Case: The new node is inserted into the right subtree of the left child of ‘z’. This is fixed by a Left Rotation followed by a Right Rotation (a double rotation ).
  • Right-Left (RL) Case: The new node is inserted into the left subtree of the right child of ‘z’. This is fixed by a Right Rotation followed by a Left Rotation (a double rotation ).

These rotations rebalance the tree’s height while preserving the BST property.


(b) Binary Search Algorithm

Binary search is an efficient algorithm for finding a value in a

sorted array

. It works by repeatedly dividing the search interval in half.


Algorithm:

1. Compare the target value with the middle element of the array.

2. If the target value matches the middle element, return its index.

3. If the target value is less than the middle element, continue the search in the lower half (to the left).

4. If the target value is greater than the middle element, continue the search in the upper half (to the right).

5. This process is repeated until the value is found or the interval is empty.


Iterative Algorithm in C-like language:

int binarySearch(int arr[], int size, int key) { int left = 0; int right = size - 1;

while (left <= right) { // Calculate mid to avoid overflow int mid = left + (right - left) / 2;

// Check if key is present at mid if (arr[mid] == key) { return mid; // Element found }

// If key is greater, ignore left half if (arr[mid] < key) { left = mid + 1; } // If key is smaller, ignore right half else { right = mid - 1; } }

// If we reach here, then element was not present return -1;}

The time complexity of binary search is

O(log n)

, making it very fast for large datasets.


(c) Spanning Tree and Prim’s Algorithm

Spanning Tree:

A spanning tree of a connected, undirected graph G is a subgraph that is a tree and includes all the vertices of G. It has the minimum possible number of edges that connect all vertices, meaning it has no cycles.


Minimum Cost Spanning Tree (MST):

For a weighted graph, a Minimum Cost Spanning Tree (MST) is a spanning tree whose total weight (the sum of the weights of all its edges) is less than or equal to the weight of every other spanning tree.


Prim’s Algorithm:

Prim’s algorithm is a greedy algorithm for finding an MST. It grows the tree starting from one vertex, and at each step, it adds the cheapest possible edge that connects a vertex already in the tree to one that is not yet in the tree.


Steps of the Algorithm:

1. Create an MST set that is initially empty.

2. Create a `key` array to assign to all vertices, storing the weight of the edge that connects the vertex to the MST. Initialize all keys to infinity and the key of the first vertex to 0.

3. Create a `parent` array that will construct the MST.

4. While not all vertices are included in the MST set:

a. Pick a vertex `u` not in the MST set that has the minimum key value.

b. Add `u` to the MST set.

c. For all adjacent vertices `v` of `u`, if the weight of edge `(u, v)` is less than the current key of `v`, update the key of `v` to the weight of edge `(u, v)` and set the parent of `v` as `u`.


Applications of Spanning Tree:

  • Network Design: In designing computer and telecommunication networks, such as connecting cities with cables, fiber optics, or roads with minimum cost.
  • Cluster Analysis: For grouping data points into clusters.
  • Circuit Design: For connecting pins on a circuit board with the minimum length of wire.
  • Approximation Algorithms: In finding approximate solutions for NP-hard problems like the Traveling Salesman Problem.


Download IGNOU previous Year Question paper download PDFs for MCS-208 to improve your preparation. These ignou solved question paper IGNOU Previous Year Question paper solved PDF in Hindi and English help you understand the exam pattern and score better.

  • IGNOU Previous Year Solved Question Papers (All Courses)

Thanks!

Share this:

  • Share on Facebook (Opens in new window) Facebook
  • Share on X (Opens in new window) X
  • More
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Telegram (Opens in new window) Telegram
  • Print (Opens in new window) Print
  • Email a link to a friend (Opens in new window) Email

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

लेटेस्ट अपडेट पायें

Telegram Telegram Channel Join Now
Facebook FaceBook Page Follow Us
YouTube Youtube Channel Subscribe
WhatsApp WhatsApp Channel Join Now

Search

Recent Posts

  • MSU Baroda Study Materials Free Download
  • Bhavnagar University Study Materials Free Download
  • Kachchh University Study Materials Free Download
  • BMTU Study Materials Free Download
  • SGGU Study Materials Free Download

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,611 other subscribers

Categories

  • 10th model paper (3)
  • bed books (3)
  • Bihar Board Model Paper (7)
  • Bihar Jobs (1)
  • cg board model paper (1)
  • DELED Books (1)
  • English Posts (1)
  • Essay (1)
  • Exam Prep (9)
  • G.K quiz in hindi (7)
  • General Knowledge in hindi (सामान्य ज्ञान) (24)
  • gk 2018 in hindi (12)
  • GK 2020 (2)
  • GK HINDI 2019 (9)
  • gk pdf download (16)
  • High school science notes in Hindi (3)
  • IERT (3)
  • MODEL PAPER (30)
  • Motivational quotes in hindi (1)
  • mp board model paper (4)
  • My Thoughts (Thoughts by Sachin Yadav) (1)
  • Navy (2)
  • NCERT Books in hindi free download (1)
  • Police (2)
  • Polytechnic (6)
  • Pratiyogita Darpan 2019 (2)
  • RBSE Model Papers (2)
  • School Books (1)
  • SSC GENERAL KNOWLEDGE (7)
  • StudyTrac (69)
  • Uncategorized (54)
  • University Books (106)
  • University Question Papers (153)
  • University Study Materials (89)
  • University Syllabus (144)
  • UP Board Books (5)
  • up board model paper (10)
  • Up board model papers (16)
  • UPSC Notes (3)
  • Uttar Pradesh Jobs (2)
  • रेलवे (7)
  • सामान्य हिन्दी (3)

Footer

University Books

University Study Materials (Books and Notes) in PDF Format in Hindi and English languages.

Click here to download.

University Question Papers

University Previous Year Question Papers and Sample Papers in PDF Format for all Courses.

Click here to download.

University Syllabus

Universities Syllabus in PDF Format in the English and Hindi languages for all courses.

Click here to download.

Copyright © 2026 ·GKPAD by S.K Yadav | Disclaimer