You are given a path for an connected undirected graph with no cycle. The path is written by a man in the way: if he enter or leave the node he will write it down. When he comes to a node he looks for another connected to it which he has not traversed yet. If he finds such node, he follows that one. Otherwise, he go back. You have to find degree of each node.
Category: basic data structure [stack]
Idea: use stack to push the nodes in path one by one. if two consecutive node are equal, that means, this is the end of that node. now increase the degree of that node by one, and also increase its parent degree by one.
You are done.
Code
কোড গুলো দেখানোর জন্য gist অথবা পেস্টবিনের মত টুল ব্যবহার করলে ব্লগটা আরো সুন্দর লাগত। আপনার সাবনেটিং লেখাটা পড়েছি। সুন্দর লেখা। ধন্যবাদ।
ReplyDeleteThanks a lot for your great Suggestion.
DeleteFrom now, i will post code link rather than code directly.
This comment has been removed by the author.
ReplyDelete