print(queue.pop(), end=' ') return def testUnstackOrder(stack): while (not stack.isEmpty()): print(stack.pop(), end=' ') #unstacks items from stack and prints in order return #-----TESTING QUEUE-----# print('Testing Queue Implementation') #initializing queue with 0 1 2 3 4 5 6 7 8 9 testQ = q.queue() for i in range(0, 10): testQ.push(i) print('Testing dequeue order') #output should be 0 1 2 3 4 5 6 7 8 9 testDequeueOrder(testQ) print('\n') #queue should be empty after test print('Testing queue empty...') assert (testQ.isEmpty() is True) print('Queue confirmed empty') print('\n') #-----TESTING STACK-----#
#dequeues items from queue and prints in order while(not queue.isEmpty()): print(queue.pop(),end=' ') return def testUnstackOrder(stack): while(not stack.isEmpty()): print(stack.pop(),end=' ') #unstacks items from stack and prints in order return #-----TESTING QUEUE-----# print('Testing Queue Implementation') #initializing queue with 0 1 2 3 4 5 6 7 8 9 testQ = q.queue() for i in range(0,10): testQ.push(i) print('Testing dequeue order') #output should be 0 1 2 3 4 5 6 7 8 9 testDequeueOrder(testQ) print('\n') #queue should be empty after test print('Testing queue empty...') assert(testQ.isEmpty() is True) print('Queue confirmed empty') print('\n') #-----TESTING STACK-----#
def __init__(self,seed): self.q=queue() #to hold the unvisited url's self.visited=[] #to hold the visited url's self.seed=seed self.q.enqueue(seed)