o_0
Member level 3
- Joined
- Sep 30, 2009
- Messages
- 58
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 1,288
- Activity points
- 1,873
I'm supposed to write a program that counts all the vertices in a given tree.
Any language can be used. (I've been using Perl mostly but could do C too. C++ would be ok too, if it was significantly easier.)
I'm not making much progress because I don't even know what the input is supposed to look like. Also, this seems like the kind of thing that there's a formula for.
-What does the input look like? (how is the tree entered into the program?) I've seen the graphical version. But how would that tree be typed in?
-I read if a tree has n levels, the number of vertices is 2^{n-1}. And for n edges, the vertices are (n-1). Maybe that will help.
I'm a grad student in electrical engineering but software is not my area of specialization. I didn't take the algorithms class. The problem would probably be simple to anyone who had taken the class. If you know a good reference book or website, I'd appreciate that too. Googling hasn't helped much.
Any language can be used. (I've been using Perl mostly but could do C too. C++ would be ok too, if it was significantly easier.)
I'm not making much progress because I don't even know what the input is supposed to look like. Also, this seems like the kind of thing that there's a formula for.
-What does the input look like? (how is the tree entered into the program?) I've seen the graphical version. But how would that tree be typed in?
-I read if a tree has n levels, the number of vertices is 2^{n-1}. And for n edges, the vertices are (n-1). Maybe that will help.
I'm a grad student in electrical engineering but software is not my area of specialization. I didn't take the algorithms class. The problem would probably be simple to anyone who had taken the class. If you know a good reference book or website, I'd appreciate that too. Googling hasn't helped much.