Question: 1 Singly Linked Lists Consider singly linked list and array data structures as discussed in the lectures. Knowing their advantages and weaknesses, please compare the
1 Singly Linked Lists Consider singly linked list and array data structures as discussed in the lectures. Knowing their advantages and weaknesses, please compare the complexity of the fol- lowing operations: 1.1 Retrieve the value on a given index Knowing there are n elements in your ar- ray/list, retrieve the value of the i-th ele- ment for an arbitrary 0 i < n. 1.2 Set the value on a given index Knowing there are n elements in your ar- ray/list, set the i-th element to a given value for an arbitrary 0 i < n. 1.3 Traverse the container Traverse the elements in their natural or- der, i.e. from index 0 to n. 1.4 Traverse the container in reversed or- der Traverse the elements in a reversed order, i.e. from index n to 0. For the list version, do not use any extra storage and do not modify the list itself. 1.5 Insert an element Given an index i for the case of an array and a pointer p to an element for the case of a linked list, insert a new element into the container to trail i or p, respectively. 1.6 Delete an element Given an index i for the case of an array and a pointer p to an element for the case of a linked list, remove the element trailing i or p, respectively.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
