Hi Could any one answer the following question 1.) Describe the output for the f
ID: 3609554 • Letter: H
Question
Hi Could any one answer the following question 1.) Describe the output for the following sequence of dequeoperations insertFirst(3), insertLast(8), insertLast(9), insertFirst(5),removeFirst( ), removeLast( ), first( ), insertLast(7), removeFirst( ), Last( ), removeLast( ). Please expain every thing and please mention each and everystep. Thank you Hi Could any one answer the following question 1.) Describe the output for the following sequence of dequeoperations insertFirst(3), insertLast(8), insertLast(9), insertFirst(5),removeFirst( ), removeLast( ), first( ), insertLast(7), removeFirst( ), Last( ), removeLast( ). Please expain every thing and please mention each and everystep. Thank youExplanation / Answer
insertFirst(3)add the 3 at the front of the list
list = 3
insertLast(8)
add the 8 at the end of the list
list = 8, 3
insertLast(9)
add the 9 at the end of the list
list = 9,8,3
insertFirst(5)
add the 5 at the front of the list
list=9,8,3,5
removeFirst( )
remove the item from the front of the list, 5 removed
list=9,8,3
removeLast( )
remove the item from the end of the list 9 removed
list = 8,3
first( ), - I assume you meant removeFirst()
remove the item from the front of the list 3 removed
list=8
insertLast(7)
insert the 7 at the end of the list
list=7,8
removeFirst( )
remove the item from the front of the list 8 removed
list=7
Last( ) - I assume you meant removeLast
remove the item from the end of the list 7 removed
list=empty
, removeLast( ).
nothing to remove