Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
1.3k views
in Programming by (30 points)
closed by

How to write algorithm?

1 Answer

0 votes
by (25.0k points)
selected by
 
Best answer

Steps:

1. Determine the outcome of your code. What is the specific problem you want to solve or the task you want it to accomplish? Once you have a solid idea of what you're aiming to accomplish, you can determine the steps it will take to get there.

2. Decide on a starting point. Finding your starting and ending point are crucial to listing the steps of the process. To determine a starting point, determine the answers to these questions:

  • What data/inputs are available?
  • Where is that data located?
  • What formulas are applicable to the issue at hand?
  • What are the rules to working with the available data?
  • How do the data values relate to each other?

3. Find the ending point of the algorithm. As with the starting point, you can find the end point of your algorithm by focusing on these questions:

  • What facts will we learn from the process?
  • What changes from the start to the end?
  • What will be added or no longer exist?

4. List the steps from start to finish. Start with broad steps. To use a real-world example, let's say your goal is to have lasagna for dinner. You've determined that the starting point is to find a recipe, and that the end result is that you'll have a lasagna fully cooked and ready to eat by 7 PM. Your steps may look something like this:

  • Search for a recipe online.
  • Look for the ingredients you already have in the kitchen.
  • Make a list of ingredients you'll need from the store.
  • Buy the missing ingredients.
  • Return home.
  • Prepare the lasagna.
  • Remove the lasagna from the oven.

5. Determine how you will accomplish each step. Now that you have a step-by-step outline, it's time to think about how you might code each step. Which language will you use? What resources are available? What's the most efficient way to accomplish each step in that language? Incorporate some of that code into your algorithm. Expand each step until you've detailed the entire process.

  • For example, the first step in our lasagna algorithm is Search for a recipe online. But what is involved in this search? Be specific. For example:
    • Turn on your computer.
      • Check to make sure you're connected to the internet. Connect to the internet if you aren't already.
    • Open a web browser.
    • Enter your search terms.
    • Click a recipe link.
    • Determine whether the recipe meets your needs.
      • Filter out recipes that aren't vegetarian.
      • Make sure the recipe makes at least 5 servings.
    • Repeat some of these steps until you find the right recipe.
  • Consider the resources at your disposal, such as the capabilities of the system you're developing a program for. In the case of lasagna, we assume the person making the lasagna knows how to search the internet, operate an oven, etc.

6. Review the algorithm. Now that you've written your algorithm, it's time to evaluate the process. Your algorithm is designed to accomplish something specific, and you'll need it to start writing your program. Ask yourself the following questions, and address each as necessary:

  • Does the algorithm solve the problem/accomplish the task?
  • Does it have clearly defined inputs and outputs?
  • Should the end goal be redefined to be more general? More specific?
  • Can any of the steps be simplified?
  • Is the algorithm guaranteed to end with the correct result?

No related questions found

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...