Introduction to Algorithm
Growth of Function

- यह समय-कुशल होना चाहिए।
- यह कम जगह का उपयोग करता है।
- न्यूनतम संभव परिणामों (minimum possible result) में समस्याओं को हल करता है।
- समाधान तक पहुंचने के लिए न्यूनतम संसाधन (minimum resources) का उपयोग करता है।
- इसे आसानी से समझा जाना चाहिए ।
- न्यूनतम लागत पर बनाए रखा जा सकता है।
- यह लचीला होना चाहिए ।
- सभी प्रकार के अपवादों और त्रुटियों (exceptions & errors) का प्रबंधन करता है।
- आत्मनिर्भर है।
- एक जैसी समस्याओं के लिए इसे लागू किया जा सकता है।
- संतुलित होना चाहिए।
Computer A | Computer B |
1 second में 100 crore instruction हल करता है = 109/sec | 1 second में 1 crore instruction हल करता है = 107/sec |
Algorithm time complexity = n2 instructions | Algorithm time complexity = 25*nlogn instructions |
समय लगा = n2/ (execute instructions in a sec) = (106)2/109 | समय लगा = n log n / (execute instructions in a sec) = 25*(106 log106)/107 |
इसमें लगे 16.66 minutes | इसमें लगे 15 seconds |
Test Yourself
Q1- Can an algorithm have two or more than two problems?
No
Q2- Can a program have two or more than two algorithms?
The answer is yes. Why? Because if you have a program in an old language and decide to make a program in a new and efficient language, you will need the program’s algorithm. If you don’t have the algorithm of the same program, then you can write one.
Q3- Can an algorithm have two or more than two programs?
Yes. Programs can be made in many languages if you have the algorithm’s logic and many programs can be made in the same language also.
Q4- According to Coreman’s book, algorithms are just like __________.
Technology
Q5- Can a fast algorithm makes the slow computer fast?
Yes
Q6- What a good algorithm means in time context?
A good algorithm must be time-efficient.
Q7- “A good algorithm should be balanced”. Explain?
There are two complexities in an algorithm in which we can find its efficiency. One is Time Complexity and Second is Space Complexity.
So, a good algorithm should be balanced between the two complexities. It may not be the case that the time complexity of the algorithm is very low, but it is taking so much space that there is no point in doing it, and vice-versa also.