Re: [algogeeks] Tree/Graph implementation

2012-05-31 Thread Mad Coder
@Gene: Can you tell some other ways of graph representation in case of sparse matrix as till now I consider adjacency list as the best method for the same. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Tree/Graph implementation

2012-05-29 Thread prakash y
How to implement complex data structures like trees (with unknown no.of subtrees) and graphs efficiently in C/Java? I have implemented binary trees in Java as it always contains two nodes. But I don't know about graphs. I am not able to solve these problems in coding contests because of this. Can

Re: [algogeeks] Tree/Graph implementation

2012-05-29 Thread Hassan Monfared
you can use adjacency matrices for spare graphs and two dimensional array for non-spare graphs On Tue, May 29, 2012 at 2:47 PM, prakash y yprakash@gmail.com wrote: How to implement complex data structures like trees (with unknown no.of subtrees) and graphs efficiently in C/Java? I have

Re: [algogeeks] Tree/Graph implementation

2012-05-29 Thread Jeevitesh
We can use the following data structure for Graphs:- - Adjacency Lists(More generally used) - Adjacency Matrix(Takes a lot of space but good for dense graph) For Trees:- We can model a node such that it has two pointers one of which points to its first child while the other points to the next

Re: [algogeeks] Tree/Graph implementation

2012-05-29 Thread prakash y
@all, when we use a 2D array/matrix to implement graphs, how can we traverse efficiently from starting node to ending node? take a look at of these problems Graph problem: https://www.interviewstreet.com/challenges/dashboard/#problem/4f40dfda620c4 Tree Problem:

Re: [algogeeks] Tree/Graph implementation

2012-05-29 Thread atul anand
simple DFS can be used to traverse nodes in the graph On Wed, May 30, 2012 at 10:12 AM, prakash y yprakash@gmail.com wrote: @all, when we use a 2D array/matrix to implement graphs, how can we traverse efficiently from starting node to ending node? take a look at of these problems Graph