<?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: Ritik Sharma</title>
    <description>The latest articles on DEV Community by Ritik Sharma (@iritikdev).</description>
    <link>https://dev.to/iritikdev</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%2F509716%2Fd6d897b0-6d21-42f6-b4bf-23e0bf592422.jpg</url>
      <title>DEV Community: Ritik Sharma</title>
      <link>https://dev.to/iritikdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iritikdev"/>
    <language>en</language>
    <item>
      <title>Computer System</title>
      <dc:creator>Ritik Sharma</dc:creator>
      <pubDate>Fri, 10 Nov 2023 06:18:35 +0000</pubDate>
      <link>https://dev.to/iritikdev/computer-system-1m1j</link>
      <guid>https://dev.to/iritikdev/computer-system-1m1j</guid>
      <description>&lt;p&gt;Content is uploading...&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Encoding Schemes and Number System</title>
      <dc:creator>Ritik Sharma</dc:creator>
      <pubDate>Fri, 10 Nov 2023 06:11:35 +0000</pubDate>
      <link>https://dev.to/iritikdev/encoding-schemes-and-number-system-306p</link>
      <guid>https://dev.to/iritikdev/encoding-schemes-and-number-system-306p</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Computer keyboards have keys in human-readable forms, but - computers interpret them differently.&lt;/li&gt;
&lt;li&gt;Computers understand only binary language (0s and 1s), so keyboard inputs need to be converted.&lt;/li&gt;
&lt;li&gt;When a key is pressed, it's mapped to a unique code, which is further converted to binary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When the key 'A' is pressed, it's mapped to a decimal value 65 (code value), which is then converted to binary.&lt;/li&gt;
&lt;li&gt;Similarly, when 'अ' is pressed on a Hindi keyboard, it's mapped to a hexadecimal value 0905, with a binary equivalent of 0000100100000101.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Encoding&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Encoding is the process of converting data into an equivalent cipher using a specific code.&lt;/li&gt;
&lt;li&gt;It's important to understand why code value 65 is used for 'A' and if it's the same for all keyboards, regardless of their make.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Standard Encoding Schemes&lt;/strong&gt;&lt;br&gt;
Standard encoding schemes ensure consistency across keyboards.&lt;br&gt;
Each letter, numeral, and symbol is encoded or assigned a unique code.&lt;br&gt;
Various well-known encoding schemes will be described in the following sections.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;American Standard Code for Information Interchange (ASCII)&lt;/li&gt;
&lt;li&gt;Indian Script Code for Information Interchange (ISCII)&lt;/li&gt;
&lt;li&gt;UNICODE&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;American Standard Code for Information Interchange (ASCII)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Developed in the early 1960s to address the issue of computers not being able to communicate due to different keyboard representations.&lt;/li&gt;
&lt;li&gt;ASCII was created to standardize character representation, and it remains the most commonly used encoding scheme.&lt;/li&gt;
&lt;li&gt;Initially, ASCII uses 7 bits to represent characters. Recall that there are only 2 binary digits (0 or 1).&lt;/li&gt;
&lt;li&gt;With 7 bits, ASCII can encode 2^7 = 128 different characters and range from 0 to 127.&lt;/li&gt;
&lt;li&gt;However, ASCII can only encode the character set of the English language, limiting its applicability to other languages and character sets.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are some important ASCII codes for commonly used characters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Numbers 0-9: ASCII codes 48-57&lt;/li&gt;
&lt;li&gt;Uppercase Letters A-Z: ASCII codes 65-90&lt;/li&gt;
&lt;li&gt;Lowercase Letters a-z: ASCII codes 97-122&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>computerscience</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Stack: deep dive</title>
      <dc:creator>Ritik Sharma</dc:creator>
      <pubDate>Thu, 13 Jul 2023 15:16:19 +0000</pubDate>
      <link>https://dev.to/iritikdev/stack-deep-dive-106e</link>
      <guid>https://dev.to/iritikdev/stack-deep-dive-106e</guid>
      <description>&lt;h3&gt;
  
  
  Stack
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A stack is an ordered list in which insertion and deletion are done at one end, called top. &lt;/li&gt;
&lt;li&gt;The last element inserted is the first one to be deleted. &lt;/li&gt;
&lt;li&gt;Hence, it is called the &lt;strong&gt;Last in First out(LIFO)&lt;/strong&gt; or &lt;strong&gt;First in Last out (FILO) list&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Stack ADT
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Main stack operations&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Push (int data): Inserts data onto stack.&lt;/li&gt;
&lt;li&gt;int Pop(): Removes and returns the last inserted element from the stack.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Auxiliary stack operations&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;int Top(): Returns the last inserted element without removing it.&lt;/li&gt;
&lt;li&gt;int Size(): Returns the number of elements stored in the stack.&lt;/li&gt;
&lt;li&gt;int IsEmptyStack(): Indicates whether any elements are stored in the stack or not.&lt;/li&gt;
&lt;li&gt;int IsFullStack(): Indicates whether the stack is full or not.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Implementing Stack using Array
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include&amp;lt;bits/stdc++.h&amp;gt;
using namespace std;

class Stack {
    int size = 5;
    int *items = new int[size];
    int top = 0;

    public:
    void push(int item) {
        if(top == size) cout &amp;lt;&amp;lt; "StackOverFlowError" &amp;lt;&amp;lt; endl;
        else items[top++] = item;
    }

    int pop() {
        if(top == 0) {
            cout &amp;lt;&amp;lt; "StackUnderFlowError" &amp;lt;&amp;lt; endl;
            return 0;
            cout &amp;lt;&amp;lt;"HI" &amp;lt;&amp;lt; endl;
        }
            cout &amp;lt;&amp;lt;"2HI" &amp;lt;&amp;lt; endl;
        return items[--top];
    }

    int length() {
        return top;
    }

    void print() {
        for(int i = 0; i &amp;lt; top; i++)
            cout &amp;lt;&amp;lt; *(items + i) &amp;lt;&amp;lt; " ";
    }

    int top() {
        return items[top-1];
    }

    bool isEmpty() {
        return top == 0;
    }

    bool isFull() {
        return top == size;
    }

};


int main(int argc, char const *argv[]) {
    Stack s;
    s.push(10);
    s.push(20);
    s.push(30);

    cout &amp;lt;&amp;lt; "Size : " &amp;lt;&amp;lt; s.length() &amp;lt;&amp;lt; endl;
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Performance
&lt;/h3&gt;

&lt;p&gt;Let n be the number of elements in the stack. The complexities of stack operations with this representation can be given as:&lt;/p&gt;

&lt;p&gt;Space Complexity (for n push operations): O(n)&lt;br&gt;
Time Complexity of Push() :  O(1)&lt;br&gt;
Time Complexity of Pop() : O(1)&lt;br&gt;
Time Complexity of Size() : O(1)&lt;br&gt;
Time Complexity of IsEmpty(): O(1)&lt;br&gt;
Time Complexity of IsFull : O(1)&lt;/p&gt;

&lt;h3&gt;
  
  
  Limitations
&lt;/h3&gt;

&lt;p&gt;The maximum size of the stack must first be defined and it cannot be changed. Trying to push a new element into a full stack causes an implementation-specific exception.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stacks: Problems
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Discuss how stacks can be used for checking balancing of symbols.&lt;/li&gt;
&lt;li&gt;Discuss infix to postfix conversion algorithm using stack.&lt;/li&gt;
&lt;li&gt;Discuss postfix evaluation using stacks?&lt;/li&gt;
&lt;li&gt;Can we evaluate the infix expression with stacks in one pass?&lt;/li&gt;
&lt;li&gt;How to design a stack such that GetMinimum() should be O(1)?&lt;/li&gt;
&lt;li&gt;For Problem-5 is it possible to improve the space complexity?&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>Hackerrank Angry Professor Solutions</title>
      <dc:creator>Ritik Sharma</dc:creator>
      <pubDate>Mon, 06 Mar 2023 12:14:27 +0000</pubDate>
      <link>https://dev.to/iritikdev/hackerrank-angry-professor-solutions-2fj9</link>
      <guid>https://dev.to/iritikdev/hackerrank-angry-professor-solutions-2fj9</guid>
      <description>&lt;p&gt;A Discrete Mathematics professor has a class of students. Frustrated with their lack of discipline, the professor&lt;br&gt;
decides to cancel class if fewer than some number of students are present when class starts. Arrival times go&lt;br&gt;
from on time (arrivalTime 0) to arrived late (arrivalTime &amp;gt; 0).&lt;br&gt;
Given the arrival time of each student and a threshhold number of attendees, determine if the class is&lt;br&gt;
cancelled.&lt;/p&gt;

&lt;h2&gt;
  
  
  Python
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def angryProfessor(k, a):
    students = 0
    for i in a:
        if i &amp;lt;= 0: students += 1
    if students &amp;lt; k: print("YES")
    else: print("NO")

angryProfessor(3,[-1,-3,4,2])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  JavaScript
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function angryProfessor(k, a) {
  let students = 0;
  for (let i = 0; i &amp;lt; a.length; i++) {
    if (a[i] &amp;lt;= 0) {
      students++;
    }
  }
  if (students &amp;lt; k) {
    console.log("YES");
  } else {
    console.log("NO");
  }
}

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

&lt;/div&gt;



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



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

void angryProfessor(int k, int a[], int n) {
  int students = 0;
  for (int i = 0; i &amp;lt; n; i++) {
    if (a[i] &amp;lt;= 0) {
      students++;
    }
  }
  if (students &amp;lt; k) {
    cout &amp;lt;&amp;lt; "YES" &amp;lt;&amp;lt; endl;
  } else {
    cout &amp;lt;&amp;lt; "NO" &amp;lt;&amp;lt; endl;
  }
}

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

&lt;/div&gt;



</description>
      <category>solution</category>
      <category>hackerrank</category>
      <category>python</category>
    </item>
    <item>
      <title>🔥Building Array Data Structure in python</title>
      <dc:creator>Ritik Sharma</dc:creator>
      <pubDate>Tue, 14 Feb 2023 07:52:03 +0000</pubDate>
      <link>https://dev.to/iritikdev/building-array-data-structure-in-python-m43</link>
      <guid>https://dev.to/iritikdev/building-array-data-structure-in-python-m43</guid>
      <description>&lt;h3&gt;
  
  
  What is list?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A list in Python is a built-in(comes with python itself) data structure that stores a collection of values of any data type.&lt;/li&gt;
&lt;li&gt;Lists are ordered, mutable (i.e., can be changed), and can contain elements of different data types.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;for example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grocery = ["Sugar:1kg", "Tooth paste : 1", "masala:1kg"]
person = ["Ritik", "patna", 8, 56.32]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are some common operations and examples of how to use lists in Python:&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use?
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Creating a list:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers = [10, 20, 30]
# index =  0   1    2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Accessing list elements using an index:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(numbers[0]) # Output: 10
print(numbers[1]) # Output: 20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Accessing list elements using an -ve index:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(numbers[-1]) # Output: 30
print(numbers[-2]) # Output: 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>pwl</category>
    </item>
    <item>
      <title>Building Linked List Data Structures in Python</title>
      <dc:creator>Ritik Sharma</dc:creator>
      <pubDate>Thu, 09 Feb 2023 15:50:13 +0000</pubDate>
      <link>https://dev.to/iritikdev/building-linked-list-data-structures-in-python-56jb</link>
      <guid>https://dev.to/iritikdev/building-linked-list-data-structures-in-python-56jb</guid>
      <description>&lt;h3&gt;
  
  
  What is Linked List?
&lt;/h3&gt;

&lt;p&gt;A linked list is a linear data structure where each element, called a node, contains a reference to an object and a reference to the next node in the list. This structure allows for efficient insertion and removal of elements, as the references only need to be updated, rather than all elements being shifted in memory. Linked lists can be singly-linked, where each node only points to the next node, or doubly-linked, where each node points to both the next and previous nodes.&lt;/p&gt;

&lt;p&gt;Linked lists are often used as an alternative to arrays when the size of the data is unknown or changing frequently, as elements can be easily added or removed without the need to allocate new memory or move existing elements. Linked lists can also be used to implement various abstract data structures such as stacks, queues, and associative arrays.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a Linked List
&lt;/h3&gt;

&lt;p&gt;Each node in a linked list consists of two parts: the data and a reference to the next node in the list. To create a linked list, we first define a class for the nodes, called "Node", that has two properties: "data" and "next". The "data" property holds the element's value, while the "next" property holds the reference to the next node. Here's an example in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Node:
    def __init__(self, data):
        self.data = data
        self.next = None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we create the linked list itself, which consists of a head node that references the first node in the list, and a tail node that references the last node. &lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>frontend</category>
      <category>howto</category>
    </item>
    <item>
      <title>Red-Black Tree</title>
      <dc:creator>Ritik Sharma</dc:creator>
      <pubDate>Sun, 29 Jan 2023 17:05:22 +0000</pubDate>
      <link>https://dev.to/iritikdev/red-black-tree-5b5j</link>
      <guid>https://dev.to/iritikdev/red-black-tree-5b5j</guid>
      <description>&lt;h3&gt;
  
  
  Red-Black Tree
&lt;/h3&gt;

&lt;p&gt;Red-Black tree is a &lt;strong&gt;&lt;em&gt;self-balancing binary search tree&lt;/em&gt;&lt;/strong&gt; in which each node contains an extra bit for denoting the color of the node, either red or black. It was created in 1972 by Rudolf Bayer who termed them "symmetric binary B-trees."&lt;/p&gt;

&lt;h3&gt;
  
  
  Properties of Red-Black Tree:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Root element of Red-Black Tree is always black.&lt;/li&gt;
&lt;li&gt;Every NULL node or Leaf Nodes is black.&lt;/li&gt;
&lt;li&gt;If a red node has children then, the children or its parent are always black.&lt;/li&gt;
&lt;li&gt;Number of black Node on Any path from root to leaf is always same.&lt;/li&gt;
&lt;li&gt;Two consecutive red node should not be in Red-Black Tree.&lt;/li&gt;
&lt;li&gt;If you are inserting a new node is always a red node.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Maximum height of Red-Black Tree :
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;log n &amp;lt;= h &amp;lt;= 2log n
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Examples of Red-Black Tree:-
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Qq3i-0s8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r458riabr4bd251ddil9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Qq3i-0s8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r458riabr4bd251ddil9.png" alt="image" width="800" height="573"&gt;&lt;/a&gt;&lt;/p&gt;

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