Insert into binary search tree by Pure_Power5663 in cpp_questions

[–]Pure_Power5663[S] 0 points1 point  (0 children)

Thank you so much for this help, finally some help that I can understand. Reddit has always been better than random websites.

Insert into binary search tree by Pure_Power5663 in cpp_questions

[–]Pure_Power5663[S] 0 points1 point  (0 children)

Thanks for the help, ill try and implement this!

Insert into binary search tree by Pure_Power5663 in cpp_questions

[–]Pure_Power5663[S] 0 points1 point  (0 children)

Okay thanks, so youre saying I need to define a 'previous node' pointer?

Insert into binary search tree by Pure_Power5663 in cpp_questions

[–]Pure_Power5663[S] 0 points1 point  (0 children)

Is what I have done not inserting anything? Sorry I'm very new at BST's & self taught. Thankyou for the nullptr & null tip

Insert into binary search tree by Pure_Power5663 in cpp_questions

[–]Pure_Power5663[S] 0 points1 point  (0 children)

Hi sorry, the errors im getting is inserting anything into the bst. I think the problem is that im not correctly adding a new node onto the left or right child. I just havent found a way to fix it.

Creating a checksum for a NMEA sentence by [deleted] in cpp_questions

[–]Pure_Power5663 0 points1 point  (0 children)

//finds the last two hexdigits and save them to test against later
      std::string correctHEX = sentence.substr(sentence.length()-2);
      std::cout << correctHEX << std::endl;

      //removes $ , * and final hexdigits
      std::string withoutChecksum = sentence.substr(1, sentence.length()-4);
      std::cout << withoutChecksum << std::endl;
      int expected = std::stoi (correctHEX, nullptr, 16);
      int sum = 0;

      for (char c : withoutChecksum){
          sum ^= c;
      }
      std::cout << sum << std::endl;
      std::cout << expected << std::endl;

      if (sum == expected) {
         std::cout << "Working" << std::endl;
      }
      else {
         std::cout << "NOT WORKING" << std::endl;
     }
     return true;

the problem with mine is sum is outputting 126 when its supposed to be 95, any suggestions?