<?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: Abhiman</title>
    <description>The latest articles on DEV Community by Abhiman (@abhiman7).</description>
    <link>https://dev.to/abhiman7</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1256526%2F09864892-8b88-432d-a1a9-2a647ba915f8.png</url>
      <title>DEV Community: Abhiman</title>
      <link>https://dev.to/abhiman7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abhiman7"/>
    <language>en</language>
    <item>
      <title>JS insider and 5 falsey values</title>
      <dc:creator>Abhiman</dc:creator>
      <pubDate>Mon, 15 Jan 2024 07:07:20 +0000</pubDate>
      <link>https://dev.to/abhiman7/js-insider-and-5-falsey-values-3mli</link>
      <guid>https://dev.to/abhiman7/js-insider-and-5-falsey-values-3mli</guid>
      <description>&lt;p&gt;Unveiling the JavaScript Stack: How Code Runs and the Intricacies of Falsey Values&lt;/p&gt;

&lt;p&gt;Introduction:&lt;br&gt;
JavaScript, the language that powers the interactive and dynamic aspects of the web, has a fascinating way of executing code. In this blog, we'll take a deep dive into the JavaScript stack and explore how the code is built and executed. Additionally, we'll shed light on a fundamental concept in JavaScript – falsy values.&lt;/p&gt;

&lt;p&gt;Understanding the JavaScript Stack:&lt;br&gt;
When a JavaScript program is executed, it utilizes a data structure known as the call stack. The stack operates on a Last In, First Out (LIFO) basis, meaning the last function called is the first to finish. Let's break down the key components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Execution Context:&lt;br&gt;
Each function call creates an execution context that contains information about the function, its parameters, and local variables. These contexts are stacked on top of each other in the call stack.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Call Stack:&lt;br&gt;
The call stack keeps track of the execution flow. As functions are called, they are added to the stack, and as they complete, they are removed. This sequential process ensures a structured execution of code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Event Loop:&lt;br&gt;
JavaScript is single-threaded and uses an event loop to manage asynchronous operations. Callbacks, promises, and async/await are mechanisms that allow non-blocking code execution.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Code Implementation in the Stack:&lt;br&gt;
Now, let's explore how the JavaScript code gets implemented in the stack:&lt;/p&gt;

&lt;p&gt;Function Invocation:&lt;/p&gt;

&lt;p&gt;When a function is called, an execution context is created, including the function's parameters and local variables.&lt;br&gt;
Adding to the Stack:&lt;/p&gt;

&lt;p&gt;The execution context is pushed onto the call stack, making it the current running context.&lt;br&gt;
Executing Code:&lt;/p&gt;

&lt;p&gt;The statements inside the function are executed in sequence.&lt;br&gt;
Removing from the Stack:&lt;/p&gt;

&lt;p&gt;Once the function completes, its execution context is popped from the stack.&lt;br&gt;
Return Values:&lt;/p&gt;

&lt;p&gt;If a function returns a value, it's passed back to the calling function.&lt;br&gt;
This process repeats until the entire program has been executed.&lt;/p&gt;

&lt;p&gt;Falsey Values in JavaScript:&lt;br&gt;
In JavaScript, truthiness and falsiness are essential concepts. While certain values are inherently considered "truthy," there are five specific values that are "falsey":&lt;/p&gt;

&lt;p&gt;false: The boolean value false.&lt;br&gt;
0: The number zero.&lt;br&gt;
'' (empty string): An empty string.&lt;br&gt;
null: The absence of any object value.&lt;br&gt;
undefined: A declared variable that hasn't been assigned a value.&lt;br&gt;
Understanding falsey values is crucial when writing conditional statements, as they help determine the flow of your code.&lt;/p&gt;

&lt;p&gt;Conclusion:&lt;br&gt;
JavaScript's stack-based execution and the concept of falsy values play pivotal roles in shaping the language's behavior. By grasping these fundamental aspects, developers can write more efficient and error-resistant code. Stay tuned for more insights into the intricate workings of JavaScript!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>PQ vs SET</title>
      <dc:creator>Abhiman</dc:creator>
      <pubDate>Sun, 14 Jan 2024 17:22:36 +0000</pubDate>
      <link>https://dev.to/abhiman7/pq-vs-set-54dn</link>
      <guid>https://dev.to/abhiman7/pq-vs-set-54dn</guid>
      <description>&lt;p&gt;Understanding time complexity of Dijkstra priority queue vs set vs queue--&amp;gt;&lt;/p&gt;

&lt;p&gt;Dijkstra's Algorithm using Priority Queue:&lt;br&gt;
vector dijkstra(int V, vector&amp;gt; adj[], int S) {&lt;br&gt;
priority_queue, vector&amp;gt;,&lt;br&gt;
greater&amp;gt;&amp;gt; pq;&lt;br&gt;
vector distTo(V, INT_MAX);&lt;br&gt;
distTo[S] = 0;&lt;br&gt;
pq.push({0, S});&lt;br&gt;
while (!pq.empty()) {&lt;br&gt;
int node = pq.top().second;&lt;br&gt;
int dis = pq.top().first;&lt;br&gt;
pq.pop();&lt;br&gt;
for (auto it : adj[node]) {&lt;br&gt;
int v = it[0];&lt;br&gt;
int w = it[1];&lt;br&gt;
if (dis + w &amp;lt; distTo[v]) {&lt;br&gt;
distTo[v] = dis + w;&lt;br&gt;
pq.push({dis + w, v});&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
return distTo;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Dijkstra's Algorithm using Set:&lt;br&gt;
vector dijkstra(int V, vector&amp;gt; adj[], int S) {&lt;br&gt;
set&amp;gt; st;&lt;br&gt;
vector dist(V, 1e9);&lt;br&gt;
st.insert({0, S});&lt;br&gt;
dist[S] = 0;&lt;br&gt;
while (!st.empty()) {&lt;br&gt;
auto it = *(st.begin());&lt;br&gt;
int node = it.second;&lt;br&gt;
int dis = it.first;&lt;br&gt;
st.erase(it);&lt;br&gt;
for (auto it : adj[node]) {&lt;br&gt;
int adjNode = it[0];&lt;br&gt;
int edgW = it[1];&lt;br&gt;
if (dis + edgW &amp;lt; dist[adjNode]) {&lt;br&gt;
if (dist[adjNode] != 1e9)&lt;br&gt;
st.erase({dist[adjNode], adjNode});&lt;br&gt;
dist[adjNode] = dis + edgW;&lt;br&gt;
st.insert({dist[adjNode], adjNode});&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
return dist;&lt;br&gt;
}&lt;br&gt;
Comparison:&lt;/p&gt;

&lt;p&gt;Data Structure Used:&lt;br&gt;
The first version uses a priority_queue to efficiently extract the minimum distance node.&lt;br&gt;
The second version uses a set to maintain nodes in ascending order based on distances.&lt;/p&gt;

&lt;p&gt;Complexity:&lt;br&gt;
The first version (with the priority queue) usually has better time complexity in practice as compared to the second version.&lt;br&gt;
The second version has a higher time complexity due to the overhead of searching and erasing elements from the set.&lt;/p&gt;

&lt;p&gt;Code Length:&lt;br&gt;
The first version is generally more concise and easier to read.&lt;br&gt;
The second version involves more lines of code, mainly due to handling set operations.&lt;/p&gt;

&lt;p&gt;Efficiency:&lt;br&gt;
The first version is generally more efficient for large graphs due to the efficient extraction of the minimum element from the priority queue.&lt;br&gt;
The second version may be less efficient for large graphs due to the overhead of set operations.&lt;/p&gt;

&lt;p&gt;In conclusion, while both versions implement Dijkstra's algorithm, the version using the priority queue is typically more efficient and concise. The version using the set might be useful in certain scenarios or for educational purposes, but for practical implementations, the version with the priority queue is often preferred.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
