36 Lecture
CS301
Midterm & Final Term Short Notes
Running Time Analysis
Running time analysis is the process of evaluating the efficiency of an algorithm by determining the time it takes to execute as a function of its input size. This analysis is typically done using asymptotic notation, such as big O notation, whi
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is the time complexity of a linear search algorithm? a) O(n) b) O(log n) c) O(n^2) d) O(1) Answer: a) O(n)
Which of the following is not an asymptotic notation used for running time analysis? a) Big O notation b) Theta notation c) Little O notation d) Epsilon notation Answer: d) Epsilon notation
What is the time complexity of a binary search algorithm? a) O(n) b) O(log n) c) O(n^2) d) O(1) Answer: b) O(log n)
Which of the following is a constant time complexity algorithm? a) Bubble sort b) Insertion sort c) Quick sort d) Counting sort Answer: d) Counting sort
Which of the following is an example of an exponential time complexity algorithm? a) Merge sort b) Quick sort c) Bubble sort d) Traveling salesman problem Answer: d) Traveling salesman problem
Which of the following is not a factor that can affect the running time of an algorithm? a) Input size b) Memory usage c) Hardware configuration d) Implementation details Answer: b) Memory usage
What is the time complexity of a worst-case scenario for a sorting algorithm? a) O(n) b) O(log n) c) O(n^2) d) O(1) Answer: c) O(n^2)
What is the time complexity of a best-case scenario for a sorting algorithm? a) O(n) b) O(log n) c) O(n^2) d) O(1) Answer: a) O(n)
Which of the following is an example of a logarithmic time complexity algorithm? a) Merge sort b) Quick sort c) Binary search d) Bubble sort Answer: c) Binary search
Which of the following is an example of a quadratic time complexity algorithm? a) Merge sort b) Quick sort c) Insertion sort d) Heap sort Answer: c) Insertion sort
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is running time analysis? Answer: Running time analysis is the process of evaluating the efficiency of an algorithm by determining the time it takes to execute as a function of its input size.
What is the difference between best-case and worst-case time complexity? Answer: Best-case time complexity refers to the minimum time required by an algorithm to complete its task on a given input, whereas worst-case time complexity refers to the maximum time required by an algorithm to complete its task on a given input.
What is the purpose of asymptotic notation in running time analysis? Answer: Asymptotic notation, such as big O notation, provides an upper bound on the growth rate of an algorithm's running time. It is used to describe how the running time of an algorithm increases as the size of its input increases.
What is the time complexity of an algorithm that takes constant time to execute? Answer: An algorithm that takes constant time to execute has a time complexity of O(1).
What is the time complexity of an algorithm that executes a loop n times, where n is the size of the input? Answer: An algorithm that executes a loop n times, where n is the size of the input, has a time complexity of O(n).
What is the difference between logarithmic and linear time complexity? Answer: Logarithmic time complexity refers to an algorithm whose running time increases logarithmically with the size of its input, while linear time complexity refers to an algorithm whose running time increases linearly with the size of its input.
What is the difference between average-case and worst-case time complexity? Answer: Average-case time complexity refers to the expected time required by an algorithm to complete its task on a given input, while worst-case time complexity refers to the maximum time required by an algorithm to complete its task on a given input.
What is the purpose of analyzing the running time of an algorithm? Answer: The purpose of analyzing the running time of an algorithm is to identify the most efficient algorithm to solve a problem, taking into account the size of the input.
What is the time complexity of an algorithm that executes a loop within a loop, where both loops iterate n times? Answer: An algorithm that executes a loop within a loop, where both loops iterate n times, has a time complexity of O(n^2).
Can the running time of an algorithm be measured in seconds? Answer: The running time of an algorithm can be measured in seconds, but it is not a useful metric for comparing the efficiency of algorithms, as it depends on the hardware configuration of the computer on which the algorithm is executed. Asymptotic notation is a more useful metric for comparing the efficiency of algorithms.