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

Fix the function for printing the queue #1573

Merged
merged 2 commits into from
Dec 4, 2024
Merged

Fix the function for printing the queue #1573

merged 2 commits into from
Dec 4, 2024

Conversation

Xi-Row
Copy link
Contributor

@Xi-Row Xi-Row commented Nov 26, 2024

If this pull request (PR) pertains to Chinese-to-English translation, please confirm that you have read the contribution guidelines and complete the checklist below:

  • This PR represents the translation of a single, complete document, or contains only bug fixes.
  • The translation accurately conveys the original meaning and intent of the Chinese version. If deviations exist, I have provided explanatory comments to clarify the reasons.

If this pull request (PR) is associated with coding or code transpilation, please attach the relevant console outputs to the PR and complete the following checklist:

  • I have thoroughly reviewed the code, focusing on its formatting, comments, indentation, and file headers.
  • I have confirmed that the code execution outputs are consistent with those produced by the reference code (Python or Java).
  • The code is designed to be compatible on standard operating systems, including Windows, macOS, and Ubuntu.

@krahets
Copy link
Owner

krahets commented Dec 4, 2024

image

Hi, I cannot see the screenshots. Could you paste them directly into the comment box of this page?

@Xi-Row
Copy link
Contributor Author

Xi-Row commented Dec 4, 2024

1
2
3
4
5
6
7

@Xi-Row
Copy link
Contributor Author

Xi-Row commented Dec 4, 2024

我按md文件中的顺序发出来了

@krahets krahets changed the title renfined! Fix the function for printing the queue Dec 4, 2024
@Xi-Row
Copy link
Contributor Author

Xi-Row commented Dec 4, 2024

修改说明

@krahets
Copy link
Owner

krahets commented Dec 4, 2024

Thank you for the PR!

Referring to the implementations in other programming languages, we decided to add the toArray() function instead. Here are the test results:

❯ hello-algo/codes/c/build/chapter_stack_and_queue/array_queue
队列 queue = [1, 3, 2, 5, 4]
队首元素 peek = 1
出队元素 pop = 1 ,出队后 queue = [3, 2, 5, 4]
队列长度 size = 4
队列是否为空 = false
第 0 轮入队 + 出队后 queue = [2, 5, 4, 0]
第 1 轮入队 + 出队后 queue = [5, 4, 0, 1]
第 2 轮入队 + 出队后 queue = [4, 0, 1, 2]
第 3 轮入队 + 出队后 queue = [0, 1, 2, 3]
第 4 轮入队 + 出队后 queue = [1, 2, 3, 4]
第 5 轮入队 + 出队后 queue = [2, 3, 4, 5]
第 6 轮入队 + 出队后 queue = [3, 4, 5, 6]
第 7 轮入队 + 出队后 queue = [4, 5, 6, 7]
第 8 轮入队 + 出队后 queue = [5, 6, 7, 8]
第 9 轮入队 + 出队后 queue = [6, 7, 8, 9]

❯ hello-algo/codes/c/build/chapter_stack_and_queue/array_deque
双向队列 deque = [3, 2, 5]
队首元素 peekFirst = 3
队尾元素 peekLast = 5
元素 4 队尾入队后 deque = [3, 2, 5, 4]
元素 1 队首入队后 deque = [1, 3, 2, 5, 4]
队尾出队元素 = 4 ,队尾出队后 deque= [1, 3, 2, 5]
队首出队元素 = 1 ,队首出队后 deque= [3, 2, 5]
双向队列长度 size = 3
队列是否为空 = false

@krahets krahets merged commit e41b0a3 into krahets:main Dec 4, 2024
4 checks passed
@krahets krahets added bug Bug fixes code Code-related labels Dec 4, 2024
@krahets
Copy link
Owner

krahets commented Dec 4, 2024

@Xi-Row Please check the latest version of the comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug fixes code Code-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants