Difference between revisions of "Talk:TADM2E 3.13"

From Algorithm Wiki
Jump to: navigation, search
Line 1: Line 1:
 
Doesn't this solution violate the condition that we are restricted to O(n) memory usage? If the tree has N leaf nodes, and is a perfectly balanced binary tree, there would be a total of N log N nodes and O( n log n ) memory used. Correct?
 
Doesn't this solution violate the condition that we are restricted to O(n) memory usage? If the tree has N leaf nodes, and is a perfectly balanced binary tree, there would be a total of N log N nodes and O( n log n ) memory used. Correct?
  
brandon.arnold (7/8/2017): Absolutely, I saw the same O(nlogn) approach but could not improve on it, and came here to see the correct one. This is wrong.
+
brandon.arnold (7/8/2017): It absolutely differs from the requirements, though my edition states at most an "additional array of size n," which is more stringent a requirement than O(n) memory usage. Were it the latter case, a binary tree would satisfy this (and no, it is not O(nlogn); a binary tree with n leaves is O(n) space). Anyway, this is wrong.

Revision as of 18:13, 8 July 2017

Doesn't this solution violate the condition that we are restricted to O(n) memory usage? If the tree has N leaf nodes, and is a perfectly balanced binary tree, there would be a total of N log N nodes and O( n log n ) memory used. Correct?

brandon.arnold (7/8/2017): It absolutely differs from the requirements, though my edition states at most an "additional array of size n," which is more stringent a requirement than O(n) memory usage. Were it the latter case, a binary tree would satisfy this (and no, it is not O(nlogn); a binary tree with n leaves is O(n) space). Anyway, this is wrong.