Skip to main content
Filter by
Sorted by
Tagged with
3 votes
1 answer
139 views

I'm working on Python project that involves processing a very large graph - it has millions of nodes and edges. The goal is to perform a breadth-first search (BFS) or depth-first search (DFS) from a ...
ThatsNotAbhinit's user avatar
1 vote
1 answer
81 views

At my wits end here. I'm following this psuedocode from CLRS and I don't know why my final for loop doesn't keep going to give me the distance from the given source node to all other vertices. I'm so ...
Jide Fadairo's user avatar
0 votes
1 answer
122 views

I have created a search function following the BFS algorithm but found a problem, it works fine on other problem domains but on this problem domain I am only getting stack overflows. This specific ...
hrodric's user avatar
  • 435
1 vote
1 answer
75 views

Here's a link to the actual question. Here's a link to the full code on Go Playground, with some test cases that return the correct result My code is correct, just slow it seems? I'm not a programmer ...
user29447151's user avatar
0 votes
1 answer
68 views

I've recently found myself solving a lot of 2D matrix search problems. A typical approach looks like the skeleton below, which searches for a word along 4-directionally connected paths in a 2D array: ...
Brendan Langfield's user avatar
3 votes
1 answer
189 views

Given a tree-like data structure of nodes with each node having a property children that contains the children nodes from left to right, I wish to create a string representation of this data structure ...
Gigi Bayte 2's user avatar
  • 1,014
1 vote
1 answer
113 views

I’m working on a problem where I need to compare multiple lineages (family trees) to check if they are structurally identical. Each lineage starts from a single root (ancestor) and extends downwards. ...
Bishop_1's user avatar
0 votes
0 answers
82 views

While trying to find all spanning trees using the queue, I came to the conclusion that it would be logical to search edges. If there is no new edge in the tree, I add the edge to the tree and put the ...
Potato's user avatar
  • 1
0 votes
1 answer
96 views

Splitting dag dependencies in Python I tried implementing a script for splitting dag dependencies, my goal is to split the node dependencies so that for each node that has more then one dependency, I ...
ADAM King's user avatar
2 votes
0 answers
73 views

with some help, i was able to traverse directory and parse it into Collection struct recursively like this #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Collection { pub relative_path:...
xqcccccccccc's user avatar
2 votes
1 answer
80 views

Below is Python code for a depth search algorithm. def add_edge(adj, s, t): # Add edge from vertex s to t adj[s].append(t) # Due to undirected Graph adj[t].append(s) print('adj add ...
Palavi Rajgude's user avatar
3 votes
2 answers
160 views

I was working on some Leetcode questions for Dijkstra's algorithm and I do not quite understand the space complexity of it. I looked online but I found various answers and some were rather complicated ...
Sam J's user avatar
  • 33
0 votes
2 answers
90 views

/* // Definition for a Node. class Node { public: int val; vector<Node*> neighbors; Node() { val = 0; neighbors = vector<Node*>(); } Node(int _val) { ...
Michael Johnson's user avatar
0 votes
0 answers
73 views

I've been working on the LeetCode problem 1192. Critical Connections in a Network. From various sources, I have the following code: class Solution { int timer = 1; void dfs(int node, int ...
Nikhil Garg's user avatar
2 votes
0 answers
126 views

I wrote a tail-recursive BFS in Scala: import scala.collection.mutable /** Do BFS from start and return the smallest distance to end (None if not connected) */ def bfs[A](start: A, end: A, neighbors: ...
pathikrit's user avatar
  • 33.7k
2 votes
2 answers
103 views

I am working on Leetcode 417 Pacific Atlantic Water Flow: There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and ...
percy_liu's user avatar
1 vote
0 answers
41 views

Context: I am trying to find out the depth between two CFGs using BFS but the code is not properly working as it's only showing the results up to depth 0 and 1 but it's not showing the other depths ...
tamanna's user avatar
  • 11
1 vote
1 answer
79 views

I am trying to solve the following question https://leetcode.com/problems/nearest-exit-from-entrance-in-maze/?envType=study-plan-v2&envId=leetcode-75 This is my approach def insidemaze(r,c,nrow,...
Siddharth Somani's user avatar
2 votes
2 answers
409 views

I am trying to solve the CSES Labyrinth problem: You are given a map of a labyrinth, and your task is to find a path from start to end. You can walk left, right, up and down. Input The first input ...
Yash Rai's user avatar
1 vote
2 answers
109 views

I am trying to solve a LeetCode problem (1219. Path with Maximum Gold) with BFS approach Statement: In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of ...
Karthikeyan's user avatar
0 votes
1 answer
29 views

I am attempting to use breadth first search to add to a node to an orderless tree Tree: Unordered Node: Each node groups together 3 datapoints, which are usernames Children: 3 nodes My current code is ...
dogeilante's user avatar
0 votes
3 answers
171 views

I'm currently working for a project with TOP and I'm asked to find the shortest path between 2 squares with a Knight on a 8x8 chessboard. Imagine I want to go from 0,0 to 7,7, my algo need to return ...
Hachounet's user avatar
0 votes
1 answer
171 views

Problem I am currently digging deep into some optimizations on the classical iterative approaches to both DFS and BFS algorithms. The material I'm currently using at my University presents both ...
Michel H's user avatar
  • 363
-1 votes
1 answer
75 views

Give the reasons for the above my query I find the above questions of the traverse of graph. Bfs and DFS both are the traverse to detect the cycle in a graph but most is the dfs why this is the best ...
Anjali Kashyap's user avatar
-2 votes
1 answer
88 views

I am new into graph theory I have this, problem I have a graph that will be diferent each time, I want to know if there is an algorithm to know from a random node which nodes I can visit, this ...
Domo48x's user avatar
  • 13

1
2 3 4 5
46