# YOU CAN DOWNLOAD 200+ SUBJECTS PDF BOOK FOR COMPETITIVE EXAMINATIONS

## Data Structure Questions and Answers-Double Ended Queue (Dequeue)

Question 6 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

Which of the following can be used to delete an element from the rear end of the queue?

public Object deleteRear() throws emptyDEQException { if(isEmpty()) throw new emptyDEQException("Empty"); else { Node temp = head.getNext() | |

public Object deleteRear() throws emptyDEQException { if(isEmpty()) throw new emptyDEQException("Empty"); else { Node temp = head.getNext() | |

What is the time complexity of deleting from the rear end of the dequeue implemented with a singly linked list?

O(nlogn) | |

O(logn) | |

O(n) | |

O(n ^{2}) |

Question 7 Explanation:

Since a singly linked list is used, first you have to traverse till the end, so the complexity is O(n).

Question 8 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

After performing these set of operations, what does the final list look contain?

InsertFront(10); InsertFront(20); InsertRear(30); DeleteFront(); InsertRear(40); InsertRear(10); DeleteRear(); InsertRear(15); display();

10 30 10 15 | |

20 30 40 15 | |

20 30 40 10 | |

10 30 40 15 |

Question 8 Explanation:

A careful tracing of the given operation yields the result.

10

20 10

20 10 30

10 30

10 30 40

10 30 40 10

10 30 40

10 30 40 15

There are 8 questions to complete.