CSD201_-_SP_2024_-_FE_1650.webp
H

CSD201_-_SP_2024_-_FE_1650.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;}
}
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;
}

I want to Inisin
Q: 1

Thông tin

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

Image metadata

Filename
CSD201_-_SP_2024_-_FE_1650.webp
File size
217.9 KB
Dimensions
1920px x 930px

Share this media

Back
Bên trên Bottom