<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Olalekan's blog]]></title><description><![CDATA[Olalekan's blog]]></description><link>https://olalekanlearns.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 31 Aug 2026 12:00:45 GMT</lastBuildDate><atom:link href="https://olalekanlearns.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Data Structure: Queues]]></title><description><![CDATA[Prerequisites:

Basic knowledge of Python

A data structure is a way to organize and store data. A queue is a linear data structure that handles data sequentially. It uses a first-in-first-out (FIFO) approach, meaning elements are processed and remov...]]></description><link>https://olalekanlearns.hashnode.dev/data-structure-queues</link><guid isPermaLink="true">https://olalekanlearns.hashnode.dev/data-structure-queues</guid><category><![CDATA[datastructure]]></category><category><![CDATA[Queues]]></category><dc:creator><![CDATA[Olalekan Adegbite]]></dc:creator><pubDate>Wed, 14 May 2025 00:30:47 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/DFgvAYbEV9k/upload/6f05c3805f93db47b1aafb02c0b65aa3.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-prerequisites">Prerequisites:</h3>
<ul>
<li>Basic knowledge of Python</li>
</ul>
<p>A data structure is a way to organize and store data. A queue is a linear data structure that handles data sequentially. It uses a first-in-first-out (FIFO) approach, meaning elements are processed and removed in the order they were added. A real-life example of a Queue is the line or queue in a banking hall, where the person in front of the cashier is served before others.</p>
<p>The process of removing an element in a queue is called dequeue while adding a new element is called enqueue. Insertion occurs in the rear while deletion is from the front.</p>
<p>Queues are practically used in a variety of domains and scenarios, for example, the instruction set of an operating system and e-commerce. Let's explore these examples:</p>
<ol>
<li><p>Operating Systems: Queues play a crucial role in managing and scheduling tasks in operating systems. Tasks or instructions can be organized in queues based on priority or other scheduling algorithms. Then the operating system executes these tasks in the order they were inserted.</p>
</li>
<li><p>E-commerce: During peak periods, like sales or promotional events, simultaneous requests can overwhelm the system. To address this, a queue manages incoming requests, processing them in the order of arrival. By placing requests in a queue, the system avoids overload and ensures all requests are eventually handled. While customers may experience a short wait in the queue, it helps maintain system stability and reliability during high-traffic periods.</p>
</li>
</ol>
<p>Here is a simple implementation of a queue:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Queue</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self</span>):</span>
        self.queue = []

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">enqueue</span>(<span class="hljs-params">self, item</span>):</span>
        self.queue.append(item)

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">dequeue</span>(<span class="hljs-params">self</span>):</span>
        <span class="hljs-keyword">if</span> len(self.queue) &lt; <span class="hljs-number">1</span>:
            <span class="hljs-keyword">return</span> <span class="hljs-literal">None</span>
        <span class="hljs-keyword">return</span> self.queue.pop(<span class="hljs-number">0</span>)

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">getFirstElement</span>(<span class="hljs-params">self</span>):</span>
        <span class="hljs-keyword">return</span> self.queue[<span class="hljs-number">0</span>]

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">size</span>(<span class="hljs-params">self</span>):</span>
        <span class="hljs-keyword">return</span> len(self.queue)
</code></pre>
<p>However, this implementation can be inefficient in certain cases. For instance, when we want to handle a certain number of requests at a time due to multiple requests.</p>
<p>Enter the circular queue.</p>
<p>By employing a circular queue, it is possible to achieve simultaneous processing of limited requests during periods of high traffic. This allows for improved performance and throughput.</p>
<p>A circular queue utilizes a fixed-sized array, two pointers to indicate the start and end positions, and the last position is connected back to the first position to make a circle.</p>
<p>Here is an implementation of a circular queue:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyCircularQueue</span>:</span>

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, k: int</span>):</span>
        self.queue = [<span class="hljs-literal">None</span>] * k
        self.start = <span class="hljs-number">-1</span>
        self.rear = <span class="hljs-number">-1</span>
        self.maxSize = k

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">enQueue</span>(<span class="hljs-params">self, value: int</span>) -&gt; bool:</span>
        <span class="hljs-keyword">if</span> self.isFull():
            <span class="hljs-keyword">return</span> <span class="hljs-literal">False</span>
        <span class="hljs-keyword">if</span> self.isEmpty():
            self.start = <span class="hljs-number">0</span>
        self.rear = (self.rear + <span class="hljs-number">1</span>) % self.maxSize
        self.queue[self.rear] = value
        <span class="hljs-keyword">return</span> <span class="hljs-literal">True</span>

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">deQueue</span>(<span class="hljs-params">self</span>) -&gt; bool:</span>
        <span class="hljs-keyword">if</span> self.isEmpty():
            <span class="hljs-keyword">return</span> <span class="hljs-literal">False</span>
        <span class="hljs-keyword">if</span> self.start == self.rear:
            self.start = <span class="hljs-number">-1</span>
            self.rear = <span class="hljs-number">-1</span>
            <span class="hljs-keyword">return</span> <span class="hljs-literal">True</span>
        <span class="hljs-keyword">else</span>:
            self.start = (self.start + <span class="hljs-number">1</span>) % self.maxSize
            <span class="hljs-keyword">return</span> <span class="hljs-literal">True</span>

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">Front</span>(<span class="hljs-params">self</span>) -&gt; int:</span>
        <span class="hljs-keyword">if</span> self.isEmpty():
            <span class="hljs-keyword">return</span> <span class="hljs-number">-1</span>
        <span class="hljs-keyword">else</span>:
            <span class="hljs-keyword">return</span> self.queue[self.start]

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">Rear</span>(<span class="hljs-params">self</span>) -&gt; int:</span>
        <span class="hljs-keyword">if</span> self.isEmpty():
            <span class="hljs-keyword">return</span> <span class="hljs-number">-1</span>
        <span class="hljs-keyword">else</span>:
            <span class="hljs-keyword">return</span> self.queue[self.rear]

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">isEmpty</span>(<span class="hljs-params">self</span>) -&gt; bool:</span>
        <span class="hljs-keyword">return</span> self.rear == <span class="hljs-number">-1</span>

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">isFull</span>(<span class="hljs-params">self</span>) -&gt; bool:</span>
        <span class="hljs-keyword">return</span> (self.rear + <span class="hljs-number">1</span>) % self.maxSize == self.start
</code></pre>
<p>In conclusion, queues are essential data structures for managing and processing data sequentially. They find practical applications in various domains, including e-commerce and operating systems. By utilizing queues, e-commerce platforms can efficiently manage order processing, handle high traffic situations, and ensure a smooth customer experience.</p>
]]></content:encoded></item><item><title><![CDATA[An overview of HTTP]]></title><description><![CDATA[HTTP stands for Hyper Text Transfer Protocol. It is a set of rules for fetching resources across the internet. With HTTP, the client or recipient initiates the request and not the other way round
A feature of HTTP is that it is stateless. This means ...]]></description><link>https://olalekanlearns.hashnode.dev/an-overview-of-http</link><guid isPermaLink="true">https://olalekanlearns.hashnode.dev/an-overview-of-http</guid><category><![CDATA[http]]></category><category><![CDATA[https]]></category><category><![CDATA[How the internet works ]]></category><category><![CDATA[Browsers]]></category><dc:creator><![CDATA[Olalekan Adegbite]]></dc:creator><pubDate>Sun, 22 Jan 2023 23:25:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1674428450091/6f8b6320-c917-4315-b1ba-e5c0179e35ed.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>HTTP stands for Hyper Text Transfer Protocol. It is a set of rules for fetching resources across the internet. With HTTP, the client or recipient initiates the request and not the other way round</p>
<p>A feature of HTTP is that it is stateless. This means that HTTP does not store data related to the request or the server response. After the server responds, that connection is lost. Thus, for each request to fetch a resource, HTTP would make a new connection to the server to fetch resources. This will be problematic for users that have to interact with certain pages. For example, i would have to log in every time i want to view my Twitter profile or feed. But, HTTP cookies solve this by allowing the creation of a session. This cookie is then shared between the client and server on each request.</p>
<p>All devices that can connect to the internet utilize HTTP. It is simple and it allows computers to communicate and transfer data across the internet</p>
]]></content:encoded></item><item><title><![CDATA[What are Data Types in JavaScript?]]></title><description><![CDATA[Data types represent features of data in a particular programming language, and they are often called values. this article will focus on the basic data types and by the end of this article, you will know the set of data types in JavaScript with examp...]]></description><link>https://olalekanlearns.hashnode.dev/what-are-data-types-in-javascript</link><guid isPermaLink="true">https://olalekanlearns.hashnode.dev/what-are-data-types-in-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[data types]]></category><category><![CDATA[-]]></category><dc:creator><![CDATA[Olalekan Adegbite]]></dc:creator><pubDate>Sat, 16 Jul 2022 21:40:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658007234202/uLVHBQJoe.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Data types represent features of data in a particular programming language, and they are often called values. this article will focus on the basic data types and by the end of this article, you will know the set of data types in JavaScript with examples. </p>
<p>There are two sets of data types in JavaScript: <strong>primitive</strong> and <strong>object</strong></p>
<p>According to <code>MDN</code>, primitives are simple and immutable values, meaning they are less complex and cannot be changed.</p>
<p><strong>Primitive data types</strong></p>
<ul>
<li>Boolean values are either <code>true</code> or <code>false</code>. They can represent the evaluation of a condition. e.g<pre><code><span class="hljs-keyword">if</span> (a <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">1</span>) {
<span class="hljs-comment">// do something</span>
} <span class="hljs-keyword">else</span> {
<span class="hljs-comment">// do another thing</span>
}
</code></pre>let's imagine <code>a</code> is a variable defined someplace, then for the <code>if</code> block to run then <code>(a === 1)</code> must evaluate to <code>true</code>, <code>a</code> must be exactly the number 1, note that this evaluation is implicit, meaning that you can't see it. if <code>a</code> is not equal to 1 then the else block runs. the literal form of Boolean values is  <code>true</code> and <code>false</code></li>
<li>Number is any integer or floating-point number.  e.g let count = 2 or let weight = 60.5</li>
<li>String is any text that is surrounded by either single or double quotes. e.g let name = 'Olalekan' or let fruits = "berry"</li>
<li>Null is a type that has only one value, <code>null</code>. e.g let total = null</li>
<li>Undefined is also a type that has only one value, undefined. e.g let age = undefined </li>
</ul>
<p>Although null and undefined can mean an absence of other values, they are different because a variable is undefined when it has been declared but not yet assigned a value. while null represents no value. </p>
<p>Some primitive values also behave like objects because they have methods. e.g strings, numbers, and Booleans. null and undefined have no methods</p>
<p><strong>Objects</strong></p>
<p> Ok, this part really confused me at first, I will refer to the object data type as reference types. These values include Objects, Functions, Array, RegExp, Date etc. object types are different because they can hold other data types. </p>
<p>They also have methods and properties attached to them. The object data type can be referred to as reference type because a variable is not actually holding the object data type but a pointer or reference to the value. A variable will only store a reference to an array, function or object, not the value itself </p>
<p>According to Nicholas Zakas, <code>an object is an unordered list of properties and value</code>. These properties are mostly strings while the value can be any other data type. When the value of a property is a function, it is called a method. </p>
<p>Reference types can be created either by using the <code>new</code> constructor e.g </p>
<pre><code><span class="hljs-keyword">let</span> obj = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Object</span>()

<span class="hljs-keyword">let</span> getInfo = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Function</span>()
</code></pre><p>or using their literal form </p>
<pre><code><span class="hljs-keyword">let</span> obj = {
  <span class="hljs-attr">name</span>: <span class="hljs-string">'Eren'</span>;
  age: <span class="hljs-number">99</span>;
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getInfo</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> <span class="hljs-string">'something'</span>
}
</code></pre><p>But creating a function with the <code>new</code>  keyword is not recommended. </p>
<p>In the example below, am assigning a pointer to the object to the <code>dad</code> variable.</p>
<pre><code>let dad = { 
  <span class="hljs-type">name</span>: "Lee" 
};

let son = <span class="hljs-keyword">user</span>; // son shares the same reference <span class="hljs-keyword">with</span> dad 

console.log(son) // <span class="hljs-keyword">Object</span> { <span class="hljs-type">name</span>: "Lee" }
</code></pre><p>Changing the object value through one variable will affect the other because they point to the same object in memory. In order to change or access the value of a reference type, we have dot notation </p>
<pre><code>let dad <span class="hljs-operator">=</span> { 
  name: <span class="hljs-string">"Lee"</span> 
};

son.<span class="hljs-built_in">name</span> <span class="hljs-operator">=</span> <span class="hljs-string">"Armin"</span>;

console.log(dad) <span class="hljs-comment">// Object { name: "Armin" }</span>
</code></pre><p>and so also is bracket notation</p>
<pre><code>let dad = { 
  <span class="hljs-type">name</span>: "Lee" 
};

son["name"] = "Armin"

console.log(dad) // <span class="hljs-keyword">Object</span> { <span class="hljs-type">name</span>: "Armin" }
</code></pre><p>Other than the common object, we also have other specialised object types such as </p>
<p> <strong>Array:</strong> an ordered list of numerically indexed values</p>
<pre><code><span class="hljs-string">let</span> <span class="hljs-string">score</span> <span class="hljs-string">=</span> [<span class="hljs-number">2</span>, <span class="hljs-number">4</span>, <span class="hljs-number">54</span>, <span class="hljs-number">343</span>]<span class="hljs-string">;</span>
</code></pre><p><strong>Date:</strong>  represents the date and time  </p>
<pre><code><span class="hljs-keyword">let</span> count = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>();
</code></pre><p><strong>Function:</strong></p>
<pre><code><span class="hljs-keyword">function</span> getData(<span class="hljs-keyword">value</span>) {
  <span class="hljs-keyword">return</span> <span class="hljs-keyword">value</span>;
}
</code></pre><p><strong>RegExp:</strong> represents a regular expression </p>
<pre><code><span class="hljs-comment">// literal form</span>
<span class="hljs-keyword">var</span> numbers <span class="hljs-operator">=</span> <span class="hljs-operator">/</span>\d<span class="hljs-operator">+</span><span class="hljs-operator">/</span>g;
</code></pre><p><strong>Further reading</strong></p>
<p><a target="_blank" href="https://nostarch.com/oojs">Nicholas Zakas book on OOP</a></p>
<p><a target="_blank" href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwjwqbW-rP74AhVErxoKHSepCWwQFnoECEMQAQ&amp;url=https%3A%2F%2Fjavascript.info%2Fobject-copy&amp;usg=AOvVaw3S3DObf980HxIveBQYy46b">Js.info on object referencing</a></p>
]]></content:encoded></item></channel></rss>