Question: You can design the algorithm in pseudo code We want to design a list-like data structure that supports the following operations on integers. ADDTOFRONT(e): Adds

You can design the algorithm in pseudo code

You can design the algorithm in pseudo code We want to design

We want to design a list-like data structure that supports the following operations on integers. ADDTOFRONT(e): Adds a new element e at the front of the list. ADDToBack(e): Adds a new element e at the end of the list. REMOVEFROMFRONT(): Removes the first element from the list and returns it. REMOVEFROMBACK(): Removes the last element from the list and returns it. SETELEMENT(i, e): Sets the element of the i-th element of the list to e. Each operation should run in O(1) time. You can assume that we know that the list will never contain more than k elements (k is not a constant and should not show up in your running time). Example execution: ADD TOBACK(0) [0] ADDTOFRONT(-1) (-1,0] ADD TO FRONT(2) [2,-1,0] SETELEMENT(1,6) [2,6,0] REMOVEFROMBACK() [2,6], returns o REMOVEFROMFRONT() [6], returns 2 a) Design a data structure that supports the above operations in the required time. b) Briefly argue the correctness of your data structure and operations. c) Analyse the running time of your operations

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!