Linked list

  Home  Data Structure  Linked list


“Data Structure Linked list frequently Asked Questions in various Linked list job Interviews by interviewer. The set of Data Structure Linked list interview questions here ensures that you offer a perfect answer to the interview questions posed to you. Get preparation of Data Structure Linked list job interview”



22 Linked List Questions And Answers

21⟩ Explain how to find 3rd element from end in a linked list in one pass?

This is another frequently asked linked list interview question. This question is exactly similar to finding middle element of linked list in single pass. If we apply same trick of maintaining two pointers and increment other pointer, when first has moved upto 3rd element, than when first pointer reaches to the end of linked list, second pointer will be pointing to the 3rd element from last in a linked list.

 192 views

22⟩ Suppose In an integer array, there is 1 to 100 number, out of one is duplicate, how to find?

This is a rather simple data structures question, especially for this kind of. In this case you can simply add all numbers stored in array, and total sum should be equal to n(n+1)/2. Now just subtract actual sum to expected sum, and that is your duplicate number. Of course there is a brute force way of checking each number against all other numbers, but that will result in performance of O(n^2) which is not good. By the way this trick will not work if array have multiple duplicates or its not numbers forming arithmetic progression. Here is example of one way to find duplicate number in array.

 207 views