प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
What is the time complexity of the loop: for (i = 1; i * i <= n; i++) count++; ?
सही उत्तर: ख) O(sqrt(n))
The loop stops when i exceeds the square root of n, so it runs about sqrt(n) times.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the time complexity of the loop: while (n > 1) n = n / 3; ?
सही उत्तर: क) O(log n)
n is divided by 3 each time, so the loop runs about log base 3 of n times, which is O(log n).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
A recursive function does a constant amount of work and then calls itself once on a problem smaller by one. Its running time on input size n is:
सही उत्तर: घ) O(n)
This gives T(n) = T(n - 1) + c, which unrolls to about n times c, i.e. linear time.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
The keys 50, 40, 30, 60, 70, 45 are inserted in that order into an empty binary search tree. What is its postorder traversal?
सही उत्तर: ग) 30 45 40 70 60 50
The tree has root 50, left child 40 (children 30 and 45) and right child 60 (right child 70); postorder visits left, right, root.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Using a stack, evaluate the reverse Polish expression 6 2 / 3 - 4 2 * + . The result is:
सही उत्तर: ख) 8
6 / 2 = 3, 3 - 3 = 0, 4 * 2 = 8, and 0 + 8 = 8.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Which postfix expression corresponds to the infix expression A + B * C - D / E?
सही उत्तर: क) A B C * + D E / -
B * C and D / E are done first because of precedence; then A is added to B*C and D/E is subtracted, giving A B C * + D E / -.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
The numbers 1, 2 and 3 are pushed onto an empty stack in that order, and pops may be done at any time between the pushes. Which pop sequence is impossible?
सही उत्तर: घ) 3 1 2
To pop 3 first, 1 and 2 must already be on the stack with 2 on top, so 1 cannot come out before 2.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Running this in Python 3 displays which output? print(repr('Python'[10:]))
सही उत्तर: ग) ''
Slicing beyond the end of a sequence does not raise an error; it simply returns an empty string.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python: try: [1][2] / except IndexError: print('I') / except Exception: print('E'). What is printed?
सही उत्तर: ख) I
Index 2 does not exist, so IndexError is raised; only the first matching except clause runs, printing I.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python, class A's __init__ sets self.v = 1. What is printed by: a = A(); a.v += 1; b = A(); print(a.v + b.v) ?
सही उत्तर: क) 3
v is an instance attribute, so each object has its own copy: a.v is 2 and b.v is 1, giving 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।