Jump to content

Calculate Time complexity of this algorithm...


Recommended Posts

Posted

No more spamming this thread please. Next person to post an irrelevant comment will be punished. 

 

 

But its in spam ?

 

 

Why was this thread moved to Spam? It was originally in the Programming section.

 

Maybe we should have a programming questions section in there if this is considered off topic?

Posted

 I mean it wasn't supposed to be coded, and i tossed it together to prove the complexities. What's so bad about it?

I don't think you understand what a tree data structure is. Tree's have explicit parent pointers with a set of children (which makes up each "branch"). You defined a linked list, not a tree. On top of that you explicitly defined value as an int which is just lazy considering there are easy to implement generic types.

Posted (edited)

I don't think you understand what a tree data structure is. Tree's have explicit parent pointers with a set of children (which makes up each "branch"). You defined a linked list, not a tree. On top of that you explicitly defined value as an int which is just lazy considering there are easy to implement generic types.

 

 

I've used this data structure plenty of time to represent a binary tree. The basic data structure consisting of a value, leftChild, rightChild is commonly used amongst programmers. So you are complaining about that? Secondly, i don't know if you could tell but this was an algorithm specific question, not a java one. My attempt was not to use language specifics, such that the algorithm was less dependent on a specific language. I mean if you just look at the problem, why would I go overkill and add generics if all the values at a node are ints.. Would you like me to check if the returning value was affected my overflow too doge.png ? 

Edited by Qubit

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...