Jump to content

Calculate Time complexity of this algorithm...


Qubit

Recommended Posts

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?

Link to comment
Share on other sites

 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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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