Data Structure - Interview Questions and Answers for 'Data structure' - 72 question(s) found - Order By Rating Q1. How to delete a node from linked list if u do not have head and only have a pointer to the element which has to be removed ? Data Structure 2019-11-22 12:22:22
This question was recently asked at 'LifCare'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q2. How to sort an ArrayList of objects Data Structure 2019-10-29 15:21:43
This question was recently asked at 'Amdocs'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q3. What is the O notation for the ArrayList and List? And which one would you choose to insert item in the middle? Data Structure 2019-10-29 15:21:28
This question was recently asked at 'ExpertSoft'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies This question was recently asked at 'Unisys'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q5. Write an algorithm to shift a linked list n positions. Data Structure 2019-09-17 13:10:15
This question was recently asked at 'Amdocs'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q6. What is the time complexity and space complexity of reversing a Linked List ? Data Structure 2019-09-17 09:01:18
Ans. o(n) for time complexity
o(1) for space complexity Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   This question was recently asked at 'Tata Consultancy (TCS)'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  message queue Asked in 1 Companies This question was recently asked at 'Compro Technologies'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies This question was recently asked at 'Jefferies'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q10. Implement a queue, using only stacks Data Structure 2019-01-31 20:38:20
This question was recently asked at 'IBM India'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  queue  stack Asked in 1 Companies Q11. Write a Program to print all nodes of the data structure ? Algorithm 2019-01-29 13:24:26
This question was recently asked at 'Overstock.com'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  data structure  algorithm Asked in 1 Companies Q12. Implement a Stack with 2 threads in which one thread push data and another pop data. Data Structure 2018-11-27 09:14:19
This question was recently asked at 'HCL Technologies'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  stack Asked in 1 Companies Ans. Work with two pointers on the linked list - a slow pointer (increments by one node) and a fast pointer (increments by two nodes). If both of these pointers meet at the same node, then there is a cycle in the linked list. Otherwise, no cycle. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  linkedlist Asked in 1 Companies Q14. Write a Program to Find the maximum sum of the sub array ? Data Structure 2018-09-16 16:26:46
This question was recently asked at 'Reddit'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Maximum subarray variant  arrays  sub array  subarray Asked in 1 Companies Q15. Write a program to insert a value after a specific value in an array. Data Structure 2018-07-22 07:39:24
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q16. Find the length of the non repeated numbers in an array. Data Structure 2018-07-22 07:35:38
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q17. Find number of recycled pairs in n array. Data Structure 2018-07-22 07:33:16
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q18. In an array every element is repeated twice except one, Find that element? Data Structure 2018-07-22 07:30:31
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q19. Difference between Arrays and LinkedList ? Data Structure 2018-07-22 07:24:14
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arrays vs linkedlist Q20. Can you write code to copy one array into another ? Data Structure 2018-07-22 07:19:26
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   This question was recently asked at 'Deutsche Bank'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q22. Why does an array need continuous memory locations and not Linked List ? Data Structure 2018-06-11 09:21:56
Ans. Array needs continuous memory location because it need to provide random access of it's elements which is not required for Linked List.
Array index acts as an offset from the base address and hence can retrieve the respective element using the expression Base Address + ( Index * Element Size ). This expression could only hold true if the elements are in continuous memory location. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q23. Why does an array index starts at 0 and not 1 ? Data Structure 2018-06-11 08:41:24
Ans. The array index starts with 0 because program locates an element using the expression ( BaseAddress + ( Index * size of array Element ), where index is used as an offset. As the starting address is actually the address of first element, the index of first element is used as 0 and so on. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q24. How will you implement your own custom hashmap and linkedlist ? Data Structure 2018-06-08 19:16:25
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q25. What can we do if we need to retrieve Fibonacci value at a particular index faster ? Can we use Linked List ? Data Structure 2018-06-05 15:32:51
This question was recently asked at 'Canopy Tax'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  LinkedList Asked in 1 Companies Q26. Write a method that returns maximum depth of a tree ? Algorithm 2018-05-24 08:40:50
This question was recently asked at 'One Click Retail'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  tree  data structure  maximum depth of tree Asked in 1 Companies Q27. What is the difference between pop and peek function of stack ? Data Structure 2018-05-24 08:34:36
Ans. pop method pulls the top element from the stack and then move the top to the next element whereas peek only get the top element but doesn't move the top. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  stack Q28. Write a program to sort a stack in ascending order You should not make any assumptions about how the stack is implemented The following are the only functions that should be used to write this program: push | pop | peek | isEmpty Algorithm 2018-05-24 08:33:37
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Data Structures Q29. Describe how you could use a single array to implement three stacks Algorithm 2018-05-24 08:28:08
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Data Structure Q30. Write a Program to implement stack using LinkedList. Data Structure 2018-05-24 08:25:40
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Data Structure Q31. What is the access time for ArrayList and LinkedList ? Data Structure 2018-05-23 19:18:48
Ans. O(1) for ArrayList
O(n) for LinkedList Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 2 Companies Q32. What is the "multiplicative congruence" method for determining where an element belongs in a hash table ? Data Structure 2018-05-19 18:57:35
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q33. Describe how a queue is usually created using sequential allocation. Data Structure 2018-05-19 18:56:18
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q34. If a stack is implemented using linkedlist, which end (head or tail) should represent the top ? Data Structure 2018-05-19 18:55:34
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q35. If a stack is implemented using an array, which end (head or tail) should represent the top ? Data Structure 2018-05-19 18:54:28
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q36. Can we access elements at a particular index using LinkedList collection class ? Data Structure 2018-04-29 09:05:25
Ans. Yes we can. But as the underlying structure of the collection class is double linked list, it will eventually have to traverse to the element linearlly and hence would result in bad performance. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q37. Which of the following - arrays or LinkedList allow elements to be accessed using index and how ? Data Structure 2018-04-29 09:03:26
Ans. Arrays allows elements to be accessed directly using the index.
As Array elements are stored in continuous memory locations it's very easy to find the memory address of any element using the formula as following
Memory Address of Array start or index 0 + ( Size of array element * Index ) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arrays  linkedlist Q38. Difference between Arrays and LinkedList ? Data Structure 2018-04-26 18:57:20
This question was recently asked at 'Spillman Technologies,Motorola Solutions'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 2 Companies This question was recently asked at 'Collabera'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hash codes  hashcode Asked in 1 Companies Q40. Create a stack of specific size using arrayList? Data Structure 2018-04-04 21:33:45
Ans. public class StackUsingArrayList {
public static void main(String[] args) {
List list = new ArrayList();
list.add("A");
list.add("B");
list.add("C");
Stack stack = new Stack();
list.forEach(a -> stack.add(a));
System.out.println(stack);
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies