How an algorithm with linear time complexity behaves

Describe how an algorithm with linear time complexity behaves.
Describe how an algorithm with exponential time complexity behaves.
Question 2 [7 pts]
Describe time and space complexity of an algorithm. Explain the relationship between them.
Question 3 [7 pts]
Describe polynomial time (P) and nondeterministic polynomial time (NP) algorithms. What is the difference between them? Give examples to each.
Question 4 [7 pts]
What is an NP-complete problem? Describe the factoring problem that the RSA algorithm is based on.
Question 5 [7 pts]
Which of the following statements are correct?
• Quadratic time complexity is a type of polynomial complexity
• Superpolynomial time complex algorithms are harder to solve than algorithms with exponential time complexity.
• Trying to find the 128-bit key of a cipher text encrypted with AES is a problem with exponential complexity
• Factoring problem that RSA is using is not probably an NP-complete problem.

Full Answer Section

      This algorithm has linear time complexity because the number of times the algorithm iterates over the list is directly proportional to the size of the list. For example, if the list has 10 numbers, then the algorithm will iterate over the list 10 times. If the list has 100 numbers, then the algorithm will iterate over the list 100 times. Exponential time complexity An algorithm with exponential time complexity has an execution time that grows exponentially with the input size. This means that the time it takes for the algorithm to run increases at a much faster rate than the size of the input. Example: Consider a simple algorithm for solving the Traveling Salesman Problem (TSP). The TSP is a problem where a salesperson must visit a set of cities in a specific order, such that they visit each city exactly once and return to their starting city at the end. The goal is to find the shortest possible route for the salesperson to take. One way to solve the TSP is to use a brute-force algorithm. A brute-force algorithm tries every possible solution to the problem and then returns the best solution. For the TSP, a brute-force algorithm would try every possible permutation of the cities. This algorithm has exponential time complexity because the number of possible solutions to the TSP grows exponentially with the number of cities. For example, if there are 10 cities, then there are 10! (10 factorial) possible solutions. This is equal to 3,628,800. If there are 100 cities, then there are 100! possible solutions. This is a number that is so large that it cannot be represented on a computer. Conclusion Algorithms with linear time complexity are generally more efficient than algorithms with exponential time complexity. This is because algorithms with linear time complexity have an execution time that grows at a slower rate than the input size. However, there are some problems that cannot be solved by an algorithm with linear time complexity. For example, the TSP is a problem that is NP-hard, which means that it is unlikely that there is an algorithm with polynomial time complexity for solving the problem. In these cases, it may be necessary to use an algorithm with exponential time complexity. However, it is important to be aware of the limitations of these algorithms and to use them only when necessary.  

Sample Answer

   

Linear time complexity

An algorithm with linear time complexity has an execution time that grows linearly with the input size. This means that the time it takes for the algorithm to run increases at the same rate as the size of the input.

Example: Consider a simple algorithm for finding the largest number in a list of numbers. The algorithm works by iterating over the list and comparing each number to the current largest number. If a number is larger than the current largest number, then the algorithm updates the current largest number to be that number.