<?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: Kamal Sharma</title>
    <description>The latest articles on DEV Community by Kamal Sharma (@letsjuscode).</description>
    <link>https://dev.to/letsjuscode</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%2F579985%2Fa1c90829-0d51-4bf8-9d6d-50346aeac4e8.png</url>
      <title>DEV Community: Kamal Sharma</title>
      <link>https://dev.to/letsjuscode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/letsjuscode"/>
    <language>en</language>
    <item>
      <title>Add Two Numbers Represented by Linked Lists</title>
      <dc:creator>Kamal Sharma</dc:creator>
      <pubDate>Wed, 22 Dec 2021 07:55:43 +0000</pubDate>
      <link>https://dev.to/letsjuscode/add-two-numbers-represented-by-linked-lists-1leg</link>
      <guid>https://dev.to/letsjuscode/add-two-numbers-represented-by-linked-lists-1leg</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;Given 2 numbers, where each digit is represented by nodes of a LinkedList, find the sum of the 2 numbers represented as LinkedList.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample Test Cases&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Input 1:&lt;br&gt;
firstList = 7 5 9 4 6&lt;br&gt;
secondList = 8 4&lt;/p&gt;

&lt;p&gt;Output 1: result = 5 0 0 5 &lt;/p&gt;

&lt;p&gt;Adding the linked lists in the above manner with the rules of sum and carry of addition, we get the resultant linked-list as 5 -&amp;gt; 0 -&amp;gt; 0 -&amp;gt; 5 -&amp;gt; 6.&lt;/p&gt;

&lt;p&gt;Input 2:&lt;br&gt;
firstList = 0&lt;br&gt;
secondList = 0&lt;br&gt;
Output 2:&lt;br&gt;
result = 0&lt;/p&gt;

&lt;p&gt;Explanation 2:&lt;br&gt;
Both the linked lists in the above example represent the number 0, so the result is also a single node with the value 0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach&lt;/strong&gt;&lt;br&gt;
We approach this problem as follows. We will perform a traversal on both the lists and append zeros on the list which has a lesser number of digits till both numbers have an equal number of digits. Then we can recursively start from the start nodes of both the lists, where the function recursively moves ahead on both the lists till we reach the end. In the process of recursion, we will keep creating new nodes which will store the sum of the digits, and the recursive function returns the carry onto the next node for the sum operation.&lt;br&gt;
The algorithm is as described below:&lt;/p&gt;

&lt;p&gt;Perform a traversal on both the linked lists and make the shorter list of length equal to the long list by appending zeros to its end.&lt;/p&gt;

&lt;p&gt;Start a recursive function from the start nodes of both the lists, where the function will further call the next nodes of the list.&lt;br&gt;
The recursion continues till we reach the end of a linked list.&lt;br&gt;
While continuing our recursion, we will keep adding new nodes which will store the sum of digits of our result, and the recursive function will return the carry to the next step in each recursive call.&lt;br&gt;
Run the code with InterviewBit's &lt;a href="https://www.interviewbit.com/online-cpp-compiler/"&gt;Online C++ Compiler&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  C++ Code
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// class Node {
// public:
//     int data;
//     Node* next;
// };
Node * addTwoLists(Node * first, Node * second) {
  Node * res = NULL;
  Node * temp;
  Node * prev = NULL;
  int carry = 0, sum = 0;
  while (first != NULL || second != NULL) {
    sum = carry;
    sum += first != NULL ? first -&amp;gt; data : 0;
    sum += second != NULL ? second -&amp;gt; data : 0;
    if (sum &amp;gt;= 10) {
      carry = 1;
    } else {
      carry = 0;
    }
    sum %= 10;
    temp = newNode(sum);
    if (res != NULL) {
      prev -&amp;gt; next = temp;
    } else {
      res = temp;
    }
    prev = temp;
    if (first) {
      first = first -&amp;gt; next;
    }
    if (second) {
      second = second -&amp;gt; next;
    }
  }

  if (carry &amp;gt; 0)
    temp -&amp;gt; next = newNode(carry);
  return res;
}

Node * reverse(Node * head) {
  if (head == NULL || head -&amp;gt; next == NULL) {
    return head;
  }
  Node * rest = reverse(head -&amp;gt; next);
  head -&amp;gt; next -&amp;gt; next = head;
  head -&amp;gt; next = NULL;
  return rest;
}

Node * solve(Node * list1, Node * list2) {
  list1 = reverse(list1);
  list2 = reverse(list2);
  Node * added = addTwoLists(list1, list2);
  return added;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Java Code
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*
static class Node {
    int data;
    Node next;

    Node(int d) {
        data = d;
        next = null;
    }
}
*/
public static Node addTwoLists(Node first, Node second) {
  Node start1 = new Node(0);
  start1.next = first;
  Node start2 = new Node(0);
  start2.next = second;
  addPrecedingZeros(start1, start2);
  Node result = new Node(0);
  if (sumTwoNodes(start1.next, start2.next, result) == 1) {
    Node dummy = new Node(1);
    dummy.next = result.next;
    result.next = dummy;
  }
  return result.next;
}
public static int sumTwoNodes(Node first, Node second, Node result) {
  if (first == null) {
    return 0;
  }
  int sum = 0;
  sum += first.data;
  sum += second.data;
  sum += sumTwoNodes(first.next, second.next, result);
  Node dummy = new Node(sum % 10);
  dummy.next = result.next;
  result.next = dummy;
  return sum / 10;
}
public static void addPrecedingZeros(Node start1, Node start2) {
  Node next1 = start1.next;
  Node next2 = start2.next;
  while (next1 != null &amp;amp;&amp;amp; next2 != null) {
    next1 = next1.next;
    next2 = next2.next;
  }
  if (next1 == null) {
    if (next2 != null) {
      while (next2 != null) {
        Node dummy = new Node(0);
        dummy.next = start1.next;
        start1.nedummy dummy;
        next2 = next2.next;
      }
    }
  } else if (next2 == null) {
    if (next1 != null) {
      while (next1 != null) {
        Node dummy = new Node(0);
        dummy.next = start2.next;
        start2.next = dummy;
        next1 = next1.next;
      }
    }
  }
}
public static Node solve(Node first, Node second) {
  Node result = addTwoLists(first, second);
  return result;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reference - &lt;a href="https://www.interviewbit.com/blog/add-two-numbers-represented-by-linked-lists/"&gt;InterviewBit&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>cpp</category>
      <category>python</category>
    </item>
    <item>
      <title>C++ and Java Code for Sieve of Eratosthenes</title>
      <dc:creator>Kamal Sharma</dc:creator>
      <pubDate>Fri, 01 Oct 2021 06:59:40 +0000</pubDate>
      <link>https://dev.to/letsjuscode/c-and-java-code-for-sieve-of-eratosthenes-2i4</link>
      <guid>https://dev.to/letsjuscode/c-and-java-code-for-sieve-of-eratosthenes-2i4</guid>
      <description>&lt;p&gt;The sieve of Eratosthenes is one of the most efficient ways to find all primes smaller than n when n is smaller than 10 million or so. Following is the algorithm to find all the prime numbers less than or equal to a given integer n by the Eratosthenes method: &lt;/p&gt;

&lt;p&gt;When the algorithm terminates, all the numbers in the list that are not marked are prime. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Firstly write all the numbers from  2,3,4…. n&lt;/li&gt;
&lt;li&gt;Now take the first prime number and mark all its multiples as visited.&lt;/li&gt;
&lt;li&gt;Now when you move forward take another number which is unvisited yet and then follow the same step-2 with that number.&lt;/li&gt;
&lt;li&gt;All numbers in the list left unmarked when the algorithm ends are referred to as prime numbers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  C++ Implementation
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;SieveOfEratosthenes&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;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;prime&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&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="n"&gt;memset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prime&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

    &lt;span class="k"&gt;for&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;p&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="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&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;prime&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;for&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;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;prime&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false&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;for&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;p&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="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&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;prime&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
            &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&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;h2&gt;
  
  
  Java Implementation
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SieveOfEratosthenes&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;sieveOfEratosthenes&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;prime&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;];&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++)&lt;/span&gt;
            &lt;span class="n"&gt;prime&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;++){&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prime&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                    &lt;span class="n"&gt;prime&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++)&lt;/span&gt;
        &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prime&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" "&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Time complexity of Sieve of Eratosthenes :&lt;br&gt;
o(n * (log(log(n)))).&lt;/p&gt;

&lt;p&gt;Space complexity: O(1)&lt;br&gt;
Source - &lt;a href="https://www.interviewbit.com/blog/sieve-of-eratosthenes/"&gt;InterviewBit&lt;/a&gt;&lt;/p&gt;

</description>
      <category>primenumbers</category>
      <category>java</category>
      <category>cpp</category>
    </item>
    <item>
      <title>HTML vs XML</title>
      <dc:creator>Kamal Sharma</dc:creator>
      <pubDate>Thu, 25 Feb 2021 15:26:17 +0000</pubDate>
      <link>https://dev.to/letsjuscode/html-vs-xml-1afa</link>
      <guid>https://dev.to/letsjuscode/html-vs-xml-1afa</guid>
      <description>&lt;p&gt;HTML and  XML are &lt;strong&gt;platform-independent markup languages&lt;/strong&gt;. They are both based on SGML - Standard Generalized Markup Language. HTML was designed to facilitate transferring of web-based documents.&lt;/p&gt;

&lt;p&gt;XML was later developed to provide interoperability with HTML and simplify its implementation. HTML focuses on describing the web page structure and displaying information. Whereas, XML focuses on storing and transferring this information.&lt;/p&gt;

&lt;p&gt;If you are preparing for the HTML interview, you could maybe check the &lt;a href="https://www.interviewbit.com/html-interview-questions/"&gt;InterviewBit&lt;/a&gt; guide on HTML to clear the interview&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt; or &lt;strong&gt;Hypertext Markup Language&lt;/strong&gt; is popularly used to create web pages and web applications. It is the basis for all web pages. It describes web page structure It is a markup language and consists of various HTML elements composed of tags and their content. It is a hypertext language that creates a chain of links of documents. Standard HTML pages are static. HTML5.2 is the latest version of HTML.&lt;/p&gt;

&lt;p&gt;HTML is easy to learn and use because of its simple syntax. It is supported by all browsers and is free, lightweight, and user-friendly.&lt;/p&gt;

&lt;p&gt;However, HTML cannot be used to create dynamic pages. Also, HTML is not centralized - all web pages need to be programmed separately.&lt;/p&gt;

&lt;p&gt;Let’s see a simple example for an HTML program&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE HTML&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;meta charset="UTF-8"&amp;gt;
&amp;lt;HTML&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;Welcome to the world&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;h1&amp;gt;Web Development&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;HTML vs XML&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;    
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h2&gt;
  
  
  XML
&lt;/h2&gt;

&lt;p&gt;XML or eXtensible Markup Language’ is also used to create web pages and web applications. It is a textual data format with strong support via Unicode for several different human languages. Its design goals focus on simplicity, generality, and usability across the internet. It is dynamic. XML1.1 is the latest version of XML.&lt;/p&gt;

&lt;p&gt;It makes documents transportable across systems and applications and simplifies platform change and data sharing processes. It is extendable, easy to read and understand, and does not affect data presentation. &lt;/p&gt;

&lt;p&gt;XML is redundant and verbose compared to other text-based formats. Large data volumes can lead to high storage and transportation cost due to redundancy in XML syntax.&lt;/p&gt;

&lt;p&gt;Let’s now see an example for XML program:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version = "1.0"?&amp;gt;
&amp;lt;InterviewBit&amp;gt;
    &amp;lt;address category = "Practice"&amp;gt;
            &amp;lt;track&amp;gt;Web Development&amp;lt;/track&amp;gt;
            &amp;lt;Display&amp;gt;HTML&amp;lt;/Display&amp;gt;
            &amp;lt;transport&amp;gt;XML&amp;lt;/transport&amp;gt;
    &amp;lt;/address&amp;gt;
&amp;lt;/development&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h2&gt;
  
  
  Difference between HTML and XML
&lt;/h2&gt;

&lt;p&gt;The following table summarizes some of the key differences between HTML and XML.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;HTML&lt;/th&gt;
&lt;th&gt;XML&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;HTML stands for Hypertext Markup Language&lt;/td&gt;
&lt;td&gt;XML stands for eXtensible Markup Language&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It is a predefined markup language.&lt;/td&gt;
&lt;td&gt;It is a standard markup language that provides a framework to define other markup languages.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It is used for encoding web pages and to display data.&lt;/td&gt;
&lt;td&gt;XML is used to transport and store data.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It focuses on how data will look on the client-side.&lt;/td&gt;
&lt;td&gt;It focuses on what the data represents and describes.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It is static as it is used to display data.&lt;/td&gt;
&lt;td&gt;It is dynamic as it is used to carry information.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It offers native support.&lt;/td&gt;
&lt;td&gt;In XML, objects are expressed by conventions with the help of elements and attributes.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It has predefined tags.&lt;/td&gt;
&lt;td&gt;It supports user-defined tags.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It has a limited number of tags&lt;/td&gt;
&lt;td&gt;XML tags are extensible.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;In HTML, it is not mandatory to use a closing tag.&lt;/td&gt;
&lt;td&gt;In XML, it is mandatory to use a closing tag.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTML can ignore small errors&lt;/td&gt;
&lt;td&gt;XML does not allow errors.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It is case insensitive.&lt;/td&gt;
&lt;td&gt;It is case-sensitive.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It does not preserve whitespaces.&lt;/td&gt;
&lt;td&gt;It preserves whitespaces.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTML parsers in most web browsers accept element overlapping.&lt;/td&gt;
&lt;td&gt;In XML, elements can not overlap&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTML parsers in most web browsers accept element overlapping.&lt;/td&gt;
&lt;td&gt;In XML, elements can not overlap&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It natively recognizes the null value&lt;/td&gt;
&lt;td&gt;Xsi:nil on elements is required in an XML instance document to indicate a null value.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;In HTML, extra application code is not needed to parse text.&lt;/td&gt;
&lt;td&gt;XML DOM application and implementation code are required for mapping text back into JavaScript objects.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>html</category>
      <category>xml</category>
    </item>
  </channel>
</rss>
