McqMate

Q. |
## What would be the asymptotic time complexity to add a node at the end of singly linked list, if the pointer is initially pointing to the head of the list? |

A. | O(1) |

B. | O(n) |

C. | θ(n) |

D. | θ(1) |

Answer» C. θ(n) |

807

0

Do you find this helpful?

7

View all MCQs in

Data Structures (DS)No comments yet

- 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.
- public int function() { if(head == null) return Integer.MIN_VALUE; int var; Node temp = head; while(temp.getNext() != head) temp = temp.getNext(); if(temp == head) { var = head.getItem(); head = null; return var; } temp.setNext(head.getNext()); var = head.getItem(); head = head.getNext(); return var; } What is the functionality of the following code? Choose the most appropriate answer.
- What is the functionality of the following code? Choose the most appropriate answer. public int function() { if(head == null) return Integer.MIN_VALUE; int var; Node temp = head; Node cur; while(temp.getNext() != head) { cur = temp; temp = temp.getNext(); } if(temp == head) { var = head.getItem(); head = null; return var; } var = temp.getItem(); cur.setNext(head); return var; }
- What would be the asymptotic time complexity to insert an element at the front of the linked list (head is known)?
- What would be the asymptotic time complexity to find an element in the linked list?
- What would be the asymptotic time complexity to insert an element at the second position in the linked list?
- Worst space complexity of singly linked list is
- A linked list whose last node points back to the list node instead of containing the null pointer________.
- A _________is a linked list which always contains a special node called the header node, at the beginning of the list.
- What is the worst case time complexity of inserting a node in a doubly linked list?