- Array Linear Search arrays basic generics avg O(n/2) best O(1) worst O(n)
- Array Append arrays basic generics O(n) resizing
- Array Insert arrays basic generics O(n) resizing
- Array Delete basic generics resizing O(n)
- Linked List Append generics arrays append O(1)
- Linked List Merge generic ordered arrays merge O(n+m)
- Bubble Sort generics swap array sorting
- Hoare Partitions generics array hoare sorting O(n) space complexity O(1)
- Common Words strings O(n+m)
- Two Sum arrays O(n) *
- K Closest Points arrays O (N * Long(N)) * **
- Queue generic queue using an slice
- Neuron basic neuron
- * study later
- *** try to make it simpler
Arrays will be faster than linked lists for most applications. This is because arrays are stored in contiguous memory locations, which makes it easy to access elements using an index. Linked lists, on the other hand, require traversing the list to find an element, which can be slower.
Use arrays when the number of elements is known in advance and when you need to access elements by index. When accessing the elements is a common operation, arrays are a better choice. Array access time is O(1) while linked list is O(n). Binary search, interpolation search, quick sort, and merge sort are all faster with arrays.
Use linked lists when the number of elements is not known in advance and when you need to insert or delete elements. The most common use case of Linked List is the implementation of undo operation in Browsers and editing software. If you require an array of linked list for hashing, you can use a linked list to handle collisions.