How to write a nice algorithm in computers? Just remember that an algorithm is just a fancy word to say for a set of instructions written for computers to do in sequence to solve/complete a task.
The characteristics of a powerful algorithm
- strive for efficiency by workaround the limitations of your computer(s)
- effective in solving a specific task with fewer instructions for a faster finish
Efficient in using limited resources
- Memory Space (RAM) - Limiting the amount of temporary memory to use
- Disk Space (Storage) - Limiting the amount of long-term memory to use
- Processing Speed - Budgeting the use of computer(s) or supercomputer(s) to achieve the required number of instructions per second VS the cost to build and maintain them
- Power Consumption - Limiting the amount of electricity that the computer(s) or supercomputer(s) will use
Effective in solving the task
- Data Structure - Improving of how the data is being store and retrieve
- Limiting the number of times to run through the whole algorithm to complete a task which is express in O(n) time complexity
- Limiting the number of instructions is required to do in a single iteration of the algorithm (O(n) does not address this at all; Stay tune for more)
- Avoid using built-in instructions that are too time consuming to run