
Learn core concepts, essential formulas, and attempt practice questions designed on the latest TCS NQT testing patterns.
What is time complexity of searching in a sorted array using Binary Search?
Correct Answer: A) O(log N)
Step-by-step Solution: Binary Search halves the search space in each step, leading to logarithmic O(log N) time complexity.
What is time complexity of: for(int i=0; i<n; i++) for(int j=0; j<n; j++) print("*");?
Correct Answer: A) O(N^2)
Step-by-step Solution: An outer loop running N times wraps an inner loop running N times. Total operations = N * N = N^2.
Avoid assuming complexity from loop counts. Always analyze how variables decrement/increment.