Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in remove_nodes - deleting wrong nodes #16

Closed
potat-dev opened this issue Oct 18, 2021 · 1 comment
Closed

Bug in remove_nodes - deleting wrong nodes #16

potat-dev opened this issue Oct 18, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@potat-dev
Copy link
Owner

Function removes elements with a shift, which leads to incorrect results

https://github.com/DenCoder618/SUAI-Labs/blob/2f2ddd9929bac01ea3d5520e2c60d0585ba725ae/Semester_1/Lab_6/snippets.c#L309

For example:

list: 0 1 2 3 4 5 6 7
remove_nodes from 5 to 8
expected output: 0 1 2 3 4
real output: <empty> [error]
@potat-dev potat-dev added the bug Something isn't working label Oct 18, 2021
@potat-dev potat-dev self-assigned this Oct 18, 2021
@potat-dev
Copy link
Owner Author

Solution: remove every time the same node

void remove_nodes(list *list, int start, int end) {
  for (int i = 0; i < end - start; i++)
  remove_node(list, start);  // start node wiithout a shift
  list -> size -= (end - start);
}

potat-dev added a commit that referenced this issue Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Labs 1 semester
  
Awaiting triage
Development

No branches or pull requests

1 participant