Ip Unit 1 Modified
Ip Unit 1 Modified
The following are the some basic steps to solve the problems by computer.
After filtering all the solution, you have the best solution only. Then choose one of the best solution
After getting the best solution, implement that solution to solve a problem.
After implementing a best solution, Evaluate how much you solution solve the problem. If your
solution will not solve the problem then you can again start with Step 2.
Analysis of algorithms is the determination of the amount of time and space resources required to
execute it.
Omega notation: Represents the minimum running time of an algorithm, or the best-case complexity
f(n) = omega(g(n)), read as f of n is omega of g of n, iff (if and only if) positive constants c and
n0 exist such that f(n) >= cg(n) for all n, n >= n0.
Theta notation: Represents the upper and lower bound of the running time of an algorithm, or the
average-case complexity.
f(n) = Theta(g(n)), read as f of n is theta of g of n, iff (if and only if) positive constants c1, c2, and
n0 exist such that c1g(n) <=f(n) <= c2g(n) for all n, n >= n0.
Top-down Approach is a problem-solving method that breaks down a bigger problem into smaller,
less complex sub-problems and solving each sub-problem individually. Then break the sub problem into
tasks until they are directly solvable. Top-Down approach is also termed as breaking a bigger problem
into smaller problems and solving them individually in recursive manner. It is also known as “stepwise
refinement”. Top-Down Model is followed by structural programming languages like C, Fortran, etc.
Advantages
2. At each step of refinement, new sub-problem become less complex and easier to solve.
4. Breaking problems into parts allows more than one person to solve the problem.
4.What are Problem solving strategies. Explain Briefly.
Ans: There are typically two primary ways to approach problem-solving - "top-down approach"
Top-down approach
down into smaller parts. Thus, it uses the decomposition approach. This approach is generally used
The implementation of algorithm using top-down approach depends on the programming language
and platform. Top-down approach is generally used with documentation of module and debugging
code.
Bottom-up approach
Bottom-Up Approach is one in which the smaller problems are solved, and then these solved
problems are integrated to find the solution to a bigger problem. Therefore, it uses composition
approach.
It is generally used with object-oriented programming paradigm such as C++, Java, and Python.
When we want to develop a program using any programming language, we follow a sequence of steps.
These steps are called phases in program development. The program development life cycle is a set of
steps or phases that are used to develop a program in any programming language.
Generally, the program development life cycle contains 6 phases, they are as follows….
1. Problem Definition
In this phase, we define the problem statement and we decide the boundaries of the problem. In this
phase we need to understand the problem statement, what is our requirement, what should be the
output
of the problem solution. These are defined in this first phase of the program development life cycle.
2. Problem Analysis
In phase 2, we determine the requirements like variables, functions, etc. to solve the problem. That
means we gather the required resources to solve the problem defined in the problem definition phase.
3. Algorithm Development
During this phase, we develop a step by step procedure to solve the problem using the specification
given in the previous phase. This phase is very important for program development. That means we
This phase uses a programming language to write or implement the actual programming instructions for
the steps defined in the previous phase. In this phase, we construct the actual program. That means we
write the program to solve the given problem using programming languages like C, C++, Java, etc.
During this phase, we check whether the code written in the previous step is solving the specified
problem or not. That means we test the program whether it is solving the problem for various input data
values or not. We also test whether it is providing the desired output or not.
6. Maintenance
During this phase, the program is actively used by the users. If any enhancements found in this phase,
all the phases are to be repeated to make the enhancements. That means in this phase, the solution
(program) is used by the end-user. If the user encounters any problem or wants any enhancement, then
we need to repeat all the phases from the starting, so that the encountered problem is solved or
enhancement is added
ALGORITHM
Algorithm is the set of rules that define how particular problem can be solved in finite number of
Advantages of Algorithms:
Disadvantage of Algorithms:
1. It is time consuming
Algorithms are employed to solve problems. The requirements for problem solving by computer
include:
1. Clear Understanding of the Problem: Precise articulation of the problem is essential. Define the
problem in a way that a computer can understand and process it. This includes identifying inputs,
2. Input Data: Determine what data is required to solve the problem. Collect, acquire, or generate
the necessary input data. Ensure the data is accurate and reliable.
3. Algorithms and Methods: Formulate a step-by-step procedure or algorithm to solve the problem.
Algorithms provide a clear set of instructions for the computer to follow, breaking down the
solution into smaller, manageable steps. Choose appropriate algorithms, methods, and
4. Data Structures: Use suitable data structures to represent and manipulate data efficiently.
Common data structures include arrays, lists, trees, graphs, queues, and stacks.
5. Logical Precision: While developing computer algorithms the solution must be specified with
Definition of program:Program is the set of instructions which is run by the computer to perform
specific task. The task of developing program is called programming. To obtain a computer solution
to a problem, which provides input to the program which is manipulated according to instructions
Program verification is the process of applying formal methods directly to verification of code.
Program verification is the process of using mathematical proof techniques to establish that the results
obtained by the execution of a program with arbitrary inputs are in accord with formally defined
output specifications.
The main goal of the program verification is to understand what happens when a program is executed
i=1, f=1;
while(i<=n)
f=f*i;
i++;
iv) Proof of termination: To prove that a program terminates, it is necessary to show that the
expected output is attained in a finite number of steps. This implies that every loop in the program