InterviewSolution
| 1. |
How to write algorithm? |
|
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:
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:
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:
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.
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:
|
|