//CODING of QUEUE function in javascript
//original content of arrays A, B
A=['A',4,3,2,1];
B=['B'];
globi=0;
function queue(n,A,B)
{
// Moving items form A to B implementing a queue
// zeroth item of arrays represent a label
if (n<=1) return;
globi++;
$('#out').append("<pre>"+globi+" Moving "+A[1]+" from "+A[0]+" to "+B[0]+"</pre>")
B.push(A.splice(1,1));
queue(n-1,A,B);
}
#### CODING OF QUEUE function and full program in PYTHON
# original contents of lists A, B
# zeroth element is the label of array itself will not be moved to other lists
A=['A',4, 3,2,1]
B=['B']
i=0
def queue(n,A,B):
"""
Moving n items from A to B in a queue
"""
global i
if n<=1:
return
k=A.pop(1)
B.append(k)
i+=1
print(f"{i} moved {k} from {A[0]} to {B[0]}")
queue(n-1,A,B)
queue(len(A),A,B)
print("Moving A to B ")
print(A)
print(B)