C lang UNIT - 1 Notes
C lang UNIT - 1 Notes
Program:
Algorithm:
Algorithm is the set of rules that define how particular problem can
be solved in finite number of steps. Any good algorithm must have
following characteristics.
( or )
( or )
Disadvantage of Algorithms:
1. It is time consuming
2. Difficult to show branching and looping statement
3. Large problems are difficult to implement
Flowchart:
Advantage of Flowchart:
1. Easier to understand
2. Helps to understand logic of problem
3. Easy to draw flowchart in any software like MS-Word
4. Complex problem can be represent using less symbols
5. It is the way to documenting any problem
6. Helps in debugging process
Disadvantage of Flowchart:
Sometimes it is not sufficient just to cope with problems. We have to solve those
problems. Most people are involving to solve the problem. These problems are
occurred while performing small task or making small decision. So, here are some
basic steps to solve the problems
• List out all the solution that you find. Do not focus on the quality of the solution
• Generate the maximum number of solutions as you can without considering the
quality of the solution
Step 3: Evaluate Alternatives
After filtering all the solution, you have the best solution only. Then choose one
of the best solution and make a decision to make it as a perfect 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 Step2.
Implementation Phase
• Program Development
Translate algorithm into a program written in a programming language
• Program Testing
Test program for syntactical and logical errors. Fix the errors.
Maintenance Phase
• Use
Use the program to solve real world problems
• Maintain
Modify the program to meet changing requirements
4. PROBLEM SOLVING STRATEGIES:
1. Identify the problem
The first step is to know which problem you need to solve. Then, you need to
find the root cause of the problem.
The best course of action is to gather as much data as possible, speak to the
people involved, and separate facts from opinions.
Once this is done, formulate a statement that describes the problem. Use
rational persuasion to make sure your team agrees.
2. Break the problem down
Identifying the problem allows you to see which steps need to be taken to
solve it.
First, break the problem down into achievable blocks. Then, use strategic
planning to set a time frame in which to solve the problem and establish a
timeline for the completion of each stage.
3. Generate potential solutions
At this stage, the aim isn’t to evaluate possible solutions but to generate as
many ideas as possible.
Encourage your team to use creative thinking and be patient — the best
solution may not be the first or most obvious one.
Use one or more of the different strategies in the following section to help
come up with solutions — the more creative, the better.
4. Evaluate the possible solutions
Once you’ve generated potential solutions, narrow them down to a shortlist.
Then, evaluate the options on your shortlist.
5. Implement and monitor the solutions
Once you have identified your solution and got buy-in from your team, it is
time to implement it.
But the work doesn’t stop there. You need to monitor your solution to see
whether it actually solves your problem.
Request regular feedback from the team members involved and have a
monitoring and evaluation plan in place to measure progress.
If the solution doesn’t achieve your desired results, start this step-by-step
process again
5. TOP-DOWN APPROACH:
Top-Down Approach is an approach to design algorithms in which a bigger
problem is broken down into smaller parts. Thus, it uses the decomposition
approach. This approach is generally used by structured programming
languages such as C, COBOL, FORTRAN.
In this approach we look at the overall requirement and start coding. We
build the main function first, then add calls to various functions like add,
subtract etc... and then display the output. After doing all these we code the
individual functions for addition, subtraction etc.
6. ALGORITHM DESIGINING:
Algorithm design affects how well your solution works, how fast it runs,
how much memory it uses and how easy it is to understand and modify.
Choosing best right algorithm can make a big difference in the quality and
efficiency of your solution.
Designing algorithms requires a set of principles and techniques.
To begin, you must define the problem clearly and precisely including the
inputs and outputs, assumptions and goals of the solution breaking down the
problem into smaller and simpler subprograms can help, use recursion, divide,
and conquer.
7. PROGRAM VERIFICATION
Verification is the process of checking that software achieves its goal
without any bugs.it is the process to ensure whether the product that is
developed is right or not. It verifies whether the developed product fulfils
the requirements that we have.
The commonly used validation activities in software testing are usability
testing, performance testing, system testing, security testing, and
functionality testing. A few verification methods are inspection, code
review, disk checking and walkthroughs.
8. IMPROVING EFFICIENCY
One of the best ways to improve your algorithm efficiency and correctness
is to use pseudocode and diagrams to plan and visualize your algorithm
before you write any code.
Pseudocode is a simplified and informal way of describing the steps and
logic of your algorithm, using natural language and basic symbols.
The most efficient algorithm is one that takes the least amount of execution
time and memory usage possible while still yielding a correct answer.
9. ALGORITHM ANALYSIS AND NOTATIONS
Algorithm analysis is an important part of computational complexity
theory, which provides theoretical estimation for the required resources of
an algorithm to solve a specific computational problem.
Analysis of algorithm is the determination of the amount of time and space
resources required to execute it
Notations: