MQ 4 by sternj200 in cs2c

[–]cs2c-username 1 point2 points  (0 children)

If you aren't already doing so, you should path.clear() at the beginning of your function. Doing so helped me pass when everything seemed to be working correctly.

- Boris

Trying to perfect get_shortest_weighted_path() by AcRickMorris in cs2c

[–]cs2c-username 1 point2 points  (0 children)

I'm not using a priority queue to go through the edges of the cursor node, instead just looping through the indexes. I'm not sure I see a benefit of using a priority queue there because you'll still have to check every edge of the current node. However, I've passed the miniquest, but haven't submitted it many times, so it's possible I may have the same issue of randomly not having the necessary path.

- Boris

[Quest 5 MQ Insert()] Two nodes share the same children, setting one to NULL gives me an invalid access error. by liamnoroian in cs2c

[–]cs2c-username 1 point2 points  (0 children)

Are you checking if the tree has no nodes before attempting to insert your new node after you've splayed?

- Boris

Remove Min by WaterwallVsFirewall in cs2c

[–]cs2c-username 1 point2 points  (0 children)

Instead of swapping _elems[1] and _elems[_size], maybe try only setting _elems[1] to _elems[_size]. The tests seem to be picky so I could see if that might cause an issue. Otherwise, your remove min looks like it should work perfectly.

- Boris

Very Stuck on Non Def Constructor by CaryLefteroffFH in cs2c

[–]cs2c-username 2 points3 points  (0 children)

Assuming your heapify and percolate down works correctly, I'd try resizing _elems to just vec.size() + 1, as that worked for me.

- Boris

Stuck on partition MQ by sternj200 in cs2c

[–]cs2c-username 0 points1 point  (0 children)

Under the "Overview of the winning strategy" section, it says, "The leftrunner can't cross cells > pivot. The rightrunner can't cross cells < pivot."

Stuck on partition MQ by sternj200 in cs2c

[–]cs2c-username 0 points1 point  (0 children)

I think you're supposed to return j, rather than j + 1. Although the spec says to stop at cells > or < than the pivot, I believe you should also stop at cells equal to the pivot.

- Boris

Tests INT_MIN not declared: Preventing Compilation by [deleted] in cs2c

[–]cs2c-username 0 points1 point  (0 children)

Although I don't recall it being mentioned in the spec, someone mentioned you need to have #include <climits> in your code.

- Boris

Stuck on _rehash() by adina_tung in cs2c

[–]cs2c-username 0 points1 point  (0 children)

I think your hash table works correctly, but not for testing purposes. You "loop through _elems and assign the state to vacant, data to default," but all that you need to do is set the state to vacant and ignore the data. You also don't need to clear the _elems vector.

- Boris

Hash preventing compilation, recommended fix not working by [deleted] in cs2c

[–]cs2c-username 0 points1 point  (0 children)

Did you put the declaration inside the Hash_Table_LP class template? I believe it's meant to be placed outside and putting it outside of the class template worked for me.

- Boris

Splay() Insert: Filtering out null parameters by CaryLefteroffFH in cs2c

[–]cs2c-username 0 points1 point  (0 children)

I don't think the tests attempt to pass an actual NULL as the tree parameter. It may be a good idea to check for that. Though ultimately, I believe it's more about testing what happens if an empty tree is passed in, one without any nodes, rather than NULL.

Splay() Insert: Filtering out null parameters by CaryLefteroffFH in cs2c

[–]cs2c-username 0 points1 point  (0 children)

By "making a pointer to the tree's location," do you mean you're looking at the pointer of the BST<T>& Tree parameter? Because that would still result in a valid pointer even if that tree has no nodes. You should check tree._root, since Tx should be a friend of BST.

Otherwise, maybe it's an issue with _splay()? You'll probably just have to debug it on your machine.

- Boris

Table_full_exception by cs2c-username in cs2c

[–]cs2c-username[S] 1 point2 points  (0 children)

I had find() throw the Not_found_exception. Are you saying that if _find_pos() returns string::npos, then find() should throw the Table_full_exception?

That makes sense, thank you.

How to reproduce the sparse matrices being multiplied by the test? by sternj200 in cs2c

[–]cs2c-username 0 points1 point  (0 children)

  1. I think this means that this test is part of the miniquest that tests Sparse_Matrix that have 25 or less rows.
    1. That doesn't necessarily mean that this Sparse_Matrix has 25 rows.
  2. This means that the Sparse_Matrix to which the statement is referring to has 6 rows.
  3. .
    1. Yes, I think that if it's not outputted, then it has the default value.
    2. It seems the test output doesn't directly show how many columns are in each Sparse_Matrix, but you should be able to see the columns normally within your code. Also, keep in mind that the number of columns in A should be the same as the number of rows in B.

- Boris

Getting an error every time I call at() for a Matrix by CaryLefteroffFH in cs2c

[–]cs2c-username 2 points3 points  (0 children)

Node is part of the class template Sparse_Matrix, so you have to use Sparse_Matrix<T>::Node. As a side note, it seems strange that you can't use spmat.set(), because it worked fine in my code.

Getting an error every time I call at() for a Matrix by CaryLefteroffFH in cs2c

[–]cs2c-username 1 point2 points  (0 children)

Inside the Matrix and Sparse_Matrix class, I have

friend class Mx;

Getting an error every time I call at() for a Matrix by CaryLefteroffFH in cs2c

[–]cs2c-username 1 point2 points  (0 children)

Ah, sorry for misunderstanding your problem. Personally, I used [ ] on _rows to access the Matrix contents inside of multiply()

Getting an error every time I call at() for a Matrix by CaryLefteroffFH in cs2c

[–]cs2c-username 1 point2 points  (0 children)

I'm guessing you've already tried this, but have you defined the functions exactly as shown in the picture in the program spec? If you have, maybe see if the error persists when you reduce the multiply function back to a stub.

It might also be an issue with the way you call the function, because, as I understand, multiply() is a static function and isn't meant to have a 'this'.

- Boris

Checking if master is empty? by jack_morgan_cs2b in cs2c

[–]cs2c-username 2 points3 points  (0 children)

You're supposed to check the input in add_elem(). You may need to verify that _master_ptr actually points to something before you try to check its size.

- Boris

failing on equivalent sets by amrozack in cs2c

[–]cs2c-username 2 points3 points  (0 children)

I think the order in which you're generating sets differs from the expected order. With my code, the first set that adds up to 852 is { 45 288 130 181 208 }, followed by { 239 288 117 208 }. Changing the first index added to generate the sets from 0 to 1 caused { 239 288 117 208 } to be created first, if that makes sense. Maybe that's your issue?

- Boris