<?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: alokz diptim!</title>
    <description>The latest articles on DEV Community by alokz diptim! (@aloksdiptim).</description>
    <link>https://dev.to/aloksdiptim</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%2F39940%2F63ce0141-e4a0-4757-936c-8100f5396f69.jpeg</url>
      <title>DEV Community: alokz diptim!</title>
      <link>https://dev.to/aloksdiptim</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aloksdiptim"/>
    <language>en</language>
    <item>
      <title>How to remove duplicates records in SQL (ROW_NUMBER, Partition, CTE) Part 1</title>
      <dc:creator>alokz diptim!</dc:creator>
      <pubDate>Sun, 03 Sep 2023 02:39:25 +0000</pubDate>
      <link>https://dev.to/aloksdiptim/how-to-remove-duplicates-records-in-sql-rownumber-partition-cte-part-1-5hep</link>
      <guid>https://dev.to/aloksdiptim/how-to-remove-duplicates-records-in-sql-rownumber-partition-cte-part-1-5hep</guid>
      <description>&lt;p&gt;&lt;a href="https://i.giphy.com/media/3oKIPnAiaMCws8nOsE/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/3oKIPnAiaMCws8nOsE/giphy.gif" alt="SQL" width="360" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will begin by explaining the &lt;code&gt;ROW_NUMBER&lt;/code&gt; function in SQL, which is used to assign sequential values to rows in a table. &lt;br&gt;
&lt;a href="https://i.giphy.com/media/RILswLs9YVSc32SS7l/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/RILswLs9YVSc32SS7l/giphy.gif" alt="sequential" width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The crucial concept here is the sequential increment applied to rows within a table. It's important to note that this function can be applied to temporary tables, tables without traditional IDs, or even tables with unique identifiers (UIDs).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/PlgjaVXdwwTcILCLXH/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/PlgjaVXdwwTcILCLXH/giphy.gif" alt="Crucial to note" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Typically, &lt;code&gt;ROW_NUMBER&lt;/code&gt; is a function that can be used without a parameter, so it can be declared as &lt;code&gt;ROW_NUMBER()&lt;/code&gt;. &lt;br&gt;
&lt;a href="https://i.giphy.com/media/l1JN3A18lxDIDF10k/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/l1JN3A18lxDIDF10k/giphy.gif" alt="Row" width="480" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next crucial keyword is "OVER," which is used in conjunction with functions in SQL. It is required here to determine how the sets of rows in the table will be arranged. In most cases, it specify how we want to arrange the table.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/hT0F0WBLHAOR2tXqjG/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/hT0F0WBLHAOR2tXqjG/giphy.gif" alt="Over arrangements" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, the &lt;code&gt;OVER&lt;/code&gt; function requires two parameters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OVER ([PARTITION BY value_expression] [order_by_clause])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, our focus will be on the ORDER BY clause, with a mention of the &lt;code&gt;PARTITION&lt;/code&gt; BY clause later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gP01NQ8X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/abjadkpmk665h7o26amf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gP01NQ8X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/abjadkpmk665h7o26amf.jpg" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In tables like this, the IDs are sequential, so we may not necessarily need the "&lt;code&gt;row_number&lt;/code&gt;" for simple operations such as ordering the rows. &lt;br&gt;
&lt;a href="https://i.giphy.com/media/dXFKDUolyLLi8gq6Cl/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/dXFKDUolyLLi8gq6Cl/giphy.gif" alt="true" width="480" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It can be waived in such cases but is typically used in more advanced scenarios.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--w7YLGuIO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s00i7mky02eq62t8r2qs.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--w7YLGuIO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s00i7mky02eq62t8r2qs.jpeg" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, tables with unique IDs like this require a &lt;code&gt;Row_Number&lt;/code&gt; because they are not sequential. I can't even count them correctly if there are more than 2000 rows. &lt;br&gt;
&lt;a href="https://i.giphy.com/media/dvsgRsiCId0VjLUsSp/giphy-downsized-large.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/dvsgRsiCId0VjLUsSp/giphy-downsized-large.gif" alt="Cannot count" width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, in order to perform further logic on this table, we may need to generate a &lt;code&gt;Row_Number&lt;/code&gt; for it.&lt;/p&gt;

&lt;p&gt;Our SQL table, which is named "&lt;code&gt;Cars&lt;/code&gt;," has two columns: "&lt;code&gt;Id&lt;/code&gt;" and "&lt;code&gt;Name&lt;/code&gt;."&lt;/p&gt;

&lt;p&gt;If we intend to fetch the rows, we would typically write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * FROM Cars;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, if we want to include the &lt;code&gt;RowNumber&lt;/code&gt;, you can use the &lt;code&gt;ROW_NUMBER()&lt;/code&gt; function in your query. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
Id, Name,
ROW_NUMBER() OVER(ORDER BY Id) AS RowNumber
FROM Cars;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This query will return the rows from the "&lt;code&gt;Cars&lt;/code&gt;" table along with a &lt;code&gt;RowNumber&lt;/code&gt; column that assigns a unique number to each row based on the "&lt;code&gt;Id&lt;/code&gt;" column's order.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---k5cXVZ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/szsbkfjm5e18t3kt3mxo.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---k5cXVZ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/szsbkfjm5e18t3kt3mxo.jpeg" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, this gets a bit more interesting&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/qESBZRcLXrFUbE9r8Z/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/qESBZRcLXrFUbE9r8Z/giphy.gif" alt="interesting" width="480" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will be posting the next series shortly.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>[algorithm] Multiple pointers pattern explained! (EPISODE 1)</title>
      <dc:creator>alokz diptim!</dc:creator>
      <pubDate>Thu, 29 Apr 2021 22:28:22 +0000</pubDate>
      <link>https://dev.to/aloksdiptim/algorithm-multiple-pointers-pattern-explained-episode-1-44bf</link>
      <guid>https://dev.to/aloksdiptim/algorithm-multiple-pointers-pattern-explained-episode-1-44bf</guid>
      <description>&lt;p&gt;This is part of my quick series on algorithm --- with a lot of images to buttress the point. There are many ways of searching through an array. The simplest and obvious is using a loop! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/xThuWu82QD3pj4wvEQ/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/xThuWu82QD3pj4wvEQ/giphy.gif" alt="loop"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But the concern it raises is when the iterations are overused -- Loop inside a loop has an effect on how our program runs on a large scale of data. (N square time complexity)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;For Loop
    For Loop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So there ought to be a better way of searching through an &lt;strong&gt;ordered&lt;/strong&gt; list&lt;/p&gt;

&lt;p&gt;Let's look at an example of an array { 2, 3, 7, 9, 17, 1, 5 } in which we need to find the two sums of the array element that gives us 10!&lt;/p&gt;

&lt;p&gt;Pretty easy ei?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/S7QCxPt128HRKRAJPo/giphy-downsized.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/S7QCxPt128HRKRAJPo/giphy-downsized.gif" alt="easy"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looking at the component of the array,&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%2Fuploads%2Farticles%2F3lzhb3hk9vrfdgvdebdl.jpeg" 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%2Fuploads%2Farticles%2F3lzhb3hk9vrfdgvdebdl.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;7 + 3 and 9 + 1 will both give 10&lt;/p&gt;

&lt;p&gt;First and foremost, we start with the zero-based index and search through the whole array list. In simple term, it is the &lt;em&gt;summation&lt;/em&gt; of the zero-based element with every single element in the array list&lt;/p&gt;

&lt;p&gt;DAMN! we didn't see it!&lt;/p&gt;

&lt;p&gt;.......Moving to the next index........&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%2Fuploads%2Farticles%2F4lgz51umkiru34mzvve3.jpeg" 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%2Fuploads%2Farticles%2F4lgz51umkiru34mzvve3.jpeg" alt="NaivePattern"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pretty much the summation of all the elements in the array with the first index and we didn't see it. We decided to shift the index by 1 and rescan through the array&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%2Fuploads%2Farticles%2F4hyqtipj1qjpov0xw1bi.jpeg" 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%2Fuploads%2Farticles%2F4hyqtipj1qjpov0xw1bi.jpeg" alt="Native2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yes!! we found it.&lt;/p&gt;

&lt;p&gt;But assuming the array has close to 1 Million elements then we need to scan through the array list, and move the start/correlation index by 1 and rescan through the one million. ~ Repeat.~ (That's time and resource poor performance)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; class Program
    {
        static void Main(string[] args)
        {
           int[] result = SumArray(new int[] { 2, 3, 7, 9, 17, 1, 5 }, 10);

            Console.WriteLine($"{result[0]}, {result[1]}");

            Console.ReadLine();
        }

        private static int[] SumArray(int[] array, int luckySum)
        {
            for (int i = 0; i &amp;lt; array.Length; i++) //Use this to get the index of each element
            {
                for (int j = i+1; j &amp;lt; array.Length; j++) //use this loop to scan through the array
                {
                    int firstVal = array[i];
                    int secondVal = array[j];

                    int sum = firstVal + secondVal;

                    if (sum == luckySum)
                        return new int [] { array[i], array[j]};
                }
            }

            return new int[] { };
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So not efficient therefore we need to discard that approach. (unless you working with an unordered list)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/kDOFe1XbfBXMw9dgc2/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/kDOFe1XbfBXMw9dgc2/giphy.gif" alt="discard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then give room for the &lt;strong&gt;multiple/double pointer approach&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To be explained in the next episode.... &lt;em&gt;stay tuned&lt;/em&gt;&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>pointers</category>
    </item>
    <item>
      <title>What are SQL Indexes and how to create one? (For Beginners) </title>
      <dc:creator>alokz diptim!</dc:creator>
      <pubDate>Mon, 06 Jan 2020 11:51:14 +0000</pubDate>
      <link>https://dev.to/aloksdiptim/what-are-sql-indexes-and-how-to-create-one-for-beginners-3lg5</link>
      <guid>https://dev.to/aloksdiptim/what-are-sql-indexes-and-how-to-create-one-for-beginners-3lg5</guid>
      <description>&lt;p&gt;Indexes are lookup tables that when used speed up data retrival within a voluminous table. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3xv1pXnQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jwpermxdvk91sm5wws1a.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3xv1pXnQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jwpermxdvk91sm5wws1a.jpg" alt="Index SQL 1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Wbr9hJbn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/qjzshvya35dnx3kudgra.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Wbr9hJbn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/qjzshvya35dnx3kudgra.jpg" alt="Index SQL 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZX7pLfdh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/eq9ggpmf6fl73k5z84i7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZX7pLfdh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/eq9ggpmf6fl73k5z84i7.jpg" alt="Index SQL 3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'll appreciate your feedback so I can improve on the sketches. &lt;/p&gt;

</description>
      <category>sql</category>
      <category>howindexworksinsql</category>
      <category>sqlindexexample</category>
      <category>sqlindexesexplained</category>
    </item>
    <item>
      <title>Where Javascript Coercion went wrong?</title>
      <dc:creator>alokz diptim!</dc:creator>
      <pubDate>Wed, 02 Jan 2019 08:20:24 +0000</pubDate>
      <link>https://dev.to/aloksdiptim/where-javascript-coercion-went-wrong-2dmj</link>
      <guid>https://dev.to/aloksdiptim/where-javascript-coercion-went-wrong-2dmj</guid>
      <description>

&lt;p&gt;Coercion is unknowingly the conversion of a datatype to another with the use of the Javascript engine. One of the few surprises in Javascript. Now, this behaves differently for various operators and data types such as:&lt;/p&gt;

&lt;ul&gt; 
&lt;li&gt; + Operator &lt;/li&gt;
&lt;li&gt;- Operator&lt;/li&gt;
&lt;li&gt;Boolean&lt;/li&gt;
&lt;li&gt;Equality signs&lt;/li&gt;
&lt;li&gt;Arrays&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It happens mostly because of the dynamic type declaration of javascript variable. The use of &lt;b&gt;var&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;With the use of other programming languages such as c#, If we make use of numbers and strings as data types, then, compile-time ought to show us the error before runtime.&lt;/p&gt;

&lt;p&gt;So let’s dive in into each instance of Javascript coercion:&lt;/p&gt;

&lt;ol&gt; 

&lt;li&gt; From practice, the + operator returns strings, so the Javascript coerce the operands to strings.

Example: 3 + “90” will return 390
&lt;/li&gt;

&lt;li&gt;Negative sign acts as a number, and it coerces the operand to a  number instead 

 Example: 90 - “3” will return 87
&lt;/li&gt;

&lt;li&gt; Boolean, yes!
&lt;ul&gt; 

&lt;li&gt;The or/and logic gates&lt;/li&gt;

&lt;li&gt;Apple || “orange” returns Apple which is the first value for the or operator and also because it’s true.&lt;/li&gt;

&lt;li&gt;
If it were (undefined| “”| 0| false) || “orange” then orange would be returned.


&lt;/li&gt;

&lt;li&gt;So you can write a function such as this:

         &lt;code&gt;Function Whatsup(nickname){
            Nickname = nickname || “Stranger.”;
            console.log(“Hey ” + nickname);
                }

Whatsup();

&lt;/code&gt;

Since nickname would be undefined and then false, the console will print out “Hey Stranger.”
&lt;/li&gt;

&lt;/ul&gt;
-&amp;gt;&amp;gt; and for the “and” operator;
It returns the second value because it’s always false; 
&lt;/li&gt;

&lt;li&gt;Equality checks for values and types

== checks for values, so coercion still occurs.

&lt;code&gt;If (44 == “44”)&lt;/code&gt; will return true but if the triple operator equality sign is used instead, it will return false.

Ex:If &lt;code&gt;(44 === “44”)&lt;/code&gt; returns false;
&lt;/li&gt;

&lt;li&gt;The Array will return Nan for the - operator 
Ex; &lt;code&gt; [“Right Now”] - [“Later”]&lt;/code&gt; will return Nan(Not a Number)
While &lt;code&gt;[“Right Now”] + [“Later”]&lt;/code&gt; will concatenate and return RightNowLater as a string
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Remember the + operator always return strings as their value.&lt;/p&gt;

&lt;p&gt;So in an instance where we have:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(1 &amp;lt; 4 &amp;lt; 3); &lt;/code&gt;it will return true instead of false because the javascript sees it as:&lt;br&gt;
&lt;code&gt;console.log(true &amp;lt; 3);&lt;/code&gt;&lt;br&gt;
“true” would be coerced to 1 and when compared will be 1 &amp;lt; 3 which will be true.&lt;/p&gt;

&lt;p&gt;Here are some of the weird behaviours of coercion.&lt;/p&gt;

&lt;p&gt;They are best tackled with strict equality operator sign, === &lt;/p&gt;

&lt;p&gt;But then again, coercion may not only be with the comparison but also how javascript checks for a boolean value.&lt;br&gt;
To check how Javascript coerce output, check out Number(“”), Number(), or Boolean(undefined) and see what it coerce to with the given results.&lt;br&gt;
Ex: I can check,&lt;br&gt;
&lt;code&gt;&lt;br&gt;
boolean("0");  that will be coerce to false&lt;br&gt;
Boolean(undefined); will be coerce to false&lt;br&gt;
Number("3") will be coerce to 3;&lt;br&gt;
Number("Hello") will be coerce to NaN&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Also checking the precedence matters as well.&lt;/p&gt;

&lt;p&gt;Thanks and that’s all about Coercion.&lt;/p&gt;

&lt;p&gt;If you love/like, please share/comment. Thanks!&lt;/p&gt;


</description>
      <category>javascript</category>
      <category>coercion</category>
      <category>webdev</category>
      <category>technology</category>
    </item>
    <item>
      <title>Linear Search with c#</title>
      <dc:creator>alokz diptim!</dc:creator>
      <pubDate>Fri, 03 Nov 2017 16:13:35 +0000</pubDate>
      <link>https://dev.to/aloksdiptim/linear-search-with-c-b6c</link>
      <guid>https://dev.to/aloksdiptim/linear-search-with-c-b6c</guid>
      <description>

&lt;div class="highlight"&gt;&lt;pre class="highlight csharp"&gt;&lt;code&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Program&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;linearIndex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ReadLine&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;linearIndex&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;searchNumber&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;index&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;intArray&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
        &lt;span class="m"&gt;47&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;56&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;38&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;17&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;58&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;56&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;38&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;55&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;33&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;48&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;45&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

       &lt;span class="m"&gt;38&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;49&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;47&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;52&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;45&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;46&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;55&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;19&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;55&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;39&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;41&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;43&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="m"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;39&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;33&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;21&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;36&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

         &lt;span class="n"&gt;l1&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;searchNumber&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="n"&gt;intArray&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"found at! : {0}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;

            &lt;span class="n"&gt;index&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;index&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;intArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;goto&lt;/span&gt; &lt;span class="n"&gt;l1&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;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Not found at any Index"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;

            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="m"&gt;0&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;p&gt;The console app started from the main method and I passed in an int 0 to check against the arrayList,&lt;/p&gt;

&lt;p&gt;Well, there is a comparison and as long as the index of the array is less than the array length, then we are good to continue the search.&lt;/p&gt;

&lt;p&gt;If the option is maxed out then that means we didn't get to see the number. &lt;/p&gt;


</description>
      <category>c</category>
      <category>linearsearch</category>
    </item>
    <item>
      <title>Binary search using c#</title>
      <dc:creator>alokz diptim!</dc:creator>
      <pubDate>Fri, 03 Nov 2017 09:35:21 +0000</pubDate>
      <link>https://dev.to/aloksdiptim/binary-search-using-c-5i2</link>
      <guid>https://dev.to/aloksdiptim/binary-search-using-c-5i2</guid>
      <description>

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2MGNDgtx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/0i8tqf0sjtadcdm51m3x.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2MGNDgtx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/0i8tqf0sjtadcdm51m3x.jpg" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  I'll be breaking down the documentation if you need help.
&lt;/h4&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public static int BinarySearch(int arraySize, int targetNumber)
    {

        Random random = new Random();
        int[] figures = new int[arraySize];

        while (!figures.Contains(targetNumber))
        {
            for (int i = 0; i &amp;lt; figures.Length; i++)
            {
                figures[i] = random.Next(0, 15);
            }
        }

        //SORTING OUT THE ARRAY
        Array.Sort(figures);

        int minimum = 0;
        int maximum = figures.Length - 1;

        l1:

        int center = (maximum + minimum) / 2;

        if (figures[center] == targetNumber)
        {
            return center;
        }

        if (minimum &amp;gt; maximum)
        {
            Console.WriteLine("This kind of Array doesnt exist and this is false. Please add some element to the element. Thanks!");
        }

        if (figures[center] &amp;lt; targetNumber)
        {
            minimum = center + 1;
        }

        if (figures[center] &amp;gt; targetNumber)
        {
            maximum = center - 1;
        }

        if (figures[center] == targetNumber)
        {
            return center;
        }

        goto l1;

    }

    static void Main(string[] args)
    {
        Console.WriteLine(BinarySearch(10, 8));

        Console.WriteLine("The End");
        Console.Read();
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;


</description>
      <category>c</category>
      <category>algorithm</category>
      <category>binarysearch</category>
    </item>
  </channel>
</rss>
