7.4 ALGORITHM, FLOWCHART AND PSEUDOCODE

7.4 এলগৰিথম, ফ্লোচাৰ্ট আৰু চিউডোকোড

Let us assume that we want to write a program to find the largest of N given numbers. The numbers are stored in computer memory and we need to make a comparison to find out the largest one. Think for a while how human beings would solve this problem!

আমি ধৰি লওঁ যে আমি এন প্ৰদান কৰা সংখ্যাবোৰৰ ভিতৰত সৰ্ববৃহৎ টো বিচাৰিবলৈ এটা প্ৰ’গ্ৰাম লিখিব বিচাৰো। নম্বৰবোৰ কম্পিউটাৰ মেম’ৰীত সংৰক্ষণ কৰা হয় আৰু আমি আটাইতকৈ ডাঙৰটো বিচাৰি উলিয়াবলৈ তুলনা কৰিব লাগিব। মানুহে এই সমস্যাটো কেনেদৰে সমাধান কৰিব অলপ সময়চিন্তা কৰক।

When we are given only one number, the number is automatically the largest number. In general, let us consider the first number as the largest number. We will bring the second number and compare with the currently declared largest number. If the second number is greater than the current largest number, then we need to update and the second number becomes our new largest number. In case the second number is smaller than the current largest number, we do not need to do anything. If we keep on doing this till the last number, we will get the largest number among all the numbers. This is the solution strategy for the given problem.

যেতিয়া আমাক কেৱল এটা সংখ্যা দিয়া হয়, সংখ্যাটো স্বয়ংক্ৰিয়ভাৱে সৰ্ববৃহৎ সংখ্যা। সাধাৰণতে, আমি প্ৰথম সংখ্যাটোক সৰ্বাধিক সংখ্যা হিচাপে বিবেচনা কৰোঁ আহক। আমি দ্বিতীয় সংখ্যাটো আনিম আৰু বৰ্তমানে ঘোষণা কৰা সৰ্ববৃহৎ সংখ্যাৰ সৈতে তুলনা কৰিম। যদি দ্বিতীয় সংখ্যাটো বৰ্তমানৰ সৰ্ববৃহৎ সংখ্যাতকৈ ডাঙৰ হয়, তেন্তে আমি আপডেট কৰিব লাগিব আৰু দ্বিতীয় সংখ্যাটো আমাৰ নতুন সৰ্ববৃহৎ সংখ্যা হৈ পৰিব। যদি দ্বিতীয় সংখ্যাটো বৰ্তমানৰ সৰ্ববৃহৎ সংখ্যাতকৈ সৰু হয়, আমি একো কৰাৰ প্ৰয়োজন নাই। যদি আমি অন্তিম সংখ্যালৈকে এইটো কৰি থাকোঁ, আমি সকলো সংখ্যাৰ ভিতৰত সৰ্বাধিক সংখ্যা পাম। প্ৰদত্ত সমস্যাটোৰ বাবে এইটো সমাধান ৰণনীতি।

If we write them in steps specifying the operation for each step, we will end up with an algorithm for the problem. An algorithm is a well-defined set of steps to solve a given problem. The above discussed steps to find the largest number from a set of numbers can be written as an algorithm as shown in Figure 7.4.

যদি আমি সেইবোৰ প্ৰতিটো পদক্ষেপৰ বাবে অপাৰেচন নিৰ্দিষ্ট কৰা পদক্ষেপত লিখোঁ, আমি সমস্যাটোৰ বাবে এটা এলগৰিথমৰ সৈতে শেষ কৰিম। এটা এলগৰিথম হৈছে প্ৰদত্ত সমস্যা এটা সমাধান কৰাৰ বাবে এক সুনিৰ্ধাৰিত পদক্ষেপ। সংখ্যাৰ এটা সংহতিৰ পৰা সৰ্বাধিক সংখ্যা বিচাৰি উলিওৱাৰ ওপৰত আলোচনা কৰা পদক্ষেপবোৰ চিত্ৰ 7.4-ত দেখুওৱাৰ দৰে এলগৰিথম হিচাপে লিখিব পাৰি।

The steps in solving a problem can also be represented using a diagram. The graphical representation of an algorithm is called flowchart. We use different symbols to draw the flowchart. Each symbol has its dedicated meaning. We list some basic symbols used in a flowchart as follows.

সমস্যা এটা সমাধান কৰাৰ পদক্ষেপবোৰো নক্সা এটা ব্যৱহাৰ কৰি প্ৰতিনিধিত্ব কৰিব পাৰি। এটা এলগৰিথমৰ গ্ৰাফিকেল প্ৰতিনিধিত্বক ফ্লোচাৰ্ট বুলি কোৱা হয়। আমি ফ্লোচাৰ্ট আঁকিবলৈ বিভিন্ন চিহ্ন ব্যৱহাৰ কৰোঁ। প্ৰতিটো চিহ্নৰ ইয়াৰ সমৰ্পিত অৰ্থ আছে। আমি ফ্লোচাৰ্ট এখনত ব্যৱহৃত কিছুমান মৌলিক চিহ্ন তলত দিয়া ধৰণে তালিকাভুক্ত কৰোঁ।

Oval: used to indicate start or stop of the flow.

ওভাল: প্ৰবাহআৰম্ভ বা বন্ধ সূচিত কৰিবলৈ ব্যৱহাৰ কৰা হয়।

Parallelogram: used to indicate input or output operation.

সমান্তৰালগ্ৰাম: ইনপুট বা আউটপুট অপাৰেচন সূচিত কৰিবলৈ ব্যৱহাৰ কৰা হয়।

Rectangle: used to indicate processing or calculation.

আয়ত: প্ৰক্ৰিয়াকৰণ বা গণনা সূচিত কৰিবলৈ ব্যৱহাৰ কৰা হয়।

Diamond: used to indicate a decision making operation.

হীৰা: সিদ্ধান্ত লোৱাৰ কাম এটা সূচিত কৰিবলৈ ব্যৱহাৰ কৰা হয়।

As stated earlier, to write a program we must follow all the rules of the language and every statement in the program has to be a valid statement of the language. If we want to write the program in an informal way, we may do so with the help of pseudocode.

আগতে কোৱাৰ দৰে, প্ৰ’গ্ৰাম এটা লিখিবলৈ আমি ভাষাটোৰ সকলো নিয়ম অনুসৰণ কৰিব লাগিব আৰু প্ৰ’গ্ৰামটোৰ প্ৰতিটো বিবৃতি ভাষাটোৰ এক বৈধ বিবৃতি হ’ব লাগিব। যদি আমি প্ৰ’গ্ৰামটো অনানুষ্ঠানিক ভাৱে লিখিব বিচাৰো, আমি ছদ্মকোডৰ সহায়ত এনে কৰিব পাৰোঁ।

Pseudocode uses natural language and mathematical symbols to express the program. Some times, it is easier for us to comprehend the pseudocode than the actual code or the program. As a result, pseudocodes are also heavily used. Figure 7.6 shows a pseudo code for the same problem we are discussing.

ছদ্মকোডে প্ৰ’গ্ৰামটো প্ৰকাশ কৰিবলৈ প্ৰাকৃতিক ভাষা আৰু গাণিতিক চিহ্ন ব্যৱহাৰ কৰে। কিছুমান সময়ত, প্ৰকৃত কোড বা প্ৰ’গ্ৰামতকৈ ছদ্মকোডটো বুজি পোৱাটো আমাৰ বাবে সহজ হয়। ফলস্বৰূপে, ছদ্মকোডবোৰো যথেষ্ট ব্যৱহাৰ কৰা হয়। চিত্ৰ ৭.৬ য়ে আমি আলোচনা কৰি থকা একেটা সমস্যাৰ বাবে এটা ছদ্ম কোড দেখুৱায়।

Let us assume that we want to write a program to find the largest of N given numbers. The numbers are stored in computer memory and we need to make a comparison to find out the largest one. Think for a while how human beings would solve this problem.

আমি ধৰি লওঁ যে আমি এন প্ৰদান কৰা সংখ্যাবোৰৰ ভিতৰত সৰ্ববৃহৎ টো বিচাৰিবলৈ এটা প্ৰ’গ্ৰাম লিখিব বিচাৰো। নম্বৰবোৰ কম্পিউটাৰ মেম’ৰীত সংৰক্ষণ কৰা হয় আৰু আমি আটাইতকৈ ডাঙৰটো বিচাৰি উলিয়াবলৈ তুলনা কৰিব লাগিব। মানুহে এই সমস্যাটো কেনেদৰে সমাধান কৰিব অলপ সময়চিন্তা কৰক।

When we are given only one number, the number is automatically the largest number. In general, let us consider the first number as the largest number. We will bring the second number and compare with the currently declared largest number. If the second number is greater than the current largest number, then we need to update and the second number becomes our new largest number. In case the second number is smaller than the current largest number, we do not need to do anything. If we keep on doing this till the last number, we will get the largest number among all the numbers. This is the solution strategy for the given problem.

যেতিয়া আমাক কেৱল এটা সংখ্যা দিয়া হয়, সংখ্যাটো স্বয়ংক্ৰিয়ভাৱে সৰ্ববৃহৎ সংখ্যা। সাধাৰণতে, আমি প্ৰথম সংখ্যাটোক সৰ্বাধিক সংখ্যা হিচাপে বিবেচনা কৰোঁ আহক। আমি দ্বিতীয় সংখ্যাটো আনিম আৰু বৰ্তমানে ঘোষণা কৰা সৰ্ববৃহৎ সংখ্যাৰ সৈতে তুলনা কৰিম। যদি দ্বিতীয় সংখ্যাটো বৰ্তমানৰ সৰ্ববৃহৎ সংখ্যাতকৈ ডাঙৰ হয়, তেন্তে আমি আপডেট কৰিব লাগিব আৰু দ্বিতীয় সংখ্যাটো আমাৰ নতুন সৰ্ববৃহৎ সংখ্যা হৈ পৰিব। যদি দ্বিতীয় সংখ্যাটো বৰ্তমানৰ সৰ্ববৃহৎ সংখ্যাতকৈ সৰু হয়, আমি একো কৰাৰ প্ৰয়োজন নাই। যদি আমি অন্তিম সংখ্যালৈকে এইটো কৰি থাকোঁ, আমি সকলো সংখ্যাৰ ভিতৰত সৰ্বাধিক সংখ্যা পাম। প্ৰদত্ত সমস্যাটোৰ বাবে এইটো সমাধান ৰণনীতি।

If we write them in steps specifying the operation for each step, we will end up with an algorithm for the problem. An algorithm is a well-defined set of steps to solve a given problem. The above discussed steps to find the largest number from a set of numbers can be written as an algorithm as shown in Figure 7.4.

যদি আমি সেইবোৰ প্ৰতিটো পদক্ষেপৰ বাবে অপাৰেচন নিৰ্দিষ্ট কৰা পদক্ষেপত লিখোঁ, আমি সমস্যাটোৰ বাবে এটা এলগৰিথমৰ সৈতে শেষ কৰিম। এটা এলগৰিথম হৈছে প্ৰদত্ত সমস্যা এটা সমাধান কৰাৰ বাবে এক সুনিৰ্ধাৰিত পদক্ষেপ। সংখ্যাৰ এটা সংহতিৰ পৰা সৰ্বাধিক সংখ্যা বিচাৰি উলিওৱাৰ ওপৰত আলোচনা কৰা পদক্ষেপবোৰ চিত্ৰ 7.4-ত দেখুওৱাৰ দৰে এলগৰিথম হিচাপে লিখিব পাৰি।

The steps in solving a problem can also be represented using a diagram. The graphical representation of an algorithm is called flowchart. We use different symbols to draw the flowchart. Each symbol has its dedicated meaning. We list some basic symbols used in a flowchart as follows.

সমস্যা এটা সমাধান কৰাৰ পদক্ষেপবোৰো নক্সা এটা ব্যৱহাৰ কৰি প্ৰতিনিধিত্ব কৰিব পাৰি। এটা এলগৰিথমৰ গ্ৰাফিকেল প্ৰতিনিধিত্বক ফ্লোচাৰ্ট বুলি কোৱা হয়। আমি ফ্লোচাৰ্ট আঁকিবলৈ বিভিন্ন চিহ্ন ব্যৱহাৰ কৰোঁ। প্ৰতিটো চিহ্নৰ ইয়াৰ সমৰ্পিত অৰ্থ আছে। আমি ফ্লোচাৰ্ট এখনত ব্যৱহৃত কিছুমান মৌলিক চিহ্ন তলত দিয়া ধৰণে তালিকাভুক্ত কৰোঁ।

Oval: used to indicate start or stop of the flow.

ওভাল: প্ৰবাহআৰম্ভ বা বন্ধ সূচিত কৰিবলৈ ব্যৱহাৰ কৰা হয়।

Parallelogram: used to indicate input or output operation.

সমান্তৰালগ্ৰাম: ইনপুট বা আউটপুট অপাৰেচন সূচিত কৰিবলৈ ব্যৱহাৰ কৰা হয়।

Rectangle: used to indicate processing or calculation.

আয়ত: প্ৰক্ৰিয়াকৰণ বা গণনা সূচিত কৰিবলৈ ব্যৱহাৰ কৰা হয়।

Diamond: used to indicate a decision making operation.

হীৰা: সিদ্ধান্ত লোৱাৰ কাম এটা সূচিত কৰিবলৈ ব্যৱহাৰ কৰা হয়।

As stated earlier, to write a program we must follow all the rules of the language and every statement in the program has to be a valid statement of the language. If we want to write the program in an informal way, we may do so with the help of pseudocode.

আগতে কোৱাৰ দৰে, প্ৰ’গ্ৰাম এটা লিখিবলৈ আমি ভাষাটোৰ সকলো নিয়ম অনুসৰণ কৰিব লাগিব আৰু প্ৰ’গ্ৰামটোৰ প্ৰতিটো বিবৃতি ভাষাটোৰ এক বৈধ বিবৃতি হ’ব লাগিব। যদি আমি প্ৰ’গ্ৰামটো অনানুষ্ঠানিক ভাৱে লিখিব বিচাৰো, আমি ছদ্মকোডৰ সহায়ত এনে কৰিব পাৰোঁ।

Pseudocode uses natural language and mathematical symbols to express the program. Some times, it is easier for us to comprehend the pseudocode than the actual code or the program. As a result, pseudocodes are also heavily used. Figure 7.6 shows a pseudo code for the same problem we are discussing.

ছদ্মকোডে প্ৰ’গ্ৰামটো প্ৰকাশ কৰিবলৈ প্ৰাকৃতিক ভাষা আৰু গাণিতিক চিহ্ন ব্যৱহাৰ কৰে। কিছুমান সময়ত, প্ৰকৃত কোড বা প্ৰ’গ্ৰামতকৈ ছদ্মকোডটো বুজি পোৱাটো আমাৰ বাবে সহজ হয়। ফলস্বৰূপে, ছদ্মকোডবোৰো যথেষ্ট ব্যৱহাৰ কৰা হয়। চিত্ৰ ৭.৬ য়ে আমি আলোচনা কৰি থকা একেটা সমস্যাৰ বাবে এটা ছদ্ম কোড দেখুৱায়।