Wednesday, February 4, 2009

QUEUE DATA STRUCTURE

Assuming an empty data structure simulate discriptively the process involves in cosecutively accomodating the following data in your assigned data structure.Monitor values at each stage.

ANSWER:

In a queue data structure,the stucture is empty without any data.In common operations from C++,bool empty is true if the queue is empty.Data 1 is push first.Next,Data 2 is push before or added to the back of Data 1.Then,Data 3 is push before Data2.Finally,Data 4 is push before Data 3.So now apply First-In-First-Out data structure.It states that the first element added to the queue will be the first one to be removed.The data that is first one to be removed or leaves the queue from the front represents the dequeue function.The data is added to the back or join he end of the line represents the enqueue function.You cannot just insert in the middle of the queue.The data structure has now occupied.The size function is determine,the total number of element in the queue or the length of the line.About of its requirement that whenever the element is added,all elements that were added before have to be removed before the new element can be invoked.Void pop() from C++ Standard Template Library or pop removes Data 1 as the first data added at the front of a non empty queue.Next,Data 2 is pop before Data 1.Then,Data 3 is pop before Data 2.Finally,Data 4 is pop before Data 3 was removed.The empty function will return true because there was nothing in the line.