MCQs on Linked list with answers
Circular Linked List | Set 1 (Introduction and Applications)We have discussed singly and doubly linked lists in the following posts. Show Introduction to Linked List & Insertion Circular linked list is a linked list where all nodes are connected to form a circle. There is no NULL at the end. A circular linked list can be a singly circular linked list or doubly circular linked list. Advantages of Circular Linked Lists: 2) Useful for implementation of queue. Unlike this implementation, we don’t need to maintain two pointers for front and rear if we use circular linked list. We can maintain a pointer to the last inserted node and front can always be obtained as next of last. 3) Circular lists are useful in applications to repeatedly go around the list. For example, when multiple applications are running on a PC, it is common for the operating system to put the running applications on a list and then to cycle through them, giving each of them a slice of time to execute, and then making them wait while the CPU is given to another application. It is convenient for the operating system to use a circular list so that when it reaches the end of the list it can cycle around to the front of the list. 4) Circular Doubly Linked Lists are used for implementation of advanced data structures like Fibonacci Heap. Next Posts : Please write comments if you find any bug in above code/algorithm, or find other ways to solve the same problem
Article Tags :
Linked List
circular linked list Practice Tags :
Linked List circular linked list Circular Singly Linked List | InsertionWe have discussed Singly and Circular Linked List in the following post: Why Circular? In a singly linked list, for accessing any node of the linked list, we start traversing from the first node. If we are at any node in the middle of the list, then it is not possible to access nodes that precede the given node. This problem can be solved by slightly altering the structure of a singly linked list. In a singly linked list, the next part (pointer to next node) is NULL. If we utilize this link to point to the first node, then we can reach the preceding nodes. Refer to this for more advantages of circular linked lists. In this post, the implementation and insertion of a node in a Circular Linked List using a singly linked list are explained. Implementation The pointer last points to node Z and last -> next points to node P. Why have we taken a pointer that points to the last node instead of the first node? Insertion
Insertion in an empty List After inserting node T, After insertion, T is the last node, so the pointer last points to node T. And Node T is the first and the last node, so T points to itself. C++
Java
Python3
C#
Javascript
After insertion, Function to insert nodes at the beginning of the list, C++
Java
Python3
C#
Javascript
After insertion, Function to insert a node at the end of the List C++
Java
Python3
C#
Javascript
After searching and insertion, Function to insert a node at the end of the List, C++
Java
Python3
C#
Javascript
The following is a complete program that uses all of the above methods to create a circular singly linked list. C++
Java
Python3
C#
Javascript
Output: 2 4 6 8 10 12This article is contributed by Anuj Chauhan. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to . See your article appearing on the GeeksforGeeks main page and help other Geeks.
Article Tags :
Linked List
circular linked list Practice Tags :
Linked List circular linked list Circular Singly Linked ListIn a circular Singly linked list, the last node of the list contains a pointer to the first node of the list. We can have circular singly linked list as well as circular doubly linked list. We traverse a circular singly linked list until we reach the same node where we started. The circular singly liked list has no beginning and no ending. There is no null value present in the next part of any of the nodes. The following image shows a circular singly linked list. Circular linked list are mostly used in task maintenance in operating systems. There are many examples where circular linked list are being used in computer science including browser surfing where a record of pages visited in the past by the user, is maintained in the form of circular linked lists and can be accessed again on clicking the previous button. Circular Linked List MCQ Questions and Answers1. What differentiates a circular linked list from a normal linked list?(A)You cannot have the ‘next’ pointer point to null in a circular linked list (B) It is faster to traverse the circular linked list (C) You may or may not have the ‘next’ pointer point to null in a circular linked list (D) Head node is known in circular linked list Answer: You may or may not have the ‘next’ pointer point to null in a circular linked list 2. A linear collection of data elements where the linear node is given by means of pointer is called?(A) Linked list (B) Node list (C) Primitive list (D) None Answer: Linked list 3. Which of the following operations is performed more efficiently by doubly linked list than by singly linked list?(A) Deleting a node whose location in given (B) Searching of an unsorted list for a given item (C) Inverting a node after the node with given location (D) Traversing a list to process each node View Answer / Hide Answer Answer: Deleting a node whose location in given 4. Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head and tail pointer. Given the representation, which of the following operation can be implemented in O(1) time?i) Insertion at the front of the linked list ii) Insertion at the end of the linked list iii) Deletion of the front node of the linked list iv) Deletion of the last node of the linked list (A) I and II (B) I and III (C) I, II and III (D) I, II and IV Answer: I, II and III 5. Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head pointer only. Given the representation, which of the following operation can be implemented in O(1) time?i) Insertion at the front of the linked list ii) Insertion at the end of the linked list iii) Deletion of the front node of the linked list iv) Deletion of the last node of the linked list (A) I and II (B) I and III (C) I, II and III (D) I, II and IV Answer: I and III 6. Consider an implementation of unsorted doubly linked list. Suppose it has its representation with a head pointer and tail pointer. Given the representation, which of the following operation can be implemented in O(1) time?i) Insertion at the front of the linked list ii) Insertion at the end of the linked list iii) Deletion of the front node of the linked list iv) Deletion of the end node of the linked list (A) I and II (B) I and III (C) I, II and III (D) I, II, III and IV Answer: I, II, III and IV 7. Consider an implementation of unsorted doubly linked list. Suppose it has its representation with a head pointer only. Given the representation, which of the following operation can be implemented in O(1) time?i) Insertion at the front of the linked list ii) Insertion at the end of the linked list iii) Deletion of the front node of the linked list iv) Deletion of the end node of the linked list (A) I and II (B) I and III (C) I, II and III (D) I, II, III and IV Answer: I and III 8. Consider an implementation of unsorted circular linked list. Suppose it has its representation with a head pointer only. Given the representation, which of the following operation can be implemented in O(1) time?i) Insertion at the front of the linked list ii) Insertion at the end of the linked list iii) Deletion of the front node of the linked list iv) Deletion of the end node of the linked list (A) I and II (B) I and III (C) I, II, III and IV (D) None Answer: None 9. Consider an implementation of unsorted circular doubly linked list. Suppose it has its representation with a head pointer only. Given the representation, which of the following operation can be implemented in O(1) time?i) Insertion at the front of the linked list ii) insertion at the end of the linked list iii) Deletion of the front node of the linked list iv) Deletion of the end node of the linked list (A) I and II (B) I and III (C) I, II and III (D) I, II, III and IV Answer: I, II, III and IV 10. In linked list each node contain minimum of two fields. One field is data field to store the data second field is?(A) Pointer to character (B) Pointer to integer (C) Pointer to node (D) Node Answer: Pointer to node 11. 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: θ (n) 12. What would be the asymptotic time complexity to add an element in the linked list?(A) O (1) (B) O (n) (C) O (n2) (D) None Answer: O (n) 13. What would be the asymptotic time complexity to find an element in the linked list?(A) O (1) (B) O (n) (C) O (n2) (D) None Answer: O (n) 14. What would be the asymptotic time complexity to insert an element at the second position in the linked list?(A) O (1) (B) O (n) (C) O (n2) (D) None Answer: O (1) 15. The concatenation of two list can performed in O(1) time. Which of the following variation of linked list can be used?(A) Singly linked list (B) Doubly linked list (C) Circular doubly linked list (D) Array implementation of list Answer: Circular doubly linked list 16. In a circular linked list(A) Components are all linked together in some sequential manner. (B) There is no beginning and no end. (C) Components are arranged hierarchically. (D) Forward and backward traversal within the list is permitted. Answer: There is no beginning and no end. 17. A variant of linked list in which last node of the list points to the first node of the list is?(A) Singly linked list (B) Doubly linked list (C) Circular linked list (D) Multiply linked list Answer: Circular linked list 18. In doubly linked lists, traversal can be performed?(A) Only in forward direction (B) Only in reverse direction (C) In both directions (D) None Answer: In both directions 19. What kind of linked list is best to answer question like “What is the item at position n?”(A) Singly linked list (B) Doubly linked list (C) Circular linked list (D) Array implementation of linked list Answer: Array implementation of linked list 20. A variation of linked list is circular linked list, in which the last node in the list points to first node of the list. One problem with this type of list is?(A) It waste memory space since the pointer head already points to the first node and thus the list node does not need to point to the first node. (B) It is not possible to add a node at the end of the list. (C) It is difficult to traverse the list as the pointer of the last node is now not NULL (D) All of above Answer: It is difficult to traverse the list as the pointer of the last node is now not NULL A circular linked list is a variation of a linked list in which the last node points to the first node, completing a full circle of nodes. In other words, this variation of the linked list doesn’t have a null element at the end. A circular linked list can be implemented using doubly-linked lists or other more specialized data structures which are supported directly by computer hardware. The circular linked list is a nonlinear data structure that can be implemented easily in computer programming languages. This data structure contains nodes that are connected to each other in a looped fashion, which means that the last node is connected to the first node and this one-way connection enables the nodes to store information easily. Many of the programming languages support this data structure for its capability to make quick work of complex tasks, which are otherwise time-consuming. The major advantage of using the data structure is the simplicity of implementing it without having to write any complicated algorithms or code. Different programming languages offer different advantages over other, but primarily you should consider your experience, familiarity with the language, and the features that are available based on your needs. More Questions on Abstract Data Types (Data Structure)
|