Q11.webp
Q

Q11.webp

Question: 11
(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;
}
C. void enqueue(Object x)
{ Node p = new Node(x);
p.next = null;
if(isEmpty())
}
head tail p;
else
tail.next=p;
D. void enqueue(Object x)
{ Node p new Node(x);
p.next = null;
if(isEmpty())
head tail p;
else
tail =p;
}

Thông tin

Category
CSD201
Thêm bởi
Quốc Khánh1
Ngày thêm
Lượt xem
2,001
Lượt bình luận
5
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom