Tags » BF's

ACM ICPC Naga 2014 – Problem F: Diameter of a Tree

Dr. Manalastas, the author of this problem, is my friend in Facebook. Since my second year in college, I have seen him as someone who I should have a picture with. 982 more words

UVa Problems

Graph Algorithms - a revision of all the basic ones.

Hello friends! This post will be a short review of the the most common and basic algorithms for undirected graphs. 2,117 more words

Algorithms

Breadth First Search (BFS): Finding Visited Path From a Source to Destination

BreadthFirstPaths.java

package com.graph;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;

public class BreadthFirstPaths {
    private boolean[] marked; // Is a shortest path to this vertex known?
    private int[] edgeTo; // last vertex on known path to this vertex
    private final int s; // source

    public BreadthFirstPaths(Graph G, int s) {
        marked = new boolean;
        edgeTo = new int;
        this.s = s;
        bfs(G, s);
    }

    private void bfs(Graph G, int s) {
        Queue<Integer> queue = new LinkedList<Integer>();
        marked[s] = true;
        queue.add(s);
        while (!queue.isEmpty()) {
            int v = queue.peek();
            queue.poll();
            for (int w : G.adj(v))
                if (!marked[w]) {
                    edgeTo[w] = v; // save last edge on a shortest path,
                    marked[w] = true; // mark it because path is known,
                    queue.add(w);
                }
        }
    }

    public boolean hasPathTo(int v) {
        return marked[v];
    }

    public Iterable<Integer> pathTo(int v) {
        if (!hasPathTo(v))
            return null;
        Stack<Integer> path = new Stack<Integer>();
        for (int x = v; x != s; x = edgeTo[x])
            path.push(x);
        path.push(s);
        return path;
    }
} 25 more words
Graph

Hard Question 10

Problem:

Given two words of equal length that are in a dictionary, write a method to transform one word into another word by changing only one letter at a time. 158 more words

Technical And Interview And Data Science

ICCF 2014 - Problem C: Least Number of Moves

I can still remember my first ICCF participation. I was not given the chance to participate in the ICCF Open Programming Competition since I was not good enough back then. 913 more words

Bfs

Can I get a Reset? (In Memory of Graham Joyce)

I had intended to write this post about the British Fantasy Convention in York which I attended a few days ago. There was going to be mention of the different approaches to the writing process described by… 1,200 more words

BFS

Review for Nick Nightmare Investigates

For a fabulous review of Nick Nightmare Investigates go to the BFS reviews

Remember – this book is only available direct from the Alchemy Press!  

The Alchemy Press