Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Find connection from one side to other

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Find connection from one side to other

    Hi,
    I have a 2D array (as in the image) and I need to find if the left side is connected to the right side.
    I've created an object for each "1" with four boolean fields (up, right, down, left), indicating if there is a connection to the next "1".
    I've read something about breadth first search, but I don't know how to implement it. Any pointers or help would be appreciated.
    Brez_naslova2.jpg


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Find connection from one side to other

    Define "connected" in terms that make sense looking at the graphic you posted. If there's a connected path in the graphic, describe it or draw it.

    Show the class you created that represents each "1". Rather than boolean fields to indicate if there's a connection to an adjacent neighbor, you may want to use a pointer to the adjacent neighbor if a connection exists, null if a connection does not exist. Using that approach, a path through the field of "1"s might be similar to data structures you're already familiar with or a tree of some kind.

Similar Threads

  1. Replies: 1
    Last Post: October 7th, 2013, 11:36 AM
  2. How to make the output side by side. I need HELP!
    By JAVAHELPP in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 18th, 2013, 07:49 PM
  3. Shared connection or individual connection?
    By newbie14 in forum Java Networking
    Replies: 6
    Last Post: January 12th, 2013, 04:10 AM
  4. Replies: 0
    Last Post: March 26th, 2011, 11:07 AM
  5. Validate in server side..
    By Ganezan in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 27th, 2009, 06:36 AM

Tags for this Thread