teleren/devto huggingface dataset:
Breadth-First-Search(BFS) Explained With Visualization
Tags: algorithms, bfs
Published: 2020-03-24 02:18:25

---
title: Breadth-First-Search(BFS) Explained With Visualization
published: true
date: 2020-03-22 13:08:00 UTC
tags: Algorithms,BFS
canonical_url: https://coderscat.com/breadth-first-searchbfs-explained-with-visualization
---

## BFS Overview

The Breadth-First Search(BFS) is another fundamental search algorithm used to explore the nodes and edges of a graph. It runs with time complexity of O(V+E), where `V` is the number of nodes, and `E` is the number of edges in a graph.

`BFS` is particularly useful for finding the shortest path on unweighted graphs.

## BFS Visualization on Maze

The source is at the position of left-up, and the target is the position of right-bottom.

As we can see, BFS uses the opposite strategy as with [DFS](https://coderscat.com/depth-first-searchdfs-explained-with-visualization). BFS will explore all of the neighbor nodes at the present position, then move on to the larger depth of nodes.

![bfs.gif](https://coderscat.com/wp-content/uploads/bfs.gif)

The maze is generated by [disjoint set](https://coderscat.com/using-disjoint-set-union-find-to-create-maze).

## The implementation

An implementation of BFS needs the data-structure of `queue`, with the property of First-In-First-Out.

The worst-case space complexity is O(V), where V is the number of nodes in the graph.

```cpp
#include <list>
#include <queue>
#include <iostream>
using namespace std;

class Graph {
  int V;
  list<int> *adj;

public:
  Graph(int V);
  void addEdge(int v, int w);
  bool BFS(int v, int t);
};

Graph::Graph(int V) {
  this->V = V;
  adj = new list<int>[V];
}

void Graph::addEdge(int v, int w) {
  adj[v].push_back(w);
}

bool Graph::BFS(int v, int t) {
  vector<bool> marked(V, false);
  queue<int> Q;

  Q.push(v);
  marked[v] = true;
  while(!Q.empty()) {
    int n = Q.front(); Q.pop();
    cout << n << " ";
    if(n == t) //Find a path to target
      return true;
    for(list<int>::iterator it = adj[n].begin(); it != adj[n].end(); ++it) {
      if(!marked[*it]) {
        marked[*it] = true;
        Q.push(*it);
      }
    }
  }
  return false;
}

int main() {
  Graph g(4);
  g.addEdge(0, 1);
  g.addEdge(0, 2);
  g.addEdge(1, 2);
  g.addEdge(2, 0);
  g.addEdge(2, 3);
  g.addEdge(3, 3);

  cout << "Following is Breadth First Traversal (0 -> 3): \n";
  if(g.BFS(0, 3)) cout << "\nFind a Path!" << std::endl;
  else cout << "\nNo Path!" << std::endl;
  return 0;
}
```

## References

- C: [Algorithms](https://amzn.to/33NIhBb)
- Java: [Data Structures and Abstractions with Java](https://amzn.to/2Mu2Exr)
- Python：[Problem Solving with Algorithms and Data Structures Using Python](https://amzn.to/32ywK8B)

The post [Breadth-First-Search(BFS) Explained With Visualization](https://coderscat.com/breadth-first-searchbfs-explained-with-visualization) appeared first on [CodersCat](https://coderscat.com).
Daily Developer Jokes - Sunday, Mar 22, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-03-22 13:00:28

---
title: "Daily Developer Jokes - Sunday, Mar 22, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Sunday%2C%20Mar%2022%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1259a186412.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q___: Why do developers use mechanical keyboards?

___A___: To strongly type their code.
 -->
🦠🚪 Show your COVID19 work from home desk? 👩🏻‍💻🪑
Tags: discuss, showdev, productivity
Published: 2020-03-22 12:54:50

---
title: 🦠🚪 Show your COVID19 work from home desk? 👩🏻‍💻🪑
published: true
description:  What's your COVID19 work from home desk ?
tags: discuss, showdev, productivity 
---

How's your COVID19 work from home desk setup looks like?

***Mine is here:***

{% twitter 1241580974237872128 %}

And what are your tips? 

***My tips are here:***

{% link https://dev.to/teamxenox/covid-19-self-isolation-work-from-home-and-developers-22kd %}

Go ! Go ! Go !
Das Quiz Von germod
Tags: replit, html, css, javascript
Published: 2020-03-22 12:43:43

Das Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germodDas Quiz Von germod

{% replit @Germod40/Quiz-2222 %}
Thank you
Published: 2020-03-22 12:43:00

You ask me how I find the motivation

Here is the answer:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ktzvz8radagx2cbkuioc.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/of7c8a9218burkjmozrx.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/urwu7v3ba92flfp0ct33.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/b9acmqjz74u3ux8m971v.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/349pzw2tjpkj398zqubr.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2a6smccddo1aezu28n8w.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/f0ccnkyj218nai6hp51z.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/h9da683dn35lmk8kp2um.png)

I would like to just say THANKS, for asking me how it is going and how am I.

We will all came out of this crazy situation.

PS. For sure i am forgetting some messages, i got so many and i wanted to just post some, it is impossible to post them all

🙏
Quarantine Assistant - part 4 - finished React Native project + new submission video!
Tags: showdev, hackathon, react, reactnative
Published: 2020-03-22 12:36:10

# Finally!
Woohoo! Finally, this morning at 5 AM I have submitted my app to the Hackcrisis hackathon! 🥳🎉 I have been working on my application for the past four days with my good friend, mainly at the nights after daily work and in the meantime participating in the e-learning on the university.

# The project
To remind, the project is about a mobile application for local authorities to better control and contact with people in quarantine. It is written in React Native. I hadn't been previously working with this technology, so I am feeling like a winner now, no matter of the results, because I learned something new! 😍 

# Hackathon
Hackcrisis is a european hackathon hosted by Poland to find projects for preventing economical crisis and making this hard situation easier.

# Submission video:
{% youtube XXiTLXHjz38 %}
GraphQL endpoint for getting stats of COVID19
Tags: graphql, webdev, node, showdev
Published: 2020-03-22 12:28:21

I,ve created a GraphQL endpoint for getting stats of COVID19.
Use it and send a pull on [REPO](https://github.com/sharadcodes/covid19-graphql), I'll add it to the showcase.

Also I welcome all those who want to make it better. :)

LINK OF ENDPOINT: https://sharad-gql-covid19.herokuapp.com/graphql

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/dc2neql1vs1uxfs0o22s.png)
JavaScript start-up performance using JSON.parse
Tags: javascript, perforamnce
Published: 2020-03-22 12:24:28

---
title: JavaScript start-up performance using JSON.parse
published: true
description: This optimization only applies if you have an application where the startup uses a large configuration object > 10Kb
tags: javascript, perforamnce
---

[Original article on v8.dev](https://v8.dev/blog/cost-of-javascript-2019#json)

This optimization only applies if you have an application where the startup uses a large configuration object > 10Kb.

When you load the application and the object you are using at startup it is > 10kb, then formatting the configuration object as a string and using JSON.parse during running can give you a nice performance improvement (1.7 × as much as possible fast).

<img src="https://v8.dev/_img/cost-of-javascript-2019/json.svg">


[![JSON.PARSE TRICK ](https://img.youtube.com/vi/ff4fgQxPaO0/0.jpg)](https://www.youtube.com/watch?v=ff4fgQxPaO0)
This binding in JavaScript - 1. Default binding
Tags: javascript, webdev, tutorial, learning
Published: 2020-03-22 12:06:01

This post ([This binding in JavaScript - 1. Default binding](https://www.sargalias.com/blog/this-binding-in-javascript-default-binding/)) was originally published on [Sargalias](https://www.sargalias.com).

In this series we talk about `this` binding in JavaScript.

This is a very important topic. It's also something that even experienced developers frequently get wrong and / or have to think about.

Basically in JavaScript there are 4 modes for `this` binding. Make that 5 if we include arrow functions.

In order of lowest priority to highest priority, here they are:

1. Default binding
2. Implicit binding
3. Explicit binding
4. New binding
5. Arrow functions

In this post we'll talk about default binding.

---

## How default binding works

Default binding is what happens if you don't use any other kind of binding.

If we call any function **plain / without a "." before it**, we will get default binding.

An example of a plain function call is `foo()`. Notice that the function call does not have a "." before it.

An example of a function call that's not plain is `obj.foo()`.

In the plain function call `foo()`, default binding applies.

When default binding applies, `this` is the `window` object in normal mode and `undefined` in strict mode.

## Examples for default binding

Here are some examples for default binding to illustrate the point a bit more.

### Plain function call

Consider the following code.

```js
'use strict';
function foo() {
  console.log(this);
}

foo();
```

What will the code above output?

Answer: `undefined`

Explanation:

We call our function with this code: `foo()`.

The code `foo()` is a plain function call. It does not have a "`.`" before it. Therefore default binding applies. So the answer is `window` in normal mode or `undefined` in strict mode.

As we are in strict mode, the answer is `undefined`.

### Synchronous function reference call

Consider the following code.

```js
'use strict';

const obj = {
  foo() {
    console.log(this);
  },
};

const foo = obj.foo;
foo();
```

What will the code above output?

Answer: `undefined`

Explanation:

We call our function with this code: `foo()`.

That code decides everything.

As it is a plain function call, we're using default binding, so `this` is `undefined`.

In combination with the line above it, it may be more difficult to see.

```js
const foo = obj.foo;
foo();
```

We might understandably think that it should result in `this` being `obj`.

However that's not what happens. The only thing that matters is the function call, and the function call is plain and without a "." before it.

Therefore we are using default binding and `this` becomes undefined.
We are here by your side to get through the COVID-19 pandemic
Tags: startup, entrepreneurship, challenge
Published: 2020-03-22 11:53:36

Many countries are experiencing the problems of the COVID-19 pandemic, so this post is for our users that are starting to deal with the uncertainties of the immediate future.

As you probably know in Italy, we now have a clear understanding of the weight of this problem.

Once again technology seems to be the protagonist, bringing solutions to help people stay safe but productive and the ability to work remotely is becoming a necessity for companies in certain markets to survive.

At Inspector, as modern SaaS company our job is remote by nature, so adapting to this new scenario it didn't require any special effort. Our team has been working from home for three weeks without any change in our efficiency.

Indeed, our technology is receiving a lot of attention as a concrete solution to help companies to react to the changes that will undoubtedly begin to appear for the years to come:

- Work remotely and improve team collaborations;
- Make data driven decision avoiding unnecessary risks;
- Drastically improve efficiency dealing with customer problems;

Unlike other too-complicated tools that take time to learn, time to install and configure, and require a lot of assistance and training, Inspector allows you to:

- Triple your release velocity and win the competition;
- Avoid losing customers and money due to unpredictable technical problems;
- Don't wait for users complaints to know if your applications are in trouble keeping your revenue stream more stable.

All of that, in less than one minute.

To reduce the risks to our customers, we recently introduced the 14-day money back guarantee, and more importantly, we are strengthening our commitment to customer support.

I will never stop repeating it, we are here to help, write us, send us your reports, your opinions, we will be at the forefront with all our energies to help you in case of difficulties.

We are Italian and definitely like to chat :), but we have launched our challenge to the global market and we are here to act constantly in the best direction for our customers.

# "This, too, shall pass."

The one good thing about recessions is that they end. They end because things turn around eventually. That doesn’t happen by chance. It happens because entrepreneurs believe that it can be done, and then they just do it.

I hope to hear you soon via live chat or email, thank you for stay with us in this journey.

Best,

Valerio

![](https://miro.medium.com/max/5000/1*2MNMLWMfNwwdt3APYQBqgQ.png)
We vs Virus Hackathon: Giev likez plz!
Tags: hackathon, corona
Published: 2020-03-22 11:35:03

---
title: We vs Virus Hackathon: Giev likez plz!
published: true
description: 
tags: hackathon, corona
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/ljkm61cf952zzyhejw5t.jpg
---

This weekend I'm participating in the "We vs Virus" hackathon by the German government.

[WE NEED YOUR LIKES](https://devpost.com/software/stay-at-home)

It's probably the biggest hackathon in Germany ever, with 

**over 40000 participants!** 

Anyway, my team and I are planning, designing, and implementing an app that helps people to do what many devs love:

**STAY AT HOME!**

[So I figured, you may want to support us? :D](https://devpost.com/software/stay-at-home)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/fpexe1ht4t3uqvkbq2u3.png)

The app is called "CareAnTiny" and you would care, Tamagotchi like, for a plant that grows when you are at home. It also features ideas of things you can to do at home and a leaderboard that should motivate by seeing that others stay at home too!

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6t2o6u1jbbfg6bai8rwo.png)

If we win, we get resources to turn this thing further than a prototype!

[So, anyway, would be cool if you like and share :)](https://devpost.com/software/stay-at-home)
Should I use Redux? 
Tags: discuss, javascript, redux, react
Published: 2020-03-22 11:25:17

State management is a huge and important part of a big application. In libraries like React, Redux has always been popular. 
However, in past few days I came to know about these tweets. 
{%twitter 1241525265228017670 %}
And, 
{%twitter 1241376201345765376%}
And these are quit right. Redux make the code complex. 
So, should I keep using it or **React Context** is a good alternative?
What do you say about it? Is Redux deprecated?
Projects due to COVID-19
Tags: covid19, health, productivity
Published: 2020-03-22 11:17:51

---
title: Projects due to COVID-19
published: true
description: Thread to share all projects due to COVID-19.
tags: #covid19, #health, #productivity
---

In this time of uncertainty due to COVID-19 pandemic, to be honest due to our studies although depending on the background we cannot be on the first line with doctors, nurses auxiliaries, etc, to help al alleviate the situation.

This is why I'm opening this discussion. If someone is working on a tool/project to help in this days and need contributors, please share it in a comment with a description and how we can help it.

We will overcome this and please #StayAtHome
variable passed through context does not change in the child when changing in the parent and vice versa
Tags: react
Published: 2020-03-22 10:53:50

I learned this manual https://reactjs.org/docs/context.html
And wrote this code

UserContext.js:
```
import React from 'react';
const UserContext = React.createContext();
export default UserContext;
```

App.js:

```
class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      id: '',
      name: ''
    };
  }
  componentDidMount() {
    this.getAccountData();
  }

  async getAccountData() {
    this.setState({
      id: 123,
      name: "Jacob"
    });
  }

  render() {
    return (
      <UserContext.Provider value={this.state}>
          <Account />
      </UserContext.Provider>
    );
  }
}
```

Account.js:
```
class Account extends React.Component {
  static contextType = UserContext;

  render() {
    return (
      <UserContext.Consumer>
      {user => (
      <div className="account">
          <p>{user.id} - {user.name}</p>
      </div>
      )}
      </UserContext.Consumer>
    )
  }
}
```

The user.id variable remains an empty string! I tried to manually change this.context, but this also does not work, it makes a copy as it goes. In addition, there is nothing about this in the documentation. 
Any help?
Learn Lambda Destinations combined with Amazon EventBridge using AWS CDK for truly decoupled Event Driven Architecture
Tags: cdk, aws, serverless, tutorial
Published: 2020-03-22 10:26:13

The Destined Lambda combines [Lambda Destinations](https://aws.amazon.com/blogs/compute/introducing-aws-lambda-destinations/) with [Amazon EventBridge](https://aws.amazon.com/eventbridge/) to show you that with EventBridge rules you can decouple your components in an event driven architecture and by combining it with lambda destinations you can strip out EventBridge specific code from your lambda functions themselves and decouple further.

An important point about Lambda Destinations is that they have to be executed asynchronously which is why the lambda is invoked via SNS in this pattern. To reduce custom code, I have integrated the SNS directly with API Gateway using [Apache VTL](https://velocity.apache.org/engine/1.7/vtl-reference.html).

## Architecture

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3c4m5tg2bhnd29hgklms.png)

## How To Get The Code?
* Visit [cdkpatterns.com](https://github.com/cdk-patterns/serverless/blob/master/the-destined-lambda/README.md) and clone the whole repo or browse
* Use the command line tool to install with one command "npx cdkp init the-destined-lambda"
Using attributes in Rust to suppress warnings
Tags: rust
Published: 2020-03-22 10:25:27

Warnings and errors are good. We want to be told when we're doing something wrong or something with the potential to cause problems in the future. But sometimes it's ok to turn off those warnings.

## Turning off a warning in Rust at the code level

```
fn main() {
  let mut my_variable = 'foo';
  my_variable = 'bar';
}
```

If we try to compile this block of code we will see this warning -

> **warning:** variable `my_variable` is assigned to, but never used

By adding `#[allow(unused_variables)]` above the variable declaration we can suppress this warning

But there is another warning -

> **warning:** value assigned to `my_variable` is never read

We can suppress this warning by adding  `#[allow(unused_assignments)]` above the line that reassigns `my_variable`. Or...

If we add `#[allow(unused_variables, unused_assignments)]` above the function. Our code now looks like this and gives no warnings when compiled.

```
#[allow(unused_variables, unused_assignments)]
fn main() {
  let mut my_variable = "foo";
  my_variable = "bar";
}
```

Suppressing warnings when developing can be useful as it reduces the amount of noise we need to filter out when we're trying something out or debugging. But it is important to turn these warnings back on and to address any underlying issues once our code is ready.
A Minimalistic Web Portfolio for all devs 😎
Tags: productivity, portfolio, design, webdev
Published: 2020-03-22 10:15:51


This is for developers who think

> "My work and code speak more than a Portfolio website"


A small **minimal Portfolio** for developers who are tiring of thinking about creating their own new portfolio website. Due to the Pandemic outbreaks _(as staying at home)_, I was thinking of creating a weekend fun project. While searching for ideas I came up with this. So that anyone can pull/fork this [repo](https://github.com/Sivanesh-S/portfolio-minimal/) and use it to showcase their talents.

**NO WEB DEVELOPMENT SKILLS NEEDED** (If you do have, then can customize with your skills and ideas. :smile:)

## Responsive
It is fully responsive.

[Demo](https://sivanesh-s.github.io/portfolio-minimal/)

### Laptops
<img src="https://raw.githubusercontent.com/Sivanesh-S/portfolio-minimal/master/README_DOCS/Lg.JPG"/>

### Tabs
<img src="https://github.com/Sivanesh-S/portfolio-minimal/raw/master/README_DOCS/md.JPG" width="500px">

### Mobile
<img src="https://github.com/Sivanesh-S/portfolio-minimal/raw/master/README_DOCS/sm.JPG" >

## Data for the Portfolio
You don't need to surf through HTML docs and update the data. All the data needed for your portfolio must be updated in `data.js`.

<img src="https://github.com/Sivanesh-S/portfolio-minimal/raw/master/README_DOCS/Data.JPG">
⭐️WomenTech Global Conference 2020 (Virtual)
Tags: womenintech, eventsinyourcity, contributorswanted, wecoded
Published: 2020-03-22 09:52:14

Join us to unite 100.000 women in tech worldwide.

At times like these, we believe it is even more important to stand together even when being at the same place is not possible. At times when we're advised to keep our distance, we look for new ways to connect. Therefore we decided to host the largest ever online conference for women in technology.

The measures implemented to adapt our work life to COVID-19 shed light on how flexible and dynamic people and businesses can and should be.

What lessons are learned from this period of strain and changes?
How can new technology ease the balance between work and personal life in the future?
What have we learned in the past and what would be the takeaways from the current crisis? 

Join the global event remotely with engaging talks, panel discussions and networking opportunities adjusted to all timezones.
https://www.womentech.net/women-tech-conference