240 likes | 339 Views
Queue Implementation with Arrays. QUEUEinit();. Queue Implementation with Arrays. front. back. QUEUEinit();. MAX_SIZE = 6. Variable. q[0]. q[1]. q[2]. q[3]. q[4]. q[5]. Value. ?. ?. ?. ?. ?. ?. Queue Implementation with Arrays. front. back. QUEUEinit(); QUEUEput('A');.
E N D
Queue Implementation with Arrays • QUEUEinit();
Queue Implementation with Arrays front back • QUEUEinit(); MAX_SIZE = 6 Variable q[0] q[1] q[2] q[3] q[4] q[5] Value ? ? ? ? ? ?
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value ? ? ? ? ? ?
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A ? ? ? ? ?
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A ? ? ? ? ?
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D ? ? ? ?
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D ? ? ? ?
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D T ? ? ?
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D T ? ? ?
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D T E ? ?
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); • QUEUEget(); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D T E ? ?
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); • QUEUEget(); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D T E ? ? Items dequeued: A
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); • QUEUEget(); • QUEUEget(); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D T E ? ? Items dequeued: A
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); • QUEUEget(); • QUEUEget(); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D T E ? ? Items dequeued: A D
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); • QUEUEget(); • QUEUEget(); • QUEUEget(); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D T E ? ? Items dequeued: A D
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); • QUEUEget(); • QUEUEget(); • QUEUEget(); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D T E ? ? Items dequeued: A D T
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); • QUEUEget(); • QUEUEget(); • QUEUEget(); • QUEUEput('X'); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D T E ? ? Items dequeued: A D T
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); • QUEUEget(); • QUEUEget(); • QUEUEget(); • QUEUEput('X'); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D T E X ? Items dequeued: A D T
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); • QUEUEget(); • QUEUEget(); • QUEUEget(); • QUEUEput('X'); • QUEUEput('A'); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D T E X ? Items dequeued: A D T
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); • QUEUEget(); • QUEUEget(); • QUEUEget(); • QUEUEput('X'); • QUEUEput('A'); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D T E X A Items dequeued: A D T
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); • QUEUEget(); • QUEUEget(); • QUEUEget(); • QUEUEput('X'); • QUEUEput('A'); • QUEUEput('M'); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value A D T E X A Items dequeued: A D T
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); • QUEUEget(); • QUEUEget(); • QUEUEget(); • QUEUEput('X'); • QUEUEput('A'); • QUEUEput('M'); wrap-around Variable q[0] q[1] q[2] q[3] q[4] q[5] Value M D T E X A Items dequeued: A D T
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); • QUEUEget(); • QUEUEget(); • QUEUEget(); • QUEUEput('X'); • QUEUEput('A'); • QUEUEput('M'); • QUEUEget(); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value M D T E X A Items dequeued: A D T
Queue Implementation with Arrays front back • QUEUEinit(); • QUEUEput('A'); • QUEUEput('D'); • QUEUEput('T'); • QUEUEput('E'); • QUEUEget(); • QUEUEget(); • QUEUEget(); • QUEUEput('X'); • QUEUEput('A'); • QUEUEput('M'); • QUEUEget(); Variable q[0] q[1] q[2] q[3] q[4] q[5] Value M D T E X A Items dequeued: A D T E