All Questions
Tagged with python-3.x depth-first-search
17 questions
6
votes
1
answer
290
views
Graph: Depth First Search (N citizens with pairs of friends)
I have solved problem 10608 on UVA Online Judge using Python 3.5.1. My solution works, but it takes too long to run when the online judge evaluates it.
Problem
There is a town with N citizens. It is ...
2
votes
1
answer
396
views
Find articulation points/ cut vertices in graph
I would like to get some feedback on my completed code that finds and displays the articulation vertices in an undirected graph.
I included a test case within the code, it should (and does) print <...
1
vote
1
answer
274
views
(Leetcode) Freedom Trail
I would like to know whether I could make my solution to this challenge shorter and more efficient. Below is the description of the challenge (this is a Leetcode problem) -
In the video game Fallout ...
5
votes
2
answers
2k
views
(Leetcode) Minesweeper game
This is a Leetcode problem -
Let's play the Minesweeper game
(Wikipedia,
online game)!
You are given a 2D char matrix representing the game board. 'M'
represents an unrevealed mine, 'E' ...
4
votes
1
answer
2k
views
(Leetcode) 24 game in Python
This is a Leetcode problem -
You have 4 cards each containing a number from 1 to 9. You need to
judge whether they could be ...
4
votes
1
answer
2k
views
Find all concatenated words in a given list of words
This is a Leetcode problem -
Given a list of words (without duplicates), write a program that
returns all concatenated words in the given list of words.
A concatenated word is defined as a ...
6
votes
1
answer
699
views
Recursive Depth First Search for finding valid sudoku boards in Python 3
I am not an experienced programmer, and I decided to make a program that could find all possible sudoku arrangements just for fun. As far as I can see, the program is working all right, but I'd like ...
4
votes
0
answers
376
views
Skiena's DFS on unweighted graphs, in Python 3, with adjacency-list implementation
In the Algorithm Design Manual (2nd ed) pp 172 - 173, Skiena writes:
As algorithm design paradigms go, a depth-first search isn't
particularly intimidating. It is surprisingly subtle, however
...
4
votes
2
answers
830
views
Find the longest rectilinear path in a matrix with descending entries
Problem (Skiing):
Each number represents the elevation of that area of the mountain.
From each area (i.e. box) in the grid, you can go north, south, east,
west - but only if the elevation ...
1
vote
1
answer
771
views
Return a path between graph nodes using depth-first search redo
I previously attempted to implement a Graph class which has a method that returns a path between 2 nodes using depth-first search. This is my latest attempt at this ...
2
votes
1
answer
8k
views
Return path between graph nodes using depth-first search
This code is meant to implement a Graph class which has a method that returns a path between 2 nodes using depth-first search.
I'm doing this to improve my style ...
10
votes
2
answers
2k
views
2D grid Hamiltonian path puzzle solver
The puzzle goes like this: in a rectangular 2D grid there are empty spaces (.), exactly one starting point (S, ...
2
votes
1
answer
124
views
File search program not efficient enough
I have created a program to search for a file in the computer. But I feel it can be improved. Can anyone help me with this?
filesearch.py
...
8
votes
1
answer
1k
views
Search iteratively in a ternary search tree
I was trying to write an iterative search function for my Ternary Search Tree class based on a pseudo-code, and now it seems to work, but I think it can definitely be improved.
...
7
votes
1
answer
451
views
Depth First Backtracking Puzzle Solver
There is this type of puzzle
that can easily be solved with a depth-first backtracking solver. I wrote one in python 3.4 and like to get some feedback.
I'm especially interested in the following ...