Hola!

Recently I read quite a few tutorials on how how stacks, queues, dfs, bfs, adjacency matrices, adjacency lists work. I am yet to implement them. The problem is that on the way, I came across a lot of codes with new stuff like typedef, struct etc. They looked like Greek and Latin to me. I have seen the use of STL implementation stacks and queues used in codes as well and I am interested in trying out those as well as I know they make implementing graphs easier. I have always worked with only arrays before (heard of vectors but unsure how it works) I tried searching them up but there is so much out there that I canâ€™t figure out a chronological approach to learn graphs.

I have always had a fear of graphs because the fact that there is so much to know as a prerequisite has always scared me. But I have decided to get over my weakness and make it my strength. It would be of great help if someone could list out the theory in order of learning to attempt implementing graphs. Especially the STL implementations of some common data structures and and other stuff which would make implementation easier and faster. Basically I get the logic, but when it comes to representing the graphs, converting it from that drawing on my paper into code, I have trouble.

2 Likes

refer a bookâ€¦that deals with data structureâ€¦and focusing on implementation and its logicâ€¦

my personal recommendation : FUNDAMENTALS OF DATA STRUCTURE IN C BY HOROWITZ . SAHNI . ANDERSON-FREEDâ€¦

(1 book 3 writer :P)

this book will really help youâ€¦

3 Likes

i would suggest solving a problem based on tree/graphs first, and learning on the way: www.spoj.com/problems/PT07Y.

For doing this one, u need to know about graph traversal techniques: BFS, DFS, and also using stacks/queues through STL. Try reading some tutorial/solution for the above problem, it will help in starting out on graphs.

2 Likes

Facing same problemâ€¦ fear of trees and graphsâ€¦

Thanks for asking this questionâ€¦

1 Like

Same hereâ€¦Good question indeedâ€¦

2 Likes

Hello @gvaibhav I tried following the â€śfirst problem, then theoryâ€ť approach. For this, I tried looking up solutions. But most solutions use some STL functions and inbuilt data structures which make the entire code look very complicated and frightening for a beginner like me. Maybe I could google out all the things I donâ€™t understand but it only leads to more things I donâ€™t understand. I suppose there is a proper way to go about learning these so if you could suggest a list of STL functions, theory and structures in order, to learn graphs it would be cool! Anyway thanks a lot for your help.

I would suggest you to learn your language ie C++ first , so that you can understand any code written in it . then follow the strategy you are following .

for above problem, as far as STL is concerned, you need to know about stacks/queues, so i would suggest first implementing stacks and queues yourself, without using inbuilt data structures, after that you will surely understand the inbuilt functions used in the STL code. So, to start, look for some tutorials/videos on the basic data structure operations, and after that, refer to cplusplus.com for the STL referenceâ€¦ ( and also **do** learn the graph traversal methods : BFS, DFS)

Alright, @gvaibhav & @acodebreaker2 Iâ€™ll do it that way thanks