McqMate

Q. |
## How do you insert a node at the beginning of the list? |

A. | public class insertfront(int data) { node node = new node(data, head, head.getnext()); node.getnext().setprev(node); head.setnext(node); size++; } |

B. | public class insertfront(int data) { node node = new node(data, head, head); node.getnext().setprev(node); head.setnext(node); size++; } |

C. | public class insertfront(int data) { node node = new node(data, head, head.getnext()); node.getnext().setprev(head); head.setnext(node); size++; } |

D. | public class insertfront(int data) { node node = new node(data, head, head.getnext()); node.getnext().setprev(node); head.setnext(node.getnext()); size++; } |

Answer» A. public class insertfront(int data) { node node = new node(data, head, head.getnext()); node.getnext().setprev(node); head.setnext(node); size++; } |

3.8k

0

Do you find this helpful?

21

View all MCQs in

Data Structures (DS)No comments yet

- A _________is a linked list which always contains a special node called the header node, at the beginning of the list.
- Which of the following statement is true? i) Using singly linked lists and circular list, it is not possible to traverse the list backwards. ii) To find the predecessor, it is required to traverse the list from the first node in case of singly linked list.
- To insert a new node in linked list free node will be available in ___________.
- A linked list whose last node points back to the list node instead of containing the null pointer________.
- A ______________ list is a header list where the node points back to the header node.
- If we implement heap as min-heap, deleting root node (value 1)from the heap. What would be the value of root node after second iteration if leaf node (value 100) is chosen to replace the root at start.
- Suppose you are given an implementation of a queue of integers. The operations that can be performed on the queue are: i. isEmpty (Q) — returns true if the queue is empty, false otherwise. ii. delete (Q) — deletes the element at the front of the queue and returns its value. iii. insert (Q, i) — inserts the integer i at the rear of the queue. Consider the following function: void f (queue Q) { int i ; if (!isEmpty(Q)) { i = delete(Q); f(Q); insert(Q, i); } }What operation is performed by the above function f ?
- If in a linked list address of first node is 1020 then what will be the address of node at 5th position ?
- _______________is a header list where the last node points back to the header node.
- In ……………, search start at the beginning of the list and check every element in the list.