CSD201_-_SU_2024_-_RE_2502.webp
night_owl1

CSD201_-_SU_2024_-_RE_2502.webp

(Choose 1 answer)
Suppose we are implementing a queue using a singly linked list where the end of the list is treated as the end of the queue.
Specify the correct implementation of enqueue() method of the queue. (Choose the most suitable one)
A. void enqueue(Object x){ Node p = new Node(x);p.next = null;tail.next = p;
tail = p;
}
B. void enqueue(Object x){ Node p = new Node(x);p.next = null;if(isEmpty())head = tail = p;else{ tail.next = p;}
tail = p;
}
. void enqueue(Object x)C{ Node p = new Node(x);
p.next = null;if(isEmpty())head = tail = p;elsetail.next = p;}
D. void enqueue(Object x)
{ Node p = new Node(x);
p.next = null;
if(isEmpty())head = tail = p;

Thông tin

Category
CSD201
Thêm bởi
night_owl1
Ngày thêm
Lượt xem
3,116
Lượt bình luận
13
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
CSD201_-_SU_2024_-_RE_2502.webp
File size
250.2 KB
Dimensions
1920px x 1012px

Share this media

Back
Bên trên Bottom