13 Lecture
CS101
Midterm & Final Term Short Notes
Algorithms
An algorithm can be thought of as a recipe or set of instructions that a computer follows in order to complete a task. For example, an algorithm might be used to sort a list of names in alphabetical order, find the shortest route between two cit
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
Which of the following is not a type of algorithm? A) Sorting algorithm B) Search algorithm C) Machine learning algorithm D) Linear algorithm Answer: D) Linear algorithm
Which algorithm is used to find the shortest route between two cities? A) Bubble sort B) Quick sort C) Gradient descent D) Dijkstra's algorithm Answer: D) Dijkstra's algorithm
Which algorithm is used to analyze and learn from data in order to make predictions or decisions? A) Sorting algorithm B) Search algorithm C) Optimization algorithm D) Machine learning algorithm Answer: D) Machine learning algorithm
Which factor is not important to consider when designing an algorithm? A) Efficiency B) Accuracy C) Scalability D) Complexity Answer: D) Complexity
Which sorting algorithm has the worst time complexity? A) Quick sort B) Bubble sort C) Insertion sort D) Selection sort Answer: B) Bubble sort
Which search algorithm is more efficient for a sorted data set? A) Linear search B) Binary search C) Hash-based search D) All of the above Answer: B) Binary search
Which optimization algorithm is inspired by the process of cooling metals? A) Gradient descent B) Simulated annealing C) Genetic algorithms D) Particle swarm optimization Answer: B) Simulated annealing
Which machine learning algorithm is based on decision trees? A) Neural networks B) Support vector machines C) Random forests D) K-means clustering Answer: C) Random forests
Which factor is most important to consider in real-time applications? A) Efficiency B) Accuracy C) Scalability D) Complexity Answer: A) Efficiency
Which algorithm is used to find the optimal solution for a problem by evaluating all possible solutions? A) Brute force algorithm B) Greedy algorithm C) Dynamic programming D) Hill climbing algorithm Answer: A) Brute force algorithm
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is an algorithm? Answer: An algorithm is a set of well-defined instructions or rules to solve a problem or accomplish a specific task.
What is the difference between a linear search and a binary search algorithm? Answer: A linear search algorithm checks each element in a list sequentially until the desired element is found or the end of the list is reached. A binary search algorithm, on the other hand, starts at the middle of a sorted list and divides the list in half repeatedly until the desired element is found or determined to not exist.
What is the time complexity of an algorithm, and why is it important? Answer: The time complexity of an algorithm is the amount of time it takes to run as a function of the input size. It is important because it helps to determine the efficiency and scalability of the algorithm.
What is a sorting algorithm, and give an example? Answer: A sorting algorithm is an algorithm that arranges elements in a list or array in a specific order. An example of a sorting algorithm is the quicksort algorithm.
What is a greedy algorithm, and when is it used? Answer: A greedy algorithm is an algorithm that makes the locally optimal choice at each step with the hope of finding a global optimum. It is used when a problem can be divided into subproblems and the solution to each subproblem does not affect the solution to other subproblems.
What is a recursive algorithm, and give an example? Answer: A recursive algorithm is an algorithm that calls itself to solve subproblems. An example of a recursive algorithm is the factorial function.
What is a divide and conquer algorithm, and give an example? Answer: A divide and conquer algorithm is an algorithm that breaks a problem down into smaller subproblems, solves each subproblem separately, and then combines the solutions to the subproblems to solve the original problem. An example of a divide and conquer algorithm is the merge sort algorithm.
What is a dynamic programming algorithm, and give an example? Answer: A dynamic programming algorithm is an algorithm that solves a problem by breaking it down into smaller subproblems, solving each subproblem only once, and storing the solutions to subproblems to avoid redundant computations. An example of a dynamic programming algorithm is the Fibonacci sequence.
What is a heuristic algorithm, and give an example? Answer: A heuristic algorithm is an algorithm that uses a rule of thumb or an approximation to find a solution quickly, without guaranteeing the optimal solution. An example of a heuristic algorithm is the nearest neighbor algorithm.
What is an optimization algorithm, and give an example? Answer: An optimization algorithm is an algorithm that finds the best solution to a problem with given constraints. An example of an optimization algorithm is the gradient descent algorithm used in machine learning.