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 "Hello∗∗∗Worl***d*"?
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: "(4)", tức mảng vòng có r ở ô 1, l ở ô 2, d ở ô 3 và ba ô 0, 4, 5 để rỗng. Chạy tay trên mảng sáu ô: H, e, l, l, o vào các ô 0 đến 4; ba dấu sao lấy ra H, e, l nên đầu hàng đợi dời tới ô 3; W vào ô 5, rồi o, r, l quay vòng về các ô 0, 1, 2 và hàng đợi đầy; ba dấu sao tiếp lấy ra l, o, W nên đầu hàng dời tới ô 0; d vào ô 3; dấu sao cuối lấy ra o ở ô 0. Còn đúng r ở ô 1, l ở ô 2, d ở ô 3. "(1)" đặt d ở ô 0 cùng r ở ô 4 và l ở ô 5, tức đầu hàng đợi lệch một ô so với vị trí thật. "(2)" đặt l ở ô 0, d ở ô 1 và r ở ô 5, phá cả thứ tự r trước l trước d. "(3)" dồn r, l, d về ba ô đầu, đó là hình ảnh của mảng bị dịch dồn sau mỗi phép lấy ra, còn mảng vòng không dịch phần tử mà chỉ dời chỉ số đầu hàng.
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