Consider the following pseudocode: declare a queue of characters, which is implemented by circular array of size 6.
4 phương ánCó giải thích
while(there are more characters in the word to read){read a character if a character is '*' then dequeue the queue
else
enqueue the character into the queue
}How the queue looks like after processing the input "Goo**dMor****ning**"?
Các phương án trả lời
Chọn một phương ánLời giảiChọn phương án để mở
Đáp án đúng: "(2)", tức bảng có hai ô 0 và 1 rỗng, i ở ô 2, n ở ô 3, g ở ô 4 và ô 5 rỗng. Chạy tay trên mảng vòng sáu ô: G, o, o vào các ô 0, 1, 2; hai dấu sao lấy ra G và o nên đầu hàng dời tới ô 2; d, M, o vào các ô 3, 4, 5 rồi r quay về ô 0; bốn dấu sao lấy ra o, d, M, o nên đầu hàng dời về ô 0 là chỗ của r; n, i, n, g vào các ô 1, 2, 3, 4; hai dấu sao cuối lấy ra r và n, đầu hàng dừng ở ô 2. Còn lại i, n, g ở các ô 2, 3, 4. "(1)" dồn i, n, g về ba ô đầu, đó là cách hình dung của mảng bị dịch dồn sau mỗi phép lấy ra chứ không phải mảng vòng. "(3)" đặt i ở ô 1, lệch một ô so với vị trí thật của đầu hàng. "(4)" đặt i ở ô 3 và n ở ô 4, lệch một ô về phía sau, tức đếm thừa một lần thêm vào.
Cùng phần 2
Select the statement that is most correct.
Which of the following applications may not use a stack?Có lời giảiCâu hỏiConsider the following pseudocode:
declare a stack of characters
while(there are more characters in the word to read)
{read a character
if a character is '*' then
pop the stack
else
push the character into the stack
}
while(the stack is not empty)
pop and write the poped character to the screen
What is written to the screen for the input "Good**Morn**in***g" ?Có lời giảiCâu hỏiConsider the following pseudocode:
declare a stack of characters
while(there are more characters in the word to read)
{read a character
if a character is '*' then
pop and write the poped character to the screen
else
push the character into the stack
}
What is written to the screen for the input "Good**Morn**i***ng" ?Có lời giảiCâu hỏiCả 51 câu của chủ đề51 câu
Xuất hiện trong 1 bộ đề
Đi tiếp từ đây