<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammad Sakib Khan Inan</title>
    <description>The latest articles on DEV Community by Muhammad Sakib Khan Inan (@skinan).</description>
    <link>https://dev.to/skinan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F510461%2Fdea93b0c-8984-453a-91fa-eca3bd78ae22.jpeg</url>
      <title>DEV Community: Muhammad Sakib Khan Inan</title>
      <link>https://dev.to/skinan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/skinan"/>
    <language>en</language>
    <item>
      <title>Is C Programming Knowledge A Must To Learn Python or Any Other Programming Languages?</title>
      <dc:creator>Muhammad Sakib Khan Inan</dc:creator>
      <pubDate>Tue, 05 Jan 2021 12:53:42 +0000</pubDate>
      <link>https://dev.to/techlearners/is-c-programming-knowledge-a-must-to-learn-python-or-any-other-programming-languages-p5b</link>
      <guid>https://dev.to/techlearners/is-c-programming-knowledge-a-must-to-learn-python-or-any-other-programming-languages-p5b</guid>
      <description>&lt;p&gt;&lt;strong&gt;Nowadays, there is an ongoing myth among some people,&lt;/strong&gt; who are complete beginners in the programming world or coding world that without learning languages like "C" or basically "C", you won't be able to learn modern high-level programming languages like "Python" well. It can be simplified like this that before learning any other language you must need to learn "C'. I decided to write about this when one of my classmates reached me with the same type of problem which I mentioned in the very beginning. She asked me for suggestions on how to learn "Python" as a complete beginner. After I gave her some suggestions, she said that she is confused that if she needs to learn C Programming first in a good manner to cope up with learning Python or not. I told her that it isn't necessary to learn the C programming language to learn Python. But she acclaimed that she has heard that without learning C first, her basics of programming won't be clear in a full manner, and for this, she believes she should learn C before learning the others. So, I am going to share my thoughts on this topic today.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flabzwzrbtd8dwzy9darw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flabzwzrbtd8dwzy9darw.png" alt="Programming Languages"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python is a high-level programming language.&lt;/strong&gt; It is one of the most popular and widely used programming languages in today's world. Data Science, Machine Learning, Artificial Intelligence, etc fields are mostly dominated by Python now. If you are a complete beginner in coding and want to learn Python, then I will say without thinking twice you should start learning Python. Don't get worried about the confusion that you need to learn C first. If you have the basics of C or any other programming languages then it will boost up your learning speed but if you don't have it, need not worry much about it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Programming Languages&lt;/strong&gt; are just a medium or a way to make the machines understand what we want them to do. The main concepts like loops, conditional logic, functions, or methods are quite similar in all languages, just the syntax and code writing styles are different from language to language. In Python, the syntax is quite English alike, so it's quite easy to understand and learn.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;strong&gt;When you will begin to learn Python&lt;/strong&gt;, you will find programming very easy and interesting as you won't have to work hard with declaring variables before using them, etc. Just learn and understand how functions, loops, conditions, etc main basic things work in Python and practice more and more. Many programmers have learned Python as their first language and they are doing a lot of good works in the coding field. One of my friends has also learned Python first and then learned C, his favorite language is Python and he understands very well the coding basics. The main thing is you must need to learn one programming language in a good manner to understand the basics of coding, no matter whether it's Python or C or Java or Pascal or Swift or JavaScript, whatever it is.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When you will have a good experience as a beginner with any programming language, you won't find it very much hard to learn a new one. There are a lot of resources present online on Python.&lt;/p&gt;

&lt;p&gt;💘 So don't be late, start learning, start coding.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;strong&gt;At last, I want to say to the beginners of the coding world,&lt;/strong&gt; "To learn to code, you must do coding. Without writing codes on your own, you won't be able to learn it well."&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqm2u6bsds1vjr1ci47b4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fqm2u6bsds1vjr1ci47b4.png" alt="Best of Luck"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Share your opinion in the discussion section below and of course the questions if any.&lt;/em&gt; Don't forget to follow us.&lt;/p&gt;

&lt;p&gt;💡 &lt;strong&gt;&lt;em&gt;AND SUBSCRIBING to our YouTube&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.youtube.com/c/TechLearnersInc" rel="noopener noreferrer"&gt;&lt;strong&gt;TechLearnersInc&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;and Telegram&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://t.me/TechLearners" rel="noopener noreferrer"&gt;&lt;strong&gt;t.me/TechLearners&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;will be amazing.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>python</category>
    </item>
    <item>
      <title>What is Hyper Parameter Tuning in Machine Learning?</title>
      <dc:creator>Muhammad Sakib Khan Inan</dc:creator>
      <pubDate>Mon, 28 Dec 2020 12:14:10 +0000</pubDate>
      <link>https://dev.to/techlearners/what-is-hyper-parameter-tuning-in-machine-learning-32kg</link>
      <guid>https://dev.to/techlearners/what-is-hyper-parameter-tuning-in-machine-learning-32kg</guid>
      <description>&lt;p&gt;If you are new to the field of Machine Learning and Data Science and have already done some implementations of some of the Machine Learning algorithms, you might have heard the term &lt;strong&gt;Hyper Parameter Tuning&lt;/strong&gt;. Yet, if you have not heard the term, I would like to take the privilege to ensure you that you are going to hear it soon when you will focus on the optimization of the performance of your algorithm or ML model. So, let's dive into today's discussion. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XPHAiY2---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vjf1whkqdctoisjw6g91.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XPHAiY2---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vjf1whkqdctoisjw6g91.png" alt="Hyper Parameter"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  ✴️ &lt;strong&gt;What is Hyper Parameter?&lt;/strong&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Hyper Parameters&lt;/strong&gt; are those parameters of a machine learning algorithm that controls the learning process and efficiency of the machine learning algorithm in its training phase and of course can be set and optimized manually. It basically determines how the algorithm is going to take the different learning approaches in the different steps of its learning process. The wrong choice of Hyper Parameters can make your machine learning model vulnerable to overfitting or underfitting, resulting in poor performance. Therefore determining hyperparameter setting wisely can certainly make your machine learning model better.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  ➡️ &lt;strong&gt;What are the Hyperparameters of KNN?&lt;/strong&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Let's take the example of one of the simplest machine learning algorithms that beginners tend to understand easily, KNN (K Nearest Neighbour).&lt;/p&gt;

&lt;p&gt;If you have implemented the KNN algorithm using the popular Scikit Learn Library in Python, you may have noticed that the KNN class object can take some arguments (values of parameters) at the time of creation according to the documentation of scikit learn. If you don't pass values to these parameters on your own, they would be set to their default values as per documentation. &lt;br&gt;
Let's see how we create a KNN object in scikit learn. Here, some of the hyperparameters in KNN are "n_neighbours" (the value of K), "metric" (distance metrics to be used, for example, manhattan or euclidean distance, etc).&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;sklearn.neighbors&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;KNeighborsClassifier&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;KNeighborsClassifier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Here, I didn't pass any values of the parameters manually. But if do it like this;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;sklearn.neighbors&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;KNeighborsClassifier&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;KNeighborsClassifier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n_neighbours&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;metric&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'manhattan'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Now, I have passed 9 to the parameter "n_neighbours", and so the K value for this KNN would be 9, and also as I have passed "manhattan" to the parameter "metric", the manhattan distance will be used in certain calculations of the training phase. There are some other hyperparameters for KNN also which you can learn by referring to the documentation of scikit learn. Just like this, in Random Forest Classifier you can manually set the number of trees to be used or built for classification through the "n_estimators" parameter, and the splitting criterion through "criterion".&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;sklearn.ensemble&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;RandomForestClassifier&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;RandomForestClassifier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n_estimators&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;criterion&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"gini"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  ✴️ &lt;strong&gt;What is Hyperparameter Tuning?&lt;/strong&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;There are a bunch of hyperparameters that can be set manually to optimize the performances of the different machine learning algorithms (Linear Regression, Logistic Regression, Decision Trees, Adaboost, K Means Clustering, etc). But there are no fixed universal best settings of hyperparameters of a machine learning algorithm. You might need to experiment over a set of possible values to choose the best settings according to your dataset and criteria. And this process of choosing the best set of values of hyperparameters is called hyperparameter tuning. For example, trying different values of K in KNN, or choosing the best splitting criterion, decreasing or increasing the number of trees in Random Forest Classifiers. Hyperparameter tuning is one of the most essential knowledge for machine learning engineers and data scientists. Hyperparameter tuning is also important in Deep Learning algorithms like CNN (Convolutional Neural Networks), RNN(Recurrent Neural Networks). &lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Don't forget to follow us. And share your thoughts with us in the discussion section.  &lt;/p&gt;

&lt;p&gt;💡 &lt;strong&gt;Subscribing to our YouTube Channel&lt;/strong&gt; &lt;a href="https://www.youtube.com/c/TechLearnersInc"&gt;&lt;strong&gt;TechLearnersInc&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;and Telegram&lt;/strong&gt; &lt;a href="https://t.me/TechLearners"&gt;&lt;strong&gt;t.me/TechLearners&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;will be amazing.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>ai</category>
      <category>beginners</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Facts To Know Before Starting Python!</title>
      <dc:creator>Muhammad Sakib Khan Inan</dc:creator>
      <pubDate>Sun, 27 Dec 2020 17:12:02 +0000</pubDate>
      <link>https://dev.to/techlearners/facts-to-know-before-starting-python-5436</link>
      <guid>https://dev.to/techlearners/facts-to-know-before-starting-python-5436</guid>
      <description>&lt;p&gt;Hello everyone! Hope you are doing fine! Today I am going to discuss some facts of &lt;strong&gt;Python Programming Language&lt;/strong&gt; that you should know and understand as a &lt;strong&gt;Python&lt;/strong&gt; beginner. So, let’s dive into it!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K2ybA6Tw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ov8akhumz6791i1quzc5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K2ybA6Tw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ov8akhumz6791i1quzc5.jpg" alt="Thumbnail" width="880" height="538"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python&lt;/strong&gt; is a high-level, multi-paradigm, interpreted, general-purpose programming language. Its syntax is designed to focus on &lt;strong&gt;readability&lt;/strong&gt; through the use of significant indentation and white-space rules. Don’t get worried to see such complex-looking words because I am going to explain these things in a while!&lt;/p&gt;




&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;➡️ High-level Language:&lt;/strong&gt; Language like Python, C, C++, C#, Java, or Kotlin, in which it is easier to read and write codes using natural language elements with strong abstraction from the details of computer are called high-level programming languages. In contrast, a language like “Assembly Language” used to write codes for microprocessors are low-level programming languages.&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;➡️ Multi-Paradigm:&lt;/strong&gt; This programming language supports multiple paradigms of programming. For example, Python supports &lt;strong&gt;structured programming&lt;/strong&gt; paradigm like &lt;strong&gt;C&lt;/strong&gt; (Programming Language) and &lt;strong&gt;object oriented programming&lt;/strong&gt; paradigm like &lt;strong&gt;Java&lt;/strong&gt;(Programming Language). In contrast, &lt;strong&gt;C&lt;/strong&gt; does not support object oriented programming paradigm and &lt;strong&gt;Java&lt;/strong&gt; does not support the structured programming paradigm. Besides many of Python’s feature also supports functional programming, aspect-oriented programming, etc.&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;➡️ General Purpose Programming Language:&lt;/strong&gt; According to &lt;a href="https://en.wikipedia.org/wiki/General-purpose_programming_language"&gt;Wikipedia&lt;/a&gt;, a general purpose programming language means it is designed to be writing software in the widest variety of application domains. It means you can use this language in various domains, it is not bounded to be used for some specific regions or domains.&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;➡️ Significant Indentations:&lt;/strong&gt; Language like C, C++, C#, Java, etc have a significant role of semi-colons(;) and curly brackets{} in most of the part of codes which becomes a horror for programmers sometimes because you may get an error just because you forgot to put a semi-colon at the end of a line, but the good news is, in Python, we don’t need to use a semi-colon(;) at the end of lines and curly brackets to define scopes of functions, methods, loops, etc. Meanwhile, the bad news is, you need to maintain the indentations and white-space rules correctly here in Python to write a valid or correct code that you didn’t need to maintain compulsorily in C or Java. It means you might even get errors for extra or unnecessary white-spaces. In a nutshell, you get rid of those semi-colons and curly brackets in Python but you need to maintain indentations and white-spaces according to the rules of Python correctly. Python focuses on indentations to increase the readability of code. To understand this you can see an example Python code from &lt;a href="https://en.wikipedia.org/wiki/Python_(programming_language)#Python_programming_examples"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Besides all these features, Python has a huge and rich collection of libraries for different purposes like machine learning, artificial intelligence, etc. It has also many other features like dynamic typing, garbage collecting, memory management, and more, which will you get to know as you will dive more deeply into the sea of Python.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Best wishes to everyone! Keep learning and keep sharing! and don't forget to share your opinion and of course the questions if any. Don't forget to follow us. ✌️&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;💡 &lt;strong&gt;&lt;em&gt;AND SUBSCRIBING to our YouTube&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.youtube.com/c/TechLearnersInc"&gt;&lt;strong&gt;TechLearnersInc&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;and Telegram&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://t.me/TechLearners"&gt;&lt;strong&gt;t.me/TechLearners&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;will be amazing.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Binary Search Algorithm Explained</title>
      <dc:creator>Muhammad Sakib Khan Inan</dc:creator>
      <pubDate>Sun, 27 Dec 2020 15:16:59 +0000</pubDate>
      <link>https://dev.to/techlearners/binary-search-algorithm-explained-2nn5</link>
      <guid>https://dev.to/techlearners/binary-search-algorithm-explained-2nn5</guid>
      <description>&lt;p&gt;In the world of computer science, Binary Search Algorithm is the ground of the &lt;strong&gt;“ Divide &amp;amp; Conquer”&lt;/strong&gt; algorithmic paradigm. This algorithm is the easiest illustration of how “Divide and Conquer” works. Using this algorithm searching can be done in O(log(n)) time where linear search takes O(n) time in the worst case. It saves time and makes the number of comparisons to perform fewer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5hsod7t93v85b23rk671.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5hsod7t93v85b23rk671.png" alt="Thumbnail"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let us consider a scenario. Suppose, you have a book of 1000 pages and we need to go to page number 580 and check whether the page exists or not. By using the linear search algorithm, you can start looking for the desired page from the beginning or the end. In both ways, you have to search over a large number of pages to find page number 580 as we are checking every page on our way. But, can we do it better? Can we find our desired page by making fewer comparisons? The answer is: Yes, we can do it in a faster way. We can do the improvement in less time by using the &lt;strong&gt;“Binary Search Algorithm”&lt;/strong&gt;. First, we need to keep in mind that this algorithm can be correctly applied if the data is sorted. In the case of page numbers of a book, the data is sorted. Here, we have page numbers from 1 to 1000 in a sorted manner. We need to find page number 580. Let’s divide our searching area into two halves. Get the midpoint of range 1 to 1000 like this, mid-index = (ending index+starting index-1)/2. So, it goes like this,(1000 / 2) = 500. Compare 500 (mid-index) with 580 (searching index). 580 is larger than 500 so it cannot be present in the range (1- 500). So, let’s exclude it from our searching area. Now, we have (501–1000) numbered pages for searching. Repeat the previous process and get the midpoint of the range (501 -1000). It will be 750. Compare 580 again with 750. And fix the new searching area as (501 -750) and exclude the range in which the number cannot be present. Keep repeating the process until you find the exact number or reach a situation when there are no numbers left to search. In this process, you can find the desired number in log(n) time and you need to perform a very fewer number of comparisons than linear search as after every comparison we are making our searching area small by excluding areas in which searching is unnecessary. So, the method is very simple when you have a sorted data set and need to find something in the data set rather than keep checking every element in the data set one by one, keep dividing the data set into two halves and compare the value with mid-value.&lt;/p&gt;

&lt;p&gt;This algorithm is frequently used in small to big tasks in computer science. Some other important algorithms like &lt;strong&gt;Merge Sort&lt;/strong&gt; also use the concept of divide and conquer. If you understand this algorithm well, you will get the basic idea of the &lt;strong&gt;“Divide &amp;amp; Conquer”&lt;/strong&gt; paradigm which is surely going to help you in learning more complex algorithms in the future. The most important thing to remember is, whenever you are going to apply the binary search algorithm the data must be placed in a sorted manner otherwise you cannot apply binary search. If you are going to start competitive programming must know the binary search algorithm as you will find problems that needed to be solved by directly using the binary search algorithm or using the concept of the binary search algorithm.&lt;/p&gt;




&lt;p&gt;⭐ &lt;strong&gt;I have attached here my code implementation of the binary search algorithm in Python &amp;amp; C++ programming language&lt;/strong&gt; ⭐&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;✴️ Code Implementation in Python&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;given_array&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;find&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;  &lt;span class="c1"&gt;# Number to search.
&lt;/span&gt;    &lt;span class="n"&gt;number_found&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;  &lt;span class="c1"&gt;# Determines if the number is found or not.
&lt;/span&gt;    &lt;span class="n"&gt;start_index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;end_index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;given_array&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;end_index&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;start_index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;mid_index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;end_index&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;start_index&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;given_array&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mid_index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;number_found&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;given_array&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;mid_index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;end_index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid_index&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;start_index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid_index&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;number_found&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The Desired Element Is Present!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The Desired Element Is Not Present&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;✴️ Code Implementation in C++&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;

&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt;&lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt; &lt;span class="c1"&gt;// given array.&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Element to search is stored in variable y.&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// l = Lower Index&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// h = Higher Index&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// m = Middle Index&lt;/span&gt;

    &lt;span class="c1"&gt;// Start of the loop to perform "Binary Search Algorithm".&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// The loop will run until there is one element left in array.&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Find the mid to divide the array into two almost equal parts.&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;// If the element is in the mid, we found it!&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// Break the loop.&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;// If search element is lesser than element at the mid, cut the higher part of the array.&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;          &lt;span class="c1"&gt;// Else cut the lower part of the array.&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s"&gt;"%d not found&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s"&gt;"%d found!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;So far, I’ve tried to show everything steps by step, and below, the discussion section is open for your opinion to share and of course the questions if any. And don't forget to follow us. &lt;/p&gt;

&lt;p&gt;💡 &lt;strong&gt;&lt;em&gt;AND SUBSCRIBING to our YouTube&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.youtube.com/c/TechLearnersInc" rel="noopener noreferrer"&gt;&lt;strong&gt;TechLearnersInc&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;and Telegram&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://t.me/TechLearners" rel="noopener noreferrer"&gt;&lt;strong&gt;t.me/TechLearners&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;will be amazing.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;🌟 Thank you for reading. Keep coding, keep sharing! 🌟&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;📌 Featured in DEV Community's Twitter&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1343583239768846336-330" src="https://platform.twitter.com/embed/Tweet.html?id=1343583239768846336"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1343583239768846336-330');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1343583239768846336&amp;amp;theme=dark"
  }



&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>tutorial</category>
      <category>python</category>
      <category>cpp</category>
    </item>
  </channel>
</rss>
