OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Is there an efficient implementation of a FIFO queue and/or linked list built into Javascript?

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Guest
I'm writing algorithms that utilize a (FIFO) queue for efficiency. Namely, a list structure where you can append to the end of the list in O(1) time, and also remove from the front of the list in O(1) time.

Arrays can append to the end and remove from the front, but only appending to the end (with the append() method) is O(1) (amortized) time. Removing from the front (with the shift() method) is O(n) time.

Linked lists can do both appending to the end and removing from the front in O(1) time, so if there's a good linked list implementation built into Javascript, then I could use that for efficient queues.

I've Googled around and haven't been able to find either of these things - do they exist?

<p>I'm writing algorithms that utilize a (FIFO) queue for efficiency. Namely, a list structure where you can append to the end of the list in O(1) time, and also remove from the front of the list in O(1) time.</p>
<p>Arrays can append to the end and remove from the front, but only appending to the end (with the <code>append()</code> method) is O(1) (amortized) time. Removing from the front (with the <code>shift()</code> method) is O(n) time.</p>
<p>Linked lists can do both appending to the end and removing from the front in O(1) time, so if there's a good linked list implementation built into Javascript, then I could use that for efficient queues.</p>
<p>I've Googled around and haven't been able to find either of these things - do they exist?</p>
 

Latest posts

M
Replies
0
Views
1
Mohit Pant
M
Top