Introduction to Algorithms: Concepts, Representation, and Analysis - Prof. Bui, Lab Reports of Database Programming

em nop bai thay oi, thay kiem tra giup em

Typology: Lab Reports

2015/2016

Uploaded on 08/18/2021

bui-anh-1
bui-anh-1 🇻🇳

4 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1) What is Algorithms?
The algorithm is a step-by-step process that defines a series of instructions that are
executed in a specific order to achieve the desired result. Algorithms are generally created
independently of the underlying languages, ie an algorithm can be implemented in more
than one programming language.
2) How to present Algorithms?
Problem: Solving MAX(a,b)
Natural Language:
Declare two variable a and b. Using if statement to check that if a >b then a is biggest
otherwise b is biggest
Flow Chart:
Pseudo Code:
Step 1: Start.
Step 2: Read a, b . / * a, b two numbers */
Step 3: If a>b then /*Checking */
Display “a is the biggest number”.
Otherwise.
Display “b is the biggest number”.
3) What is asymtotic analysic?
Asymptotic analysis is the process of calculating the running time of an algorithm in
mathematical units to find the program’s limitations, or “run-time performance.” The
pf3
pf4

Partial preview of the text

Download Introduction to Algorithms: Concepts, Representation, and Analysis - Prof. Bui and more Lab Reports Database Programming in PDF only on Docsity!

  1. What is Algorithms? The algorithm is a step-by-step process that defines a series of instructions that are executed in a specific order to achieve the desired result. Algorithms are generally created independently of the underlying languages, ie an algorithm can be implemented in more than one programming language.
  2. How to present Algorithms? Problem: Solving MAX(a,b) Natural Language: Declare two variable a and b. Using if statement to check that if a >b then a is biggest otherwise b is biggest Flow Chart: Pseudo Code: Step 1: Start. Step 2: Read a, b. / * a, b two numbers / Step 3: If a>b then /Checking */ Display “a is the biggest number”. Otherwise. Display “b is the biggest number”.
  3. What is asymtotic analysic? Asymptotic analysis is the process of calculating the running time of an algorithm in mathematical units to find the program’s limitations, or “run-time performance.” The

goal is to determine the best case, worst case and average case time required to execute a given task. Asymptotic analysis is input bound i.e., if there's no input to the algorithm, it is concluded to work in a constant time. Other than the "input" all other factors are considered constant. The Asymptotic Notations:Θ Notation: This often “theta” notation. This notation gives upper bound as well as lower bound of an algorithm. Θ (f(n)) = {g(n): there exist positive constants c1, c2 and n0 such that 0 <= c1f(n) <= g(n) <= c2f(n) for all n >= n0} f(n) gives the exact asymptotic behavior of g(n) with changing inputs i.e. g(n) is always between c1f(n) and c2f(n). If we use this notation then, o Best Case- Θ(n) o Worst case- Θ(n3)  Big O Notation: This notation gives an upper bound of an algorithm, that bounds the function from above. O(f(n)) = { g(n): there exist positive constants c and n0 such that 0 <= g(n) <= cf(n) for all n >= n0} For most of the algorithms, we only have an upper bound.Thus , we use this notation. This upper bound can also be seen as tight upper bound as it is inclusive of the boundary values.  Ω (Omega) Notation: This Notation will provides the lower bound of an algorithm. Thus, it is always used to provide the best case solution to a problem. Consider a function g(n) that represent run-time behavior of an algorithm where n is the number of inputs. If there exist a function f(n) such as Ω (f(n)) = {g(n): there exist positive constants c and n0 such that 0 <= cf(n) <= g(n) for all n >= n0} then f(n) is said to be lower bound for g(n). Thus f(n) gives the best case run-time for the algorithm g(n). This can also be seen as tight lower bound values as it is inclusive of lower boundary values.

  1. What is trade-off? Tradeoff is a situation where one thing increases and another thing decreases. It is a way to solve a problem in:  Either in less time and by using more space, or  In very little space by spending a long amount of time. The best Algorithm is that which helps to solve a problem that requires less space in memory and also takes less time to generate the output. But in general, it is not always possible to achieve both of these conditions at the same time. The most common condition is an algorithm using a lookup table. This means that the answers to some questions for every possible value can be written down. One way of solving this problem is to write down the entire lookup table, which will let you find answers very quickly but will use a lot of space. Another way is to calculate the answers without writing down anything, which uses very little space, but might take a long time. Therefore, the more time-efficient algorithms you have, that would be less space-efficient.