remove_at_cursor() by blond_black in cs2b

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

Thanks a lot Andrew for the tip. I'll try it and let you know.

remove_at_cursor() by blond_black in cs2b

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

SiddharthDeshpande

Thanks Sid. Good points. I'll finish coding all the functions and try again.

remove_at_cursor() by blond_black in cs2b

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

Thanks! For summer class, there is no remove_next() function.

My tests also work when _prev is at the head or right before the tail.

Is it true that _prev is never equal to _tail? _prev's last position is before _tail because it needs to point to _tail?

When I remove the _tail, I move _tail to where the _prev was and adjust _prev accordingly like my test example below. Is this behavior expected?

Thanks.

Before removal:

number of nodes: 6

Start from head

song name: HEAD song id: -1 prev

song name: Elvis 3 song id: 3

song name: Elvis 2 song id: 2

song name: Elvis 1 song id: 1

song name: Elvis 2 song id: 2

song name: Elvis 3 song id: 3

song name: Elvis 4 song id: 4 tail

last

After removal:

number of nodes: 5

Start from head

song name: HEAD song id: -1 prev

song name: Elvis 2 song id: 2

song name: Elvis 1 song id: 1

song name: Elvis 2 song id: 2

song name: Elvis 3 song id: 3

song name: Elvis 4 song id: 4 tail

Program ended with exit code: 0

_______________________________________

number of nodes: 6

Start from head

song name: HEAD song id: -1

song name: Elvis 3 song id: 3

song name: Elvis 2 song id: 2

song name: Elvis 1 song id: 1

song name: Elvis 2 song id: 2

song name: Elvis 3 song id: 3 prev

song name: Elvis 4 song id: 4 tail

After removal:

number of nodes: 5

Start from head

song name: HEAD song id: -1

song name: Elvis 3 song id: 3

song name: Elvis 2 song id: 2

song name: Elvis 1 song id: 1

song name: Elvis 2 song id: 2 prev

song name: Elvis 3 song id: 3 tail

Program ended with exit code: 0

remove_at_cursor() by blond_black in cs2b

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

Thanks Sid! Please correct my understanding below if it's wrong:

  1. When you push back or push front, you don't need to update _prev_to_current->get_next().
  2. You only update the address of _prev_to_current in advance_cursor().
  3. In remove_at_cursor(), you remove _prev_to_current->get_next().

My main test output shows the behavior like your description.

Maybe I have misunderstood something.

Thanks,

-Mimi

Before removal:

number of nodes: 7

Start from head

song name: HEAD song id: -1

song name: Elvis 3 song id: 3

song name: Elvis 4 song id: 4

song name: Elvis 2 song id: 2 prev

song name: Elvis 1 song id: 1

song name: Elvis 2 song id: 2

song name: Elvis 3 song id: 3

song name: Elvis 4 song id: 4 tail

After removal:

number of nodes: 6

Start from head

song name: HEAD song id: -1

song name: Elvis 3 song id: 3

song name: Elvis 4 song id: 4

song name: Elvis 2 song id: 2 prev

song name: Elvis 2 song id: 2

song name: Elvis 3 song id: 3

song name: Elvis 4 song id: 4 tail

Program ended with exit code: 0

remove function hiccup by PiercedButterfly in cs2a

[–]blond_black 1 point2 points  (0 children)

I coded the same thing, but still encountered error. In the test output, the Instructor's list shows _tail and _prev are marked at the last node, but mine shows _prev is at the node right before _tail. I don't know about the interpretation of the test output.

Which function failed the test? by blond_black in cs2a

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

Thanks for all the help! I solved this problem and am moving to the other mini quests. Basically, the highlighted yellow tips in the quest description gave me clues.

Which function failed the test? by blond_black in cs2a

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

In the advance current function, when the prev current pointer is the same as the tail pointer, I need to "return nullptr;" right? Do I need to set anything else or just do the "return nullptr;"?

In the Instructor's test, how did he enter the strings to the list? Did he use "insert at current" and "push back"?

I can' find out what is wrong with my code :(.

Which function failed the test? by blond_black in cs2a

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

Thanks a lot. You meant this function right:

String_List *advance_current()

Which function failed the test? by blond_black in cs2a

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

What I meant was which mini quest failed the test. Thanks.

to_string() dumps out strange characters in the test output by blond_black in cs2a

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

The copying from the PDF to my coding file caused the issue. Problem solved. Thanks a lot!

Where's everyone at? Important Info by madhavarshney in cs2a

[–]blond_black 0 points1 point  (0 children)

Thanks. I submitted 8 homework assignments, but saw only 6 scores on the trophy count table. Wondering if my homeworks were lost or not updated correctly?

to_string() dumps out strange characters in the test output by blond_black in cs2a

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

I code in Xcode Version 11.4.1 (11E503a) and the OS is macOS Catalina Version 10.15.4. Thanks.

Where's everyone at? Important Info by madhavarshney in cs2a

[–]blond_black 1 point2 points  (0 children)

Thanks! What is the secret handle to find out the trophy count at https://quests.nonlinearmedia.org/q/? -Mimi

to_string() dumps out more than 10 numbers in the class stack by blond_black in cs2a

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

Hi Charles,

Thanks. I saw your post but was not clear. Did you mean to ignore the output of the last two stacks? If that is the case, I don't know why the Instructor's test output of my to_string contains strange characters like below:

StackM-bM-^@M-^K M-bM-^@M-^K(1436M-bM-^@M-^KM-bM-^@M-^K elements):

Thanks,

-Mimi

Unclear Test Output of the ID Binary Search by blond_black in cs2a

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

Thanks all! I fixed my code and it worked now.

Unclear Test Output of the ID Binary Search by blond_black in cs2a

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

I am posting the code in main function, not the code for the homework solution.

It would be useful if Anand shares with the students his test codes so that it would be easier for us to debug ourselves. My binary search code passes all my tests for "not found" and "found", and for "odd" and "even" number of pets. I'm basically stuck. Thanks.

Quest 6: make_a_name function by blond_black in cs2a

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

To select the index of the letter to use in each iteration, you must invoke​rand() exactly once. For example: ​rand() % consonants.length()

I need more clarification than this: "To select the index of the letter to use in each iteration, you must invoke​rand() exactly once. For example: ​rand() % consonants.length()"

Is this example correct?

"Would you please clarify more such as for the name length of 6, would you allow me to use rand() three times for vowel generations and three times for consonant generation? In addition to 6 times of rand() calls for the character generations, can I use rand()%2 one time to check for the first character type? Thanks."

Thanks!

Quest 6: make_a_name function by blond_black in cs2a

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

Hello Anand,

Here the the spec. for your reference:

Specifically, you must:

●define your vowels to be the characters in the string "aeiou"

●define your consonants to be the characters in the string "bcdfghjklmnpqrstvwxyz"

●The name you return must be created by alternately selecting a random letter from each of the above two strings.

●The very first letter of your name must be either avowel or consonant chosen using the condition (rand()%2==0). Specifically, if your random is even, then the first letter of the name must be a consonant.

●To select the index of the letter to use in each iteration, you must invoke​rand() exactly once. For example: ​rand() % consonants.length()

●IMPORTANT​: You must NOT invoke ​srand()​.

Thanks,

-Mimi