McqMate

Q. |
## What would be the asymptotic time complexity to insert an element at the front of the linked list (head is known)? |

A. | O(1) |

B. | O(n) |

C. | O(n2) |

D. | O(n3) |

Answer» A. O(1) |

1.4k

0

Do you find this helpful?

20

View all MCQs in

Data Structures (DS)No comments yet

- What would be the asymptotic time complexity to insert an element at the second position in the linked list?
- 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?
- 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 would be the asymptotic time complexity to find an element in the linked 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.
- 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; }
- 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 ?
- What is the time complexity of searching for an element in a circular linked list?
- What differentiates a circular linked list from a normal linked list?
- What differentiates a circular linked list from a normal linked list?