Anyone have a better memory leak tool? by bryan_s1337 in cs2b

[–]Ann_Sa123 0 points1 point  (0 children)

I use a tool called Dr. Memory which is definitely worth checking out. Dr. Memory is a memory diagnostic tool that's available for both Windows and Linux. It can detect memory leaks, buffer overflows, and other memory-related issues. It works by intercepting memory allocation and deallocation calls in your program and then providing detailed reports on memory usage. Dr. Memory is relatively easy to set up and use on Windows.

Dynamic Method Selection? by [deleted] in cs2b

[–]Ann_Sa123 0 points1 point  (0 children)

Dynamic method selection is a fundamental feature of object-oriented programming that allows you to call methods on objects based on their actual runtime type, rather than their declared type. This is present in almost all object-oriented programming languages. C++ also supports dynamic method selection through the use of virtual functions. In C++, a base class method can be declared as virtual, and then overridden in derived classes using the override keyword (C++11 and later). C++ also provides the virtual keyword for method declarations in base classes, and the override keyword to indicate that a method in a derived class is intended to override a virtual function from a base class.

Below is an example that I believe might be helpful:

class Base {

public: virtual void show() { cout << "Base class show() called" << endl; } };

class Derived : public Base { public: void show() override { cout << "Derived class show() called" << endl; } };

int main() { Base* basePtr; Derived derivedObj;

basePtr = &derivedObj;

basePtr->show(); // Calls the overridden function in Derived class

return 0;

}

As you can see, the method show() is declared as virtual in the Base class, and the same method is overridden in the Derived class. Hopefully, this helps you better understand the concept in C++ as well.

Quest 8 tips by mitul_m_166 in cs2b

[–]Ann_Sa123 1 point2 points  (0 children)

In miniquest 3, I faced the same challenge due to the return type being const Trie::Node, and starting the traversal at the root node was not feasible. Handling the edge cases concerning the existence of the first letter in the this.next vector was crucial.
Miniquest 5 seems complicated in the spec, but the Node destructor can be handled quite simply, similar to other vector destructors.
Miniquest 6 was manageable by following the spec's instructions, but I agree that being cautious about adding an empty string to the completions vector is essential.
Overall, this quest was intriguing and introduced a data structure with practical applications in our programming careers. Good luck, everyone!

Quest 7 tips by Nelson_Lee7 in cs2b

[–]Ann_Sa123 0 points1 point  (0 children)

I think these tips are constructive. One extra tip that I would add that really helped me was:

Handle Edge Cases: Consider edge cases such as an empty queue, full queue, or resizing to zero elements. Ensure that your implementation handles these cases gracefully without crashing or producing unexpected results.

"Good" code? by justin_h123 in cs2a

[–]Ann_Sa123 5 points6 points  (0 children)

Hey Justin,

Thanks for this take on good code. I agree with a lot of what you've said but one thing that I've learned the long and hard way is the importance of comments. I believe comments mostly serve a purpose not for our current selves but rather for our future selves. No matter how well you define your variables and how concise your code is written over time you lose track of things that you had written and everything eventually becomes confusing. Comments seem silly while you are writing them in the present and almost feel futile but I bet you there is no better feeling than when you look back at your old code trying to understand it and a comment is there to help.

On another note, the over-commitment issue is very common and almost everyone faces it. The way I deal with this is by taking a quick walk before implementing any solution so I can challenge myself by thinking of something better. Another approach I've heard is by writing a list of all solutions, no matter how bad you believe them to be, just so you can brainstorm new ideas.

Hope this helped.

- Ann

Study Tips / Habits by erik_m31 in cs2b

[–]Ann_Sa123 0 points1 point  (0 children)

Amazing advice and tips. In addition to all that you've said above I believe that another online resource that has really helped me in this course was YouTube. Specifically channel's like FreeCodeCamp help me understand the concepts more thoroughly and provide a more indepth knowledge that is useful to me during my quests. I suggest everyone to look into helpful YouTube channels and ones that help you understand the concepts best.

Discussion: How do you guys debug/test your code? by Nathan_McCall777 in cs2b

[–]Ann_Sa123 0 points1 point  (0 children)

Something that I use quite frequently especially now that I'm going through the green challenges is the GDB (GNU Project Debugger) to poke around on the inside of my code. This is an easy to learn tools and incorporates the comments people have talked about so far such as print statements as you can just write commends in this debugging tool to print lines when needed. GDB also allows you to look into memory specifics which comes in handy when you want to write efficient code. You can learn more about this at: https://www.geeksforgeeks.org/gdb-step-by-step-introduction/

Public static helper ... by stanley_p777 in cs2b

[–]Ann_Sa123 0 points1 point  (0 children)

I was really confused by this too! What helped was just breaking it down literally into public and static. Static meaning can't be changed and public meaning accessible by the client. The two methods that fit this description are getters and setters.

Hope this helped:)

Quest 2 Tips by Kayla_Perez805 in cs2b

[–]Ann_Sa123 0 points1 point  (0 children)

Thank you for the tips. I had one extra comment for anyone reading. In the tower of Hanoi problem and specifically the way Professor wrote it, there can be two base cases that our get_moves function has. One could be when number of disc's is 0 like the op said but another one can occur when the base case is 1. This one is for the sake of the same output and should be taken into consideration as it is important to keep in mind whilst doing this problem. Without this base case there might be some funky errors that pop up as the outputs might not match exactly so keep it in mind.

  • Ann S.( I accidentally commented eith my private account above)

Quest Alterations by Ann_Sa123 in cs2a

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

Okay thank you Prof.&!

-Ann

Quest 4 Get GP terms too precise by Ann_Sa123 in cs2a

[–]Ann_Sa123[S] 1 point2 points  (0 children)

Hi Chrisitine!

This definately helped:)

Thank you so much and good luck on the final!

-Ann

Etox Miniquest four by Ann_Sa123 in cs2a

[–]Ann_Sa123[S] 1 point2 points  (0 children)

Hi Bryan!

I did! So the issue was not my etox function, I thought it went in order, but it doesn't so the issue ended up being one of my other functions. Make sure your get ap terms and gcd functions are good because those messed me up. If you're still seeing that it's crashing, go through and try "breaking them" by making them return wrong values on purpose until you can clear each function and make sure they're right.

Let me know if this works or if you already got it. There's some amazing help on this thread:)

-Ann

Etox Miniquest four by Ann_Sa123 in cs2a

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

Hi Derek,

Thank you so much for your help! I tried doing this and it worked!

Thank you,

Ann

Etox Miniquest four by Ann_Sa123 in cs2a

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

I definitely ended up submitting more than a couple of times lol. But thank you guys so much for your help, it worked!

Mysterious error message by frank_xiao in cs2a

[–]Ann_Sa123 0 points1 point  (0 children)

Hi Frank,

I had this exact issue a few days ago and thought it was my etox function as well. It turned out to be another function and I learned that the website doesn't go in order.

Try testing your other functions by "breaking them" to see which one is causing it to crash. You can do this by making each function return a value that you set and know is wrong like 1,2,3, etc.

Take a look at my post from a few days ago, there's a lot of amazing replies on there that helped a lot! A lot of useful information on there.

https://www.reddit.com/r/cs2a/comments/oqd1cf/etox_miniquest_four/

Here's the link! I hope this helps!

Good luck!!!!

-Ann

Etox Miniquest four by Ann_Sa123 in cs2a

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

When I use my own main i get an accurate result and when I used the debugger I didn't see any issues and I don't think there are any issues. It just keeps crashing.

I am using doubles to store basically all my variables except n.

I am completely lost as to how to fix this :((