Definition
.
कुछ छात्र ये कहेंगे कि algorithm की definition है “Output प्राप्त करने के लिए Input पर लगाई जाने वाली set of instructions “.
अगर दूसरे शब्दों में कहे कि “अगर हम computer में किसी input पर set of instructions लगायेंगे, तो उससे हमें output मिलेगा, और यही set of instructions हैं जिन्हें algorithm कहा जाता है .”
अब इस definition में, ‘set’ शब्द गलत है।
Set की definition होती है “collection of elements” और elements की definition mathematics में है कि “उस set में जितने भी elements हैं, वों unique हैं मतलब कोई भी element repeat नही होगा“।
मतलब “जितने भी instruction हैं उस set में, वो unique हैं और कोई भी instruction repeat नही होगा “|
.
हमें कई बार, एक ही instruction को कई बार लिखना पड़ता है | और अगर algorithm कि definition में हमने set लगा दिया तो फिर एक instruction को हम बार बार नही लिख सकते |
Example –
Algorithm of Calculator
- Start
- int a, int b, int c
- Enter a, b.
- c = a+b
- Print c
- c = a-b
- Print c
- c = a*b
- Print c
- c = a/b
- Print c
- End
आपने देखा कि हमने 5th, 7th, 9th और 11th instruction में print c लिखा है. पर जो हमने definition लिखी है उसमें कहा गया है की set of instructions, मतलब “print c” केवल एक ही बार आ सकता है, जो सही नहीं है.
ये calculator कि algorithm, जो हमने ऊपर लिखी है, बहुत ही basic है, पर ये भी एक algorithm है और बिलकुल सही है पर ये set of instruction को satisfy नहीं करती है |
एक बात और देखने वाली है की अगर अलगोरिथ्म start हुआ है, तो stop भी होगा । मतलब एक finite sequence ( सीमित क्रम ) में अलगोरिथ्म होगा ।
.
Algorithm में कई steps हैं, और एक ही step के कई duplicate भी हैं। तो एक algorithm की सही definition होगी
“एक step by step procedure या process जिससे एक विशेष प्रकार की problem का समाधान हो जाए, उस problem का समाधान एक machine से भी हो सकता है या फिर manual भी हो सकता है “.
Manual problem का उदाहरण है जैसे चाय बनाना.
- Start
- गैस पर बर्तन रखो
- उसमे पानी और चाय पत्ती डालो
- उसको उबालो
- उसमे दूध डालो
- उसको उबालो
- उसमे चीनी डालो
- उसको उबालो
- चाय तैयार है
- Stop
लेकिन हम computational problems में रुचि रखते हैं क्योंकि हम एक computer engineer हैं, इसलिए definition होगी
“एक algorithm, instructions का एक finite sequence है, जो एक Problem या Problems के Group को हल करने के लिए किए जाने वाले operations का एक sequence निर्देशित करता है”।
.
आपमें से ज्यादातर को समझ नहीं आया होगा, जानता हूँ । इसलिए English में
“An algorithm is a finite sequence of instructions that specify a sequence of operations to be carried out to solve a specific problem or class of problems”.
.
Father of Algorithmic Analysis
एक लंबी अवधि के बाद, Donald Erwin Knuth आए। उनका जन्म 10 जनवरी, 1938 को हुआ था, और वह Stanford University में एक computer scientist, mathematician और professor भी हैं।
Knuth को “Father of Algorithmic Analysis” के रूप में जाना जाता है।

.
उन्होंने तीन किताबें लिखी “The Art of Computer Programming 1, 2 और 3”। उस किताब में algorithm को बहुत अच्छे तरीके से समझाया है लेकिन उनकी किताब बहुत complex है । हर किसी के समझ नहीं आती। जो अपने आपको बहुत बड़ा programmer मानते हो, वह उस किताब को पढ़े । हो सकता है, उनका भ्रम टूट जाए ।
Algorithm की बात करते हुए Donald Ervin Knuth ने कहा की ऊपर वाली definition बिलकुल ठीक है, पर इसके साथ 5 विशेषताएँ (characteristic features) और जुड़ेंगे । ये हैं –
- Input – zero या उससे अधिक input हो सकते हैं जैसे कि hello World के program में कोई input नहीं होता ।
- Output – कम से कम एक output तो जरूर आना चाहिए ।
- Definiteness (स्पष्ट होना) – हर instruction एकदम साफ और स्पष्ट होना चाहिए । कोई भी संदेह या गलतफहमी instruction में नहीं होनी चाहिए ।
- Effectiveness (प्रभावशीलता) – प्रत्येक instruction बहुत बुनियादी और संभव और परिणाम देने वाला होना चाहिए ।
- Finiteness (सीमित रहना) – अलगोरिथ्म कि instruction को एक सीमित संख्या के बाद समाप्त होना चाहिए । इसीलिए हम अलगोरिथ्म के समाप्त होने के बाद End जरूर लिखते हैं ।
Test Yourself
Q1- What is the definition of Algorithm?
“An algorithm is a finite sequence of instructions that specify a sequence of operations to be carried out to solve a specific problem or class of problems”.
Characteristics –
- Input – There can be zero or more inputs such that there is no input in the program of hello world.
- Output – At least one output must come.
- Definiteness – Every instruction should be very clear and unambiguous. There should be no doubt or misunderstanding in the instruction.
- Effectiveness – Every instruction should be very basic and possible and result-giving.
- Finiteness – The algorithmic instruction must end after a finite number. That is why, we definitely write the ‘End’ after the algorithm is over.
Q2- Who is Donald Ervin Knuth?
Donald Ervin Knuth is known as the “father of algorithmic analysis”.
Q3- Can an instruction be used more than once in an algorithm?
Yes, instruction can be used more than once in an algorithm.
Q4- “Algorithm is a set of instructions” is it correct?
No, Algorithm is not a set of instructions, the word ‘set’ is wrongly placed. The definition of the set is “collection of elements” and the definition of elements is “any one of the distinct objects that belong to that set”. The word distinct is not applied in the algorithm.
Q5- If the algorithm has started, then there is also a _______.
Stop.