प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
Quicksort with the Lomuto partition scheme uses the last element as pivot. After partitioning [3, 8, 2, 5, 1, 4], at which index (0-based) does the pivot end up?
सही उत्तर: घ) 3
Three elements (3, 2, 1) are smaller than the pivot 4, so it is placed just after them at index 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is printed by the C code: int n = 10, i, j, c = 0; for (i = 0; i < n; i++) for (j = 0; j < i; j++) c++; printf("%d", c); ?
सही उत्तर: घ) 45
The inner loop runs 0 + 1 + ... + 9 times, which is n(n - 1)/2 = 45.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the time complexity of: for (i = 1; i < n; i *= 2) for (j = 0; j < i; j++) count++; ?
सही उत्तर: क) O(n)
The inner loop runs 1 + 2 + 4 + ... up to less than n times, a geometric series whose sum is less than 2n.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Keys 12, 7, 22 and 3 are inserted into a hash table of size 5 using h(k) = k mod 5 with separate chaining. What is the length of the longest chain?
सही उत्तर: ख) 3
12, 7 and 22 all give remainder 2, so they share one chain; 3 goes to slot 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
A graph has edges A-B 1, B-C 2, A-C 3, C-D 4 and B-D 5. What is the total weight of its minimum spanning tree?
सही उत्तर: ग) 7
Kruskal's algorithm takes A-B (1) and B-C (2), rejects A-C (it would form a cycle), and takes C-D (4): 1 + 2 + 4 = 7.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
A weighted graph has edges A-B 4, A-C 1, C-B 2, B-D 1 and C-D 5. What is the length of the shortest path from A to D?
सही उत्तर: ग) 4
The path A-C-B-D has length 1 + 2 + 1 = 4, shorter than A-B-D (5) or A-C-D (6).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
An undirected graph has edges 1-2, 1-3, 2-4, 3-4 and 4-5. A depth-first search starts at vertex 1 and always visits the smallest-numbered unvisited neighbour first. In what order are the vertices visited?
सही उत्तर: घ) 1 2 4 3 5
From 1 go to 2, from 2 to 4, from 4 to its smallest unvisited neighbour 3; 3 has no new neighbours, so backtrack to 4 and visit 5.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
How many structurally different binary search trees can be built from the three keys 1, 2 and 3?
सही उत्तर: क) 5
The count is the Catalan number C3 = 5 (two trees with root 1, one with root 2, two with root 3).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
A binary tree has preorder traversal A B D E C and inorder traversal D B E A C. What is its postorder traversal?
सही उत्तर: ख) D E B C A
A is the root; from the inorder, D B E is the left subtree (root B, children D and E) and C is the right subtree; postorder is D E B C A.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
The keys 40, 20, 60, 10, 30, 50 are inserted in that order into an empty binary search tree. What is its postorder traversal?
सही उत्तर: ख) 10 30 20 50 60 40
The root is 40 with left subtree 20 (children 10, 30) and right subtree 60 (left child 50); postorder visits left, right, then root.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।