- Read
- Top Stories
Latest - Tips To Secure Your AWS Account
- Bridging CeFi and DeFi: Better Risk Management and More Sustainable Wealth Generation
- 11 Tips And Tricks To Write Better Python Code
- Web 3.0 and Centralized Exchanges: How Crypto Exchanges Will Work in the Decentralized Internet Era
- EOS: Blockchain Without Hurting The Environment
- Disruption in the Tech Giants Musical Chairs
- Using Machine Learning to Build a Ride Acceptance Model for Uber
- The Big Security Picture - A Case of Integrating CSPM into XDR
- Is Tech Making HTML Editors Better Or Worse?
- Five Reasons Why BlackRock’s Bitcoin Embrace is a Big Deal
- The Essays of Adam Smith: ADAM SMITH ON THE EXTERNAL SENSES - Of the Sense of SMELLING.
- Food and Flavor: A Gastronomic Guide to Health and Good Living: Chapter XI - GASTRONOMIC AMERICA

Trending - #1- How to Hack Facebook Accounts: 5 Common Vulnerabilities
- #2- The Batman Arkham Games in Chronological Order
- #3- 14 Patterns to Ace Any Coding Interview Question
- #4- Apple CarPlay Not Working? - Here's How to Fix Common Issues
- #5- How to Hack Instagram: 5 Common Vulnerabilities
- #6- Here's How To Fix Your Ethernet If It's Not Working
- #7- 21 Best Developer Portfolio Examples
- #8- This College Prep Software Is Selling Advertising Access to Your Kids
- #9- How to Hack Roblox and Should You Do it?
- #10- How to Filter NSFW Images and Programmatically Blur Them
- #11- 9 Best Body Mods for Skyrim
- #12- How to Hack TikTok Accounts : 5 Common Vulnerabilities
- #13- 3 Ways to Crack WinRAR Password Protected Files
- #14- How Do I Build High-Volume dApps With Ultra-Low Gas Fees? Like a #BAS
- #15- How To Take Screenshots In The Browser Using JavaScript
- #16- Forcing a device to disconnect from WiFi using a deauthentication attack
- #17- The Impact, Symptoms and Management of Stress
- #18- Increase Your Conversions with these Pricing Models
- #19- 3 Best Kotor Builds Even Vader Would Approve of
- #20- JavaScript Practical Coding Challenges For Beginners

- Write
Writer Contests Writing Prompts - Learn
Self-Paced Courses Tech Deep Dives Build Skillzz - Apply Psychology of Colors
- Auto-Generate Graphics
- Build Frontend for Ethereum dApps
- Build a Private Blockchain
- Create Generative Art with Python
- Choose the Right Kubernetes Container
- Get Featured on Product Hunt without Hunter
- Go Serverless with AWS
- Hack Smart Contracts
- Host Your Git Server on Raspberry Pi
- Implement QA Properly
- Insert Binary Tree in Rust
- Learn Anything
- Measure Technical Debt
- Protect Your Code with Gulp
- Write NFT Smart Contracts

- About
- Help
- Partner
- Crypto
Trending Coins Top Crypto Stories - #1- UST/Luna Meltdown & The Lessons That I've Learned So Far
- #2- Subnets are Solving the Crypto Scalability Problem
- #3- How to Get Started on Creating Your Own Cryptocurrency
- #4- WTF is The Blockchain?
- #5- 5 Exchanges Where You Can Trade Crypto Options
- #6- Learn Blockchains by Building One
- #7- The Future of NFTs In The Web3 Economy
- #8- DeSci: Decentralized Science as Our Chance to Recover the Real Science
- #9- Version 0.3.19: A Poem
- #10- Torches Finance: A Decentralized Lending Protocol Launched on KCC
- #11- #MAXBIDDING
- #12- What is the Impact of Quantum Computing on Blockchain and Cryptocurrency?
- #13- The Difference Between Custodial And Non-Custodial Crypto Trading
- #14- Using Daml to Create Blockchain NFT-Based Customer Experiences
- #15- DeFi's Collateralized Debt Protocols
- #16- Will Liquid-Cooled Miners Dominate the 3rd Hashrate Revolution?
- #17- The Future’s Tokenized (and it’s Bright!)
- #18- Cronos Establishes $100 Million War Chest to Launch Accelerator Program
- #19- How You Could Have Potentially Saved Your Money From the UST/LUNA Disaster
- #20- Elon Musk Buys Twitter: Now Dogecoin to the Moon

- Tech Co Directory
Top Tech Companies Trending Companies - Zoetis(+3900%)
- Filter Coffee(+1700%)
- AIR(+1500%)
- Yalimart(+1500%)
- eBay(+1500%)
- 3M(+1150%)
- INTL FCStone(+750%)
- CoinKeeper(+633.3%)
- MOTIF®(+600%)
- Hum Capital(+566.7%)
- 3ilogics(+500%)
- Adobe(+380%)
- Edexy(+333.3%)
- Matellio(+320%)
- CamPay(+266.7%)
- Seekr(+260%)
- InfoPrice(+250%)
- Biorem Inc.(+200%)
- Botpress(+200%)
- Cerebral Therapeutics(+200%)

Startups Worldwide - #1 Cape Town South Africa, Africa
- #2 Copenhagen Denmark, Northern Europe
- #3 Lagos Nigeria, Africa
- #4 Jaipur India, South Asia
- #5 Johannesburg South Africa, Africa
- #6 Oakland United States, California
- #7 Waterloo Canada, Canada And Central America
- #8 Beijing China, East Asia
- #9 Krakow Poland, Eastern Europe
- #10 Wellington New Zealand, Oceania
- #11 Indianapolis, Us
- #12 Mesa, Us
- #13 Accra Ghana, Africa
- #14 Istanbul Turkey, Eastern Europe

Tech Company News Pages - Shop
- NOONIES 2022

The vast majority of algorithms of interest operate on data. Therefore, there are particular ways of organizing data that play a critical role in the design and analysis of algorithms. From that, we can say that data structures are simply ways of organizing data.

They are either **linear or non-linear**. Arrays and linked lists are examples of linear data structures. On the other hand, graphs and trees are forms of non-linear data structures.

- For example, one common data structure is the
**list**or**array**, which is an ordered sequence of values. Here’s a list of numbers: 0, 1, 1, 2, 3, 5, 8, 13. The concept of the list isn’t particular to one language, and it’s also used outside of programming in everyday life — wish lists, shopping lists, and so on.

Algorithms are recipes for logical execution of the problem. They are not the same as data structures. Algorithms are usually “better” if they work faster or more efficiently (using less time, memory, or both).

But here in this article, it’s all about **looking into non-linear data structures: graphs**

A graph is a system in which there are potentially multiple ways to get from an arbitrary point, A, to another arbitrary point, B.

A graph is normally defined as a pair of sets (V,E). V is a set of arbitrary objects called vertices or nodes, and E is a set of pairs of vertices, which we call edges or (more rarely) arcs. In an undirected graph, the edges are unordered pairs, or just sets of two vertices. I usually write **u v** instead of {u,v} to denote the undirected edge between u and v.

In a directed graph, the edges are ordered pairs of vertices. I will use **u → v**instead of (u,v) to denote the directed edge from u to v and vice versa for all edges in this article.

Graphs can also be undirected or directed, cyclic or acyclic (mostly directed), or weighted.

To visit each node or vertex which is a connected component, tree-based algorithms are used. You can do this easily by iterating through all the vertices of the graph, performing the algorithm on each vertex that is still unvisited when examined.

Two algorithms are generally used for the traversal of a graph: Depth first search (DFS) and Breadth first search (BFS).

Visualizing DFS traversal

Depth-first Search (DFS) is an algorithm for searching a graph or tree data structure. The algorithm starts at the root (top) node of a tree and goes as far as it can down a given branch (path), and then backtracks until it finds an unexplored path, and then explores it. The algorithm does this until the entire graph has been explored.

Many problems in computer science can be thought of in terms of graphs. For example, analyzing networks, mapping routes, scheduling, and finding spanning trees are graph problems. To analyze these problems, graph search algorithms like depth-first search are useful. -Source

The simplest pseudo-code would be:

Depth-first search is a common way that many people naturally use when solving problems like mazes.

First, we select a path in the maze (for the sake of this example, let’s choose a path according to some rule we lay out ahead of time) and we follow it until we hit a dead end or reach the end of the maze. If a given path doesn’t work, we backtrack and take an alternative path from a past junction, and try that path.

To turn this into a graph traversal algorithm, we basically replace “child” with “neighbor”. But to prevent infinite loops, we only want to visit each vertex once. Just like in BFS, we can use marks to keep track of the vertices that have already been visited, so we don’t visit them again. Also, just like in BFS, we can use this search to build a spanning tree with certain useful properties.

dfs(vertex v){visit(v);for each neighbor w of vif w is unvisited{dfs(w);add edge vw to tree T}}

**Here’s the Python implementation using recursion:**

This was a basic overview of how DFS works. If you want to dive deeper, there is some great stuff available all over the internet and also on Medium.

It starts at the tree root (or some arbitrary node of a graph, sometimes referred to as a ‘search key’), and explores all of the neighbor nodes at the present depth prior to moving on to the nodes at the next depth level.

The only catch here is, unlike trees, graphs may contain cycles, so we may come to the same node again. To avoid processing a node more than once, we use a boolean visited array. For simplicity, it is assumed that all vertices are reachable from the starting vertex.

What we do in a BFS is a simple step-by-step process:

- Start from a vertex
**S**. Let this vertex be at what is called…. “Level 0”. - Find all the other vertices that are immediately accessible from this starting vertex
**S**, that is they are only a single edge away (the adjacent vertices). - Mark these adjacent vertices to be at “Level 1”.
- You might be coming back to the same vertex due to a loop or a ring in the graph. If this happens, your BFS will take
**∞**time. So, you will go only to those vertices who do not have their “Level” set to some value. - Mark which is the parent vertex of the current vertex you’re at, i.e., the vertex from which you accessed the current vertex. Do this for all the vertices at Level 1.
- Now, find all those vertices that are a single edge away from all the vertices which are at “Level 1”. These new set of vertices will be at “Level 2”.
- Repeat this process until you run out of graph.\

See this — https://www.programiz.com/dsa/graph-bfs

**Python Implementation Using Queue**

An *undirected graph* is a graph in which edges have no orientation. The edge (*x*, *y*) is identical to the edge (*y*, *x*). That is, they are not ordered pairs, but unordered pairs — i.e., sets of two vertices {*x*, *y*} (or 2-multisets in the case of loops). The maximum number of edges in an undirected graph without a loop is *n*(*n* − 1)/2.

For any edge `u`

and `v`

in an undirected graph, we call u a neighbor of v and vice versa. The degree of a node is its number of neighbors. In directed graphs, we have two kinds of neighbors. For any directed edge **u — >v**, we call u a predecessor of v and v a successor of u.

Among the many properties of graphs, two are important for a great number of applications : connectivity and acyclicity. Both are based on the notion of a path.

A cyclic graph is a graph containing at least one graph cycle. **Also remember that cyclic graphs cannot be a form of tree because tree’s nodes are only visited once via DFS or BFS(traversal methods).**

An acyclic graph is a graph without cycles (a cycle is a complete circuit). When following the graph from node to node, you will never visit the same node twice.

A directed acyclic graph is an acyclic graph that has a direction as well as a lack of cycles.

A tree is a formation of Directed acyclic graph

Source — http://www.statisticshowto.com/directed-acyclic-graph/

The parts of the above graph are:

**Integer**= the set for the the Vertices.**Vertices set**= {1,2,3,4,5,6,7}.**Edge set**= {(1,2), (1,3), (2,4), (2,5), (3,6), (4,7), (5,7), (6,7)}.

A directed acyclic graph has a **topological ordering**. This means that the nodes are ordered so that the starting node has a lower value than the ending node. A DAG has a unique topological ordering if it has a directed path containing all the nodes; in this case the ordering is the same as the order in which the nodes appear in the path.

In computer science, DAGs are also called *wait-for-graphs*. When a DAG is used to detect a deadlock, it illustrates that a resources has to *wait for* another process to continue.

**How can we detect cycles in a graph?**

As it turns out, the reason that the depth-first search algorithm is particularly good at detecting cycles is because of the fact that it is efficient at finding backward edges. We’ll look in to DFS algorithm later in this article

Consider this graph as example for understanding adjacency lists and adjacency matrices

Carrying out graph algorithms using the representation of graphs by lists of edges, or by adjacency lists, can be cumbersome if there are many edges in the graph. To simplify computation, graphs can be represented using matrices. Two types of matrices commonly used to represent graphs will be presented here. One is based on the adjacency of vertices, and the other is based on incidence of vertices and edges.

Given an adjacency matrix, we can decide in Θ(1) time whether two vertices are connected by an edge just by looking in the appropriate slot in the matrix. We can also list all the neighbors of a vertex in Θ(V) time by scanning the corresponding row (or column).

**Understanding Adjacency matrix from above given image…**

Let’s understand how adjacency matrix is constructed from above given image. For simplicity I have discussed this only for vertex “a” . Same applies to all vertex.

Due to page limit, I have not included analysis for ** a → d** and

**And what about adjacency list?**

The adjacency list data structure should immediately remind you of hash tables with chaining;the two data structures are identical.

An adjacency list is an array of linked lists, one list per vertex. Each linked list stores the neighbors of the corresponding vertex.

**For example for** `**a**`

**vertex there are edges leading to neighbors as** `**b,d and e**`

**. So its respective linked list contains vertex that are connected via edge.**

Reminder → For undirected graphs, each edge(u,v) is stored twice, once in u’s neighbor list and once in v’s neighbor list; for directed graphs, each edge is stored only once.

Weighted graph. Source — https://cs.stackexchange.com

A weighted graph (or weighted digraph) is a graph (or di-graph) with numbers assigned to its edges. These numbers are called weights or costs. An interest in such graphs is motivated by numerous real-world applications, such as finding the shortest path between two points in a transportation or communication network or the **traveling salesman problem****.**

Google Maps — it’s just one big graph! Where **Edges represent streets and vertices represent crossings.**

Graph theory underlies the Internet. It’s very heavily used in networking code (building routing tables, etc), but it comes up all kinds of places like building an internet search engine, or a social media platform.

- All trees are graphs. Not all graphs are trees.
- A tree is a kind of graph, Only if it’s connected. For instance, the graph consisting of the vertices A and B and no edges is not a tree, although it is an acyclic graph.
- A single vertex is also considered a tree (no cycles, vacuously connected). So two unconnected vertices makes a forest of two trees.
- A tree is a special kind of graph where there are never multiple paths, that there is always only one way to get from A to B, for all possible combinations of A and B.

Shot — https://dribbble.com/shots/3152667-Astronaut-Glove

Resources:

**Depth-First Search (DFS) | Brilliant Math & Science Wiki**_Depth-first Search (DFS) is an algorithm for searching a graph or tree data structure. The algorithm starts at the root…_brilliant.org

**GeeksforGeeks | A computer science portal for geeks**_A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and…_www.geeksforgeeks.org

**Algorithms | Computer science | Computing | Khan Academy**_We’ve partnered with Dartmouth college professors Tom Cormen and Devin Balkcom to teach introductory computer science…_www.khanacademy.org

**Linear Search Tutorials & Notes | Algorithms | HackerEarth**_Detailed tutorial on Linear Search to improve your understanding of Algorithms. Also try practice problems to test &…_www.hackerearth.com

L O A D I N G

. . . comments & more!

. . . comments & more!