<?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: Mukesh Yadav</title>
    <description>The latest articles on DEV Community by Mukesh Yadav (@mukeshwebs).</description>
    <link>https://dev.to/mukeshwebs</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%2F913513%2F2b58d071-d55b-4819-a5a0-757c8b65b882.jpeg</url>
      <title>DEV Community: Mukesh Yadav</title>
      <link>https://dev.to/mukeshwebs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mukeshwebs"/>
    <language>en</language>
    <item>
      <title>Binary Search Top Interview Problems</title>
      <dc:creator>Mukesh Yadav</dc:creator>
      <pubDate>Sun, 19 May 2024 05:52:07 +0000</pubDate>
      <link>https://dev.to/mukeshwebs/binary-search-top-interview-problems-2i65</link>
      <guid>https://dev.to/mukeshwebs/binary-search-top-interview-problems-2i65</guid>
      <description>&lt;p&gt;`// Java implementation of iterative Binary Search&lt;/p&gt;

&lt;p&gt;import java.io.*;&lt;/p&gt;

&lt;p&gt;class BinarySearch {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Returns index of x if it is present in arr[].
int binarySearch(int arr[], int x)
{
    int low = 0, high = arr.length - 1;
    while (low &amp;lt;= high) {
        int mid = low + (high - low) / 2;

        // Check if x is present at mid
        if (arr[mid] == x)
            return mid;

        // If x greater, ignore left half
        if (arr[mid] &amp;lt; x)
            low = mid + 1;

        // If x is smaller, ignore right half
        else
            high = mid - 1;
    }

    // If we reach here, then element was
    // not present
    return -1;
}

// Driver code
public static void main(String args[])
{
    BinarySearch ob = new BinarySearch();
    int arr[] = { 2, 3, 4, 10, 40 };
    int n = arr.length;
    int x = 10;
    int result = ob.binarySearch(arr, x);
    if (result == -1)
        System.out.println(
            "Element is not present in array");
    else
        System.out.println("Element is present at "
                           + "index " + result);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
`&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Searching Alogirthms</title>
      <dc:creator>Mukesh Yadav</dc:creator>
      <pubDate>Mon, 22 Aug 2022 17:20:26 +0000</pubDate>
      <link>https://dev.to/mukeshwebs/searching-alogirthms-1beo</link>
      <guid>https://dev.to/mukeshwebs/searching-alogirthms-1beo</guid>
      <description>&lt;p&gt;*&lt;em&gt;1. Linear Search *&lt;/em&gt;&lt;br&gt;
`    public static int search(int arr[], int x)&lt;br&gt;
    {&lt;br&gt;
        int n = arr.length;&lt;br&gt;
        for (int i = 0; i &amp;lt; n; i++)&lt;br&gt;
        {&lt;br&gt;
            if (arr[i] == x)&lt;br&gt;
                return i;&lt;br&gt;
        }&lt;br&gt;
        return -1;&lt;br&gt;
    }&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Driver code
public static void main(String args[])
{
    int arr[] = { 2, 3, 4, 10, 40 };
    int x = 10;

    // Function call
    int result = search(arr, x);
    if (result == -1)
        System.out.print(
            "Element is not present in array");
    else
        System.out.print("Element is present at index "
                         + result);
}`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Binary search &lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;it is faster than linear search &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>dsa</category>
    </item>
  </channel>
</rss>
