more topic chapters

Queues

This is the simplified version and does not allow cyclic shifts...

Psuedocode


//ARRAY IS ALREADY CREATED & STORED...
//PUSH or Entering Items
PROCEDURE Push(Counter)
 IF Counter=(LENGTH(Queue)-1)
      THEN 
        OUTPUT "The Queue is full"
      ELSE
        Tail← Tail+1
        INPUT Value
        Queue[Tail]←Value
        Counter←Counter+1
 END IF		
END PROCEDURE
//POP or Removing
FUNCTION Pop(Counter) RETURNS INTEGER
 IF Counter=(LENGTH(Queue)-1)
      THEN 
        OUTPUT "The Queue is empty"
      ELSE
        Head←Head+1
        Value=Queue[Head]
        Counter←Counter+1
        RETURN Value
END FUNCTION

Head←-1
Tail←-1
Counter←0

//THERE ARE SOME IMPLICATIONS, IF A VALUE IS ENTERED OUT OF RANGE
THIS WILL RAISE AN ERROR AND CAUSE NO CYCLIC SHIFT	
	   
	   

There are some conditions for this code under different situation but you don't need to go in depth and this is the code that the exam requires from you

Python Algorithm

The code is in python for this algorithm

The code is free for anyone to copy and use...The copied code must have the same code and indentation as above

Try it yourself




Download Py