Coding Fundamentals and Logic Flashcards
7 cards from real Mettl practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 Coding Fundamentals and Logic flashcards as text
What is the output of: print(3 ** 2 % 5)?
Answer: 4
3**2 = 9, and 9 % 5 = 4.
Which Boolean expression is equivalent to NOT (A OR B)?
Answer: NOT A AND NOT B
By De Morgan's Law, NOT(A OR B) = NOT A AND NOT B.
What is the worst-case space complexity of a recursive function that calls itself n times?
Answer: O(n)
Each recursive call adds a frame to the call stack, consuming O(n) space in the worst case.
A function takes an array and reverses it in-place. What is the minimum number of swaps needed to reverse an array of length 6?
Answer: 3
Reversing an array of length n requires ⌊n/2⌋ swaps; for n=6 that is 3.
Which of the following is NOT a characteristic of object-oriented programming?
Answer: Pointer arithmetic
Pointer arithmetic is a low-level procedural concept, not a pillar of OOP.
What does the modulo operator (%) return for the expression -7 % 3 in most languages?
Answer: -1
In most languages, -7 % 3 = -1 because -7 = (-2)*3 + (-1).
Which traversal of a binary search tree visits nodes in ascending sorted order?
Answer: In-order
In-order traversal (left → root → right) of a BST visits keys in sorted ascending order.