Docsity

Programming and Problem Solving Quiz: A Comprehensive Assessment of Fundamental Concepts -, Quizzes of Programming Languages

Toggle sidebar
bg1
Programing and Problem Solving Quiz
1. What is the time complexity of the following code snippet?
python
Copy
for i in range ( n ):
for j in range ( i , n ):
k = 1
while k < n :
k *= 2
Options:
A) O(n)
B) O(n²)
C) O(n² log n)
D) O(n³)
2. Which of the following is NOT a valid heuristic for the A search algorithm?*
Options:
A) Manhattan Distance
B) Euclidean Distance
C) Hamming Distance
D) Breadth-First Distance
3. What does the following dynamic programming recurrence relation solve?
pf3
pf4

Partial preview of the text

Download Programming and Problem Solving Quiz: A Comprehensive Assessment of Fundamental Concepts - and more Quizzes Programming Languages in PDF only on Docsity!

Programing and Problem Solving Quiz

  1. What is the time complexity of the following code snippet? python Copy for i in range( n ): for j in range( i , n ): k = 1 while k < n : k _= 2_* Options: A) O(n) B) O(n²) C) O(n² log n) D) O(n³)
  2. Which of the following is NOT a valid heuristic for the A search algorithm?* Options: A) Manhattan Distance B) Euclidean Distance C) Hamming Distance D) Breadth-First Distance
  3. What does the following dynamic programming recurrence relation solve?

dp[i][j] = dp[i-1][j] + dp[i][j-1] Options: A) Longest Common Subsequence B) Number of ways to reach bottom-right in a grid C) Knapsack problem D) Fibonacci sequence

  1. Which data structure is most efficient for implementing a priority queue with O(1) insertion and O(log n) extract-min? Options: A) Binary Search Tree B) Hash Table C) Binary Heap D) Linked List
  2. What is the output of the following Python code? python Copy def func( x ): if x == 0 : return 0 return x + func ( x - 1 ) print( func ( 5 )) Options: A) 10 B) 15
  1. What is the output of the following C++ code? cpp Copy #include using namespace std ; int main() { int x = 5 ; int ** p = & x ; cout _<< (_ p )++ << " " << x ; return 0 ; } Options: A) 5 5 B) 5 6 C) 6 6 D) Undefined Behavior