Data structure - Interview Questions and Answers for 'Amazon' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Interview Questions


 3335 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Data structure - Interview Questions and Answers for 'Amazon' - 3 question(s) found - Order By Newest

Very frequently asked. Favorite question in Walk in Drive of many Indian service companies.
  Q1. What is the difference between ArrayList and LinkedList ?Core Java
admin
info@buggybread.com
Ans. Underlying data structure for ArrayList is Array whereas LinkedList is the linked list and hence have following differences -

1. ArrayList needs continuous memory locations and hence need to be moved to a bigger space if new elements are to be added to a filled array which is not required for LinkedList.

2. Removal and Insertion at specific place in ArrayList requires moving all elements and hence leads to O(n) insertions and removal whereas its constant O(1) for LinkedList.

3. Random access using index in ArrayList is faster than LinkedList which requires traversing the complete list through references.

4. Though Linear Search takes Similar Time for both, Binary Search using LinkedList requires creating new Model called Binary Search Tree which is slower but offers constant time insertion and deletion.

5. For a set of integers you want to sort using quicksort, it's probably faster to use an array; for a set of large structures you want to sort using selection sort, a linked list will be faster.

  Sample Code for ArrayList

  Sample Code for LinkedList

 Help us improve. Please let us know the company, where you were asked this question :   


   Like         Discuss         Correct / Improve     collections   java   data structures   arraylist   linkedlist     Asked in 61 Companies      Basic        frequent

Try 1 Question(s) Test


Related Questions

 If you are given a choice to use either ArrayList and LinkedList, Which one would you use and Why ?
 Collections.sort can only be performed on ..

a. Set
b. List
c. Map
d. Any Collection implementation
 Is this a valid initialization ? Explain.

Collection<Collection> collection = new LinkedList<LinkedList>();
 In a Linked list with sorted numbers, insert a new numbers while maintaining the sort order.
  What is the difference between List, Set and Map ?

or

What are the different Java Collections Interfaces ?
  Difference between Vector and ArrayList ?
  Overridden methods must have the same ...
  Which of the following doesn't extend Collection interface ?
  Will this code give error if i try to add two heterogeneous elements in the arraylist. ? and Why ?


 Q2. In a Tree, find common ancestor of two nodes.Data Structures2017-08-24 21:45:59

 This question was recently asked at 'Amazon'.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 structures     Asked in 1 Companies


Related Questions

  Difference between TreeMap and HashMap ?
  Which of the following collections stores its elements in insertion Order ?

a. HashMap
b. TreeMap
c. LinkedHashMap
d. LinkedMap
 Difference beween HashSet and TreeSet ?
  What is reflection ?
  What is comparator interface used for ?
  If I try to add Enum constants to a TreeSet, What sorting order will it use ?
  Which of the following collection maintain its elements in Natural Sorted order ?
 What is a binary tree ?
  What are the phases of the JSP life cycle ?
  Which are the sorted collections ?


 Q3. Write an efficient program for printing k largest elements in an array. Elements in array can be in any order.Data Structure2017-10-21 08:25:55

 This question was recently asked at 'Amazon'.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  coding  code     Asked in 1 Companies


Related Questions

  What are the disadvantages of using arrays ?
  What are the Disadvantages of using Collection Classes over Arrays ?
 Difference between Arrays and ArrayList ?
 Can we declare an array without assigning the size of an array?
 If arrays cannot be resized , Why is this code valid

String[] strArray = new String[2];
strArray = new String[5];
 Why doesn't this code give compile time error when we are clearly trying to add an integer element to an array of Strings

Object[] strArray = new String[2];
strArray[0] = 5;
  What is the advantage of using arrays over variables ?
  Advantage of Collection classes over Arrays ?
  What is the difference between int[] x; and int x[]; ?
 Write a Program to merge two sorted arrays ?




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this