प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
Trace this C fragment and give its output: int x = 0xA; printf("%d", x ^ 6);
सही उत्तर: ग) 12
0xA is 10 (1010 in binary) and 6 is 0110; XOR gives 1100, which is 12.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Trace this C fragment and give its output: int a = 2, b = 3; printf("%d", a * b % 4 + b / a);
सही उत्तर: ख) 3
a * b % 4 = 6 % 4 = 2 and b / a = 3 / 2 = 1 (integer division), so the result is 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Trace this C fragment and give its output: printf("%d", 3 + 4 % 3 * 2 - 1);
सही उत्तर: क) 4
% and * have higher precedence than + and - and group left to right: 4 % 3 = 1, 1 * 2 = 2, then 3 + 2 - 1 = 4.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
The Sieve of Eratosthenes is an algorithm for:
सही उत्तर: ख) finding all prime numbers up to a given limit
It repeatedly crosses out multiples of each prime, leaving only primes up to the limit.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Inserting the keys 10, 20, 30, 40, 50 in that order into an empty (unbalanced) binary search tree produces:
सही उत्तर: क) a right-skewed tree that behaves like a linked list
Each new key is larger than all previous ones, so it always becomes the right child, giving a chain with O(n) search time.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
The keys 30, 10, 40, 5, 20 are inserted in that order into an empty binary search tree. What is its level-order traversal?
सही उत्तर: घ) 30 10 40 5 20
Level by level: root 30; then 10 and 40; then 5 and 20 (children of 10).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
LSD radix sort sorts numbers digit by digit, starting from the least significant digit; for the result to be correct, the sort used on each digit must be:
सही उत्तर: ख) stable
Each pass must keep the order produced by earlier (less significant) digits for equal keys, so the per-digit sort must be stable, as counting sort is.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
If the Fibonacci function stores (memoises) each computed value, the time to compute fib(n) becomes:
सही उत्तर: घ) O(n)
With memoisation each fib(k) for k = 0 to n is computed only once, so the time is linear.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Using Kadane's algorithm, what is the maximum sum of a contiguous subarray of [-2, 1, -3, 4, -1, 2, 1, -5, 4]?
सही उत्तर: ग) 6
The best subarray is [4, -1, 2, 1], whose sum is 6.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
If the key being searched is equally likely to be any of the n elements, the average number of comparisons in a successful linear search is:
सही उत्तर: क) (n + 1) / 2
The key is at position i with probability 1/n and needs i comparisons, so the average is (1 + 2 + ... + n)/n = (n + 1)/2.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।