Comparing LinkedLists and Arrays while also comparing their differences with sorted and unsorted data
- Adding
- Removing
- Retrieving
- Sorting
- Overall speed
- Overall memory usage
Actual questions
Discuss the feasibility of implementing an unsorted data set as a linked list rather than an array. What would the tradeoffs be in terms of insertion, removal, retrieval, computer memory, and speed of the application?
Discuss the feasibility of implementing a sorted data set as a linked list rather than an array. What would the tradeoffs be in terms of insertion, removal, retrieval, computer memory, and speed of the application?
Based on your answers to the previous questions, summarize the costs and benefits of using linked lists in an application.
My answers/input:
LinkedLists have to allocate memory everytime a new Node is added, useful when adding many Nodes and size keeps changing but generally slower when adding few elements
Arrays allocated memory at the beggining of the program run, resizing list slow (adding many elements slow if have to resize)
Retrieval is faster in array due to indexing
Adding/removing faster in LinkedList due to pointers