Jump to content

iceposeidon

Members
  • Posts

    1
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

iceposeidon's Achievements

Newbie

Newbie (1/14)

1

Reputation

  1. struct node{ int value; node *left; node *right; }; long sum(node *root, int a, int b) { if(root == NULL) return 0; if(root->value < a) return sum(root->right, a, b); if(root->value > b) return sum(root->left, a, b); return root->value + sum(root->right, a, b) + sum(root->left, a, b); } Am implementat de distractie rapid in c++, complexitatea este O(n). Sunt curios daca exista solutie mai rapida.
×
×
  • Create New...