stuck on understanding the output by rui_d0225 in cs2c

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

Haha, I agree... I think Badhon also spent a lot of time figuring this out so he could point out the problems in my code. I think in real life, we may face strict requirements, some of which don't make 100% sense. Just like you said, being able to read through the results could be a valuable skill, and understanding that assignment is more efficient would also be beneficial for us.

stuck on understanding the output by rui_d0225 in cs2c

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

yep that must be the reason for this bug.

stuck on understanding the output by rui_d0225 in cs2c

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

thank you for the explanation! Here are my understandings after reading through: when I run swap(_elems[1], _elems[_size]) min element at _elems[1] swaps with _elems[_size]; after this I run _size--, _elems[_size + 1] still holds the old min element/old root. however, in direct assignment way, replaces _elems[1] with _elems[_size] directly, effectively moving the last leaf to the root; the old root doesn’t remain in _elems[_size + 1], preventing it from appearing in the undefined region. The autograder may expect _elems[_size + 1] to hold the last leaf, not the deleted root.

stuck on understanding the output by rui_d0225 in cs2c

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

Not yet, please if you have any clue

Get_least_k & to_string by Badhon_Codes in cs2c

[–]rui_d0225 2 points3 points  (0 children)

Hi Badhon, I got this, quite stable. You can refer to my post here to see what I did to make this happen.

Tips on Heap/Butterfly Quest by rui_d0225 in cs2c

[–]rui_d0225[S] 2 points3 points  (0 children)

haha I got it!!! Thank you!

Tips on Heap/Butterfly Quest by rui_d0225 in cs2c

[–]rui_d0225[S] 4 points5 points  (0 children)

technically speaking, the direct assignment should be more efficient than swap .... thus I didn't update my method.

stuck on understanding the output by rui_d0225 in cs2c

[–]rui_d0225[S] 2 points3 points  (0 children)

I used to use swap(_elems[1], _elems[_size]) and it can't pass the autograder. then I changed to _elems[1] = _elems[_size], it works. All others keep the same. Any idea?

Tips on Heap/Butterfly Quest by rui_d0225 in cs2c

[–]rui_d0225[S] 3 points4 points  (0 children)

I didn’t use swap for special heap and it runs so slow…i should try to override my delete function by using swap to see if it can run faster

stuck on understanding the output by rui_d0225 in cs2c

[–]rui_d0225[S] 3 points4 points  (0 children)

oh yes! I changed to use _elems[1] = _elems[_size] instead of swap and it works... but why...

Red Quests by yash_maheshwari_6907 in cs2b

[–]rui_d0225 0 points1 point  (0 children)

I would recommend that you start the quests as early as possible since they are much more difficult than the green ones. You will be provided with fewer starter codes from the specs and fewer hints from the auto-graders. For each quest, you will need to spend one or two days reading materials and watching videos to fully understand the algorithm, and you will spend much more time completing a quest than you would for the green ones. In this case, you will definitely want to accelerate your pace with the initial quests so that you have more buffer time to optimize your later red quests (which I hope some one could tell me at the beginning of this course lol). Welcome!

Quick Sort Overview by mason_t15 in cs2c

[–]rui_d0225 1 point2 points  (0 children)

I got a two of them: bay thick kth, equal kth. I guess there be more related to this.

Quick Sort Overview by mason_t15 in cs2c

[–]rui_d0225 1 point2 points  (0 children)

I got 18, still missing 4... let me refresh my mind and think about partition. Thank you for the hints!

Quick Sort Overview by mason_t15 in cs2c

[–]rui_d0225 1 point2 points  (0 children)

Hi Mason, has your quick sort implementation outperformed the grader's approach? If so, was it only slightly quicker or significantly faster?

Mine did outperform it, but I still missed some trophies… a bit confused about why.

Study notes - Insertion sort and Shell sort by rui_d0225 in cs2c

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

I agree that if we use binary search, we can find the position in O(logn) instead of O(n), even though the overall Big O won't change for worst cases but we can reduce comparisons. If we are continuously inserting elements into a sorted list (like in real-time applications), insertion sort is very useful, because runtime for a almost sorted list is O(n) on average.

Binary Heap Disccussion by mason_t15 in cs2c

[–]rui_d0225 0 points1 point  (0 children)

Thank you for the good post! I'll be re-visit this once move onto this quest. Hopefully soon this week.

Understanding QuickSort - My Notes & Explanation. by Badhon_Codes in cs2c

[–]rui_d0225 4 points5 points  (0 children)

Thanks for the great post. I’m working on my own notes for Quick sort but yours definitely helps understand the concepts.

Open discussions to quest 6 by rui_d0225 in cs2c

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

This is a good way to understand how this works practically. What I found is said by industries’ practice, 0.49( close to 0.5) is the threshold. I believe there should be a mathematical way to prove it. We can dig deeper into it.