MCQs on Linked list with answers
Data Structure MCQ - Linked ListThis section focuses on the "Linked List" of the Data Structure. These Multiple Choice Questions (mcq) should be practiced to improve the Data Structure skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations. Show 1. What does the following function do for a given Linked List with first node as head? void fun1(struct node* head) { if(head == NULL) return; fun1(head->next); printf("%d ", head->data); }A. Prints all nodes of linked lists View Answer Ans : B Explanation: fun1() prints the given Linked List in reverse manner. For Linked List 1->2->3->4->5, fun1() prints 5->4->3->2->1. 2. A linear collection of data elements where the linear node is given by means of pointer is called? A. linked list View Answer Ans : A Explanation: A linear collection of data elements where the linear node is given by means of pointer is called linked list. 3. What is the time complexity to count the number of elements in the linked list? A. O(1) View Answer Ans : B Explanation: To count the number of elements, you have to traverse through the entire list, hence complexity is O(n). 4. 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) View Answer Ans : C Explanation: No Explanation. 5. What is the output of following function for start pointing to first node of following linked list? 1->2->3->4->5->6 void fun(struct node* start) { if(start == NULL) return; printf("%d ", start->data); if(start->next != NULL ) fun(start->next->next); printf("%d ", start->data); }A. 1 4 6 6 4 1 View Answer Ans : D Explanation:fun() prints alternate nodes of the given Linked List, first from head to end, and then from end to head. If Linked List has even number of nodes, then skips the last node. 6. What is the functionality of the following piece of code? public int function(int data) { Node temp = head; int var = 0; while(temp != null) { if(temp.getData() == data) { return var; } var = var+1; temp = temp.getNext(); } return Integer.MIN_VALUE; }A. Find and delete a given element in the list View Answer Ans : C Explanation: When temp is equal to data, the position of data is returned. 7. Linked lists are not suitable to for the implementation of? A. Insertion sort View Answer Ans : D Explanation: Linked lists are not suitable to for the implementation of Binary search. 8. In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is A. log 2 n View Answer Ans : D Explanation: In the worst case, the element to be searched has to be compared with all elements of linked list. 9. Which of these is an application of linked lists? A. To implement file systems View Answer Ans : D Explanation: Linked lists can be used to implement all of the above mentioned applications. 10. In circular linked list, insertion of node requires modification of? A. One pointer View Answer Ans : B Explanation: In circular linked list, insertion of node requires modification of Two pointer. Next » Also Check :
Discussion * You must be logged in to add comment. MCQ - Linked List in Data Structure11. Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head pointer only. i) Insertion at the front of the linked list View Answer Ans : B Explanation: None. 12. 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 View Answer Ans : C Explanation: None. 13. What would be the asymptotic time complexity to find an element in the linked list? A. O(1) View Answer Ans : B Explanation: None. 14. 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 View Answer Ans : C Explanation: None. 15. Consider the following definition in c programming language.Which of the following c code is used to create new node? struct node { int data; struct node * next; } typedef struct node NODE; NODE *ptr;A. ptr = (NODE*)malloc(sizeof(NODE)); View Answer Ans :A Explanation: As it represents the right way to create a node. 16. What kind of linked list is best to answer question like "What is the item at position n"? A. Singly linked list View Answer Ans : D Explanation: None. 17. Linked lists are not suitable to for the implementation of? A. Insertion sort View Answer Ans : D Explanation: It cannot be implemented using linked lists. 18. Linked list is considered as an example of ___________ type of memory allocation. A. Dynamic View Answer Ans : A Explanation: As memory is allocated at the run time. 19. In Linked List implementation, a node carries information regarding A. Data View Answer Ans : B Explanation: None. 20. Linked list data structure offers considerable saving in A. Computational Time View Answer Ans : C Explanation: Linked lists saves both space and time. « Prev Next » Also check :
Discussion * You must be logged in to add comment. Linked lists are not suitable to for the implementation of? Data Structure
Answer: Binary search
|