PDA

View Full Version : QList or QLinkedList



eleanor
24th October 2007, 15:08
Hi all, I need to do this: http://shrani.si/f/2a/sv/2f6VXI8r/fesf.png

I have a couple of questions:

1) what should I use for this: QList or QLinkedList

2) for every black circle I need 1 QList right?

3) for every blue connections I need a new QList right?

Am I assuming this correctly, or can I do this with fewer QList's without complications?

high_flyer
24th October 2007, 15:20
you didn't specify enough information for an answer.
What are the rules in the lists?
The "blue" lists vary in number of items - does this mean each item can both link to the "black" list AND the "blue" list?
The relationships are also problematic, since it looks like there is recursiveness - head1 links to head two (in the inner black circle) head two has a "blue" list members of which the last one links to the last blue item of head1 again, since the blue connections go both ways its recursive...
So you will have to explain more...
But on it looks to me that linked lists is what you need.

And please, post images on the forum it self, don't post links, since links will not stay for ever, and later it will be impossible to know what the thread is about.

eleanor
24th October 2007, 16:14
For now I just want to know this:

1) for every black circle I need 1 QLinkedList right?
- you can travel over black circles only in one direction

2) for every blue connections I need a new QLinkedList right?
- over blue circles you can travel in both directions

I just want to know how to store those...for now.

high_flyer
24th October 2007, 16:29
yes, I think you will need a link list of linked lists - that is, a link lists which each of its elements is a linked list.

eleanor
8th November 2007, 18:36
Hi, can somebody give me an idea, how to make recursive search of 2 stations (starting one + ending one) ?

This is a railway(look at the picture) where you enter a station and get off on another station. Now I have to make recursive search how to find the shorthest path between these two stations.

Thanks

jacek
8th November 2007, 19:05
Now I have to make recursive search how to find the shorthest path between these two stations.
Use Dijkstra's algorithm (http://en.wikipedia.org/wiki/Dijkstra's_algorithm), although the implementation might be a bit tricky with such non-standard representation of a graph.

high_flyer
9th November 2007, 09:40
in case each station is connected to not more then two other stations, you could use a binary search tree (http://en.wikipedia.org/wiki/Binary_search_tree), which is easy.