<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://learn.cemetech.net/index.php?action=history&amp;feed=atom&amp;title=TI-BASIC%3AQueue</id>
	<title>TI-BASIC:Queue - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://learn.cemetech.net/index.php?action=history&amp;feed=atom&amp;title=TI-BASIC%3AQueue"/>
	<link rel="alternate" type="text/html" href="http://learn.cemetech.net/index.php?title=TI-BASIC:Queue&amp;action=history"/>
	<updated>2026-06-10T13:54:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.3</generator>
	<entry>
		<id>http://learn.cemetech.net/index.php?title=TI-BASIC:Queue&amp;diff=1229&amp;oldid=prev</id>
		<title>Maintenance script: Initial automated import</title>
		<link rel="alternate" type="text/html" href="http://learn.cemetech.net/index.php?title=TI-BASIC:Queue&amp;diff=1229&amp;oldid=prev"/>
		<updated>2016-02-24T18:41:15Z</updated>

		<summary type="html">&lt;p&gt;Initial automated import&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A queue is an abstract data structure that stores objects in a First In First Out basis. The two main operations that can be performed on a queue are &amp;#039;&amp;#039;enqueue&amp;#039;&amp;#039; and &amp;#039;&amp;#039;dequeue&amp;#039;&amp;#039;. &amp;#039;&amp;#039;Enqueue&amp;#039;&amp;#039; adds an element to the bottom of a queue. &amp;#039;&amp;#039;Dequeue&amp;#039;&amp;#039; removes the top element from the queue, and returns it. A queue can be visualized as a line of people waiting to get on a bus. The first person there gets on first, and the last person there gets on last.&lt;br /&gt;
&lt;br /&gt;
Queues are widely used in the TI-83+ operating system, and are found in most computer systems.&lt;br /&gt;
&lt;br /&gt;
= Implementation in TI-Basic =&lt;br /&gt;
&lt;br /&gt;
TI-Basic does not have a queue data structure by default, but depending on what needs to be stored, a stack can be implemented as either a list or a string. &lt;br /&gt;
&lt;br /&gt;
== Lists ==&lt;br /&gt;
&lt;br /&gt;
In a list, the top can be considered the first element of the list or the last element of the list. Both approaches are valid, and either may be more appropriate depending on the situation.&lt;br /&gt;
&lt;br /&gt;
=== First element as top ===&lt;br /&gt;
&lt;br /&gt;
To make a queue using a list, one can create a list for which one assumes that the first element is the top of the queue. In order to enqueue one would do:&lt;br /&gt;
&lt;br /&gt;
 :N→L₁(dim(L₁))&lt;br /&gt;
&lt;br /&gt;
This adds N to the end of the list. Dequeue is done by getting the value of the first element and then using [[TI-BASIC:Deltalist|ΔList(]] in conjuntion with [[TI-BASIC:Cumsum|cumSum(]] to remove the first element of the list. This can be done with the following code:&lt;br /&gt;
&lt;br /&gt;
 :L₁(1)→N&lt;br /&gt;
 :ΔList(cumSum(L₁))→L₁&lt;br /&gt;
&lt;br /&gt;
If the queue is empty, then the list will be empty and dim(L₁) will return 0.&lt;br /&gt;
&lt;br /&gt;
=== Last element as top ===&lt;br /&gt;
&lt;br /&gt;
To make a queue using a list, one can create a list for which one assumes that the last element is the top of the stack In order to enqueue onto the stack one would do:&lt;br /&gt;
&lt;br /&gt;
 :augment({N},L₁)→L₁&lt;br /&gt;
&lt;br /&gt;
This stores N into the first element of the list. Dequeue is done by getting the value of the last element and then decreasing the list size by one. This can be done with the following code:&lt;br /&gt;
&lt;br /&gt;
 :L₁(dim(L₁))→N&lt;br /&gt;
 :dim(L₁)-1→dim(L₁&lt;br /&gt;
&lt;br /&gt;
If the queue is empty, then the list will be empty and dim(L₁) will return 0.&lt;br /&gt;
&lt;br /&gt;
== Strings ==&lt;br /&gt;
&lt;br /&gt;
To make a queue using a string one has to store values into a string with a specified delimiter. The delimiter is a one or two token string that will &amp;#039;&amp;#039;not&amp;#039;&amp;#039; appear in any of the data items being put into the queue. This delimiter will change depending on what you are storing in the queue. To begin, store one instance of the delimiter (for this example, &amp;quot;::&amp;quot;) into a string which will be the stack. To push on to the string, simply add the new data and a delimiter to the end of the string (for this example Str0).&lt;br /&gt;
&lt;br /&gt;
 :Str0+Str1+&amp;quot;::&amp;quot;→Str0&lt;br /&gt;
 &lt;br /&gt;
To dequeue from the string, use the inString( function for find the first instance of the delimiter and remove it from the queue.&lt;br /&gt;
&lt;br /&gt;
 :inString(Str0,&amp;quot;::&amp;quot;)→N&lt;br /&gt;
 :sub(Str0,1,N-1)→Str1&lt;br /&gt;
 :sub(Str0,N+2,length(Str0)-N-1)→Str0&lt;br /&gt;
&lt;br /&gt;
If the queue is empty, the string will contain one delimiter and length(Str0) will return the length of the delimiter (in this case 2).[[Category:TI-BASIC]]&lt;br /&gt;
[[Category:TIBD]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>