EIT Computer Science and Numerical Methods 1 ā Questions and Answers
Question 1: What is the time complexity of binary search on a sorted array of n elements?
- O(n)
- O(n²)
- O(log n) (Correct answer)
- O(1)
Correct answer: O(log n)
Binary search repeatedly halves the search space, resulting in a logarithmic number of comparisons ā O(log n).
Question 2: The Newton-Raphson iterative formula for finding the root of f(x) = 0 is:
- x_(n+1) = x_n + f(x_n)/f'(x_n)
- x_(n+1) = x_n - f(x_n)/f'(x_n) (Correct answer)
- x_(n+1) = [x_n + f(x_n)] / 2
- x_(n+1) = x_n Ā· f'(x_n) - f(x_n)
Correct answer: x_(n+1) = x_n - f(x_n)/f'(x_n)
The Newton-Raphson method subtracts the ratio f(x_n)/f'(x_n) from the current estimate to converge toward the root.
Question 3: What is the decimal equivalent of the binary number 1101?
- 11
- 12
- 13 (Correct answer)
- 14
Correct answer: 13
1101 in binary equals 1Ć8 + 1Ć4 + 0Ć2 + 1Ć1 = 8 + 4 + 0 + 1 = 13.
Question 4: In numerical methods, the trapezoidal rule is used to approximate:
- The root of a function
- The derivative of a function at a point
- A definite integral (Correct answer)
- A system of linear equations
Correct answer: A definite integral
The trapezoidal rule approximates a definite integral by summing the areas of trapezoids formed under the curve.
Question 5: Which data structure follows the LIFO (Last In, First Out) access principle?
- Queue
- Linked List
- Hash Table
- Stack (Correct answer)
Correct answer: Stack
A stack removes elements in the reverse order they were added, so the last element pushed is the first one popped.
Question 6: The average-case time complexity of merge sort is:
- O(n²)
- O(n log n) (Correct answer)
- O(log n)
- O(n)
Correct answer: O(n log n)
Merge sort divides the array into halves (log n levels) and merges them in O(n) per level, giving O(n log n) overall.
Question 7: In programming, recursion is best described as:
- A loop that iterates until a condition is met
- A function that calls itself directly or indirectly (Correct answer)
- Two functions sharing the same memory variable
- A program using multiple threads simultaneously
Correct answer: A function that calls itself directly or indirectly
Recursion occurs when a function invokes itself with a modified argument, progressing toward a base case that terminates the calls.
What is the time complexity of binary search on a sorted array of n elements?