Docsity

Algorithm Analysis: Understanding the Complexity of Computing Algorithms, Exercises of Data Structures and Algorithms

Partial preview of the text

Download Algorithm Analysis: Understanding the Complexity of Computing Algorithms and more Exercises Data Structures and Algorithms in PDF only on Docsity!

Algorithm Analysis

INSTRUCTIONS FOR USE

Definition (Tú)

◦ In essence, algorithms are

simply a series of

instructions that are

followed, step by step, to

do something useful or

solve a problem.

◦ You could consider a cake

recipe an algorithm for

making a cake, for

example.

Definition(Tú)

◦ In computing, algorithms provide

computers with a successive guide to

completing actions. They’re comprised

of a precise list of instructions that

outline exactly how to complete a task.

Algorithmic Performance(minh)

◦ The performance of an algorithm is a

process of making an evaluative

judgment about algorithms.

◦ Performance of an algorithm means

predicting the resources which are

required for an algorithm to perform its

task.

Algorithmic Performance

Performance analysis of an algorithm is the process

of calculating the space and time required by that

algorithm. Performance analysis of an algorithm is

performed by using the following measures:

◦ Space required to complete the task of that

algorithm (Space Complexity). It includes

program space and data space

◦ Time required to complete the task of that

algorithm (Time Complexity)

Definition(dat)

  • (^) The analysis of algorithms is the process of

finding the computational complexity of

algorithms – the amount of time, storage, or

other resources needed to execute them.

Why Analyze an Algorithm?(dat)

◦ Why Analyze an Algorithm? The most

straightforward reason for analyzing an algorithm

is to discover its characteristics in order to

evaluate its suitability for various applications or

compare it with other algorithms for the same

application.

◦ Moreover, the analysis of an algorithm can help

us understand it better, and can suggest

informed improvements. Algorithms tend to

become shorter, simpler, and more elegant

during the analysis process.

General Rules for Estimation(huy)

  • (^) Loops: The running time of a for loop is at most the running time of the statements inside the for loop times the number of iterations.
  • (^) Nested loops: Analyze these insides out. The total running time of a statement inside a group of nested loops is the running time of the statement multiplied by the product of the sizes of all the loops.
  • (^) Consecutive statements: These just add.
  • (^) If/else: For the fragment if(condition) S1 else S2, the running time of an if/else statement is never more than the running time of the test plus the larger of the running times of S1 and S2.

Time and Space Complexity ◦ (^) Độ phức tạp thời gian của một thuật toán biểu thị lượng thời gian mà thuật toán yêu cầu để chạy đến khi hoàn thành. Yêu cầu về thời gian có thể được định nghĩa như một hàm số T , trong đó T có thể được đo bằng số bước, miễn là mỗi bước tiêu thụ thời gian không đổi. ◦ (^) Độ phức tạp không gian của một thuật toán biểu thị lượng không gian bộ nhớ mà thuật toán yêu cầu trong vòng đời của nó.

Space Complexity