Question
Note: I am using Microsoft Visual Studio 2012 in C++. The following code established a queue called toDoList that holds up to 1000000 randomly generated
Note: I am using Microsoft Visual Studio 2012 in C++.
The following code established a queue called toDoList that holds up to 1000000 randomly generated numbers. The following functions need to be implemented within struct Queue: Queue(), push, pop, peek, print, and isEmpty . Queue initializes the first and last pointers to NULL, push inserts numbers at the back of the toDoList, pop removes each number at the front, peek returns data in the first element, print gets a temp pointer to first and prints the data in temp, and isEmpty returns true if head is NULL or false if it is not . Is there a way to implement these functions in a way so that they would perform in under 1 second?
ToDolist2 cpp Mirusoft Visual S.udio Express 2012 for Windows Desktop Quick Launch (Cti+o ToDoList2.cpa. includeiostream #include "Queue" h" inclue TineSupporL.h #includ "Randomsupport.h" using nanespace std; Just a counter Long -9; A unction that increrients the counter Hvold process(long task){ We will insert 1 nillion random elements in our to-do 1ist const int N 1082000; randonizer devicene_randanizer); uniform distribution dist = new distribution (1, N); Create a to-do list as a queue Queue toCoList; Neasure how 1ong it takes to push all the elements tinestanp insertstcurrent tine for (int 1 -e; i n; i++) { et a random nunber long a - sanple(dist, drvice); Push it into the queue toDoList.push a) tinestamp insertEndcurrent tine); You can print out the queue, but only do it far small /reDoList print 1 36 12:02 AM Type here to search 1114/2017 ToDolist2 cpp Mirusoft Visual S.udio Express 2012 for Windows Desktop Quick Launch (Cti+o ToDoList2.cpa. includeiostream #include "Queue" h" inclue TineSupporL.h #includ "Randomsupport.h" using nanespace std; Just a counter Long -9; A unction that increrients the counter Hvold process(long task){ We will insert 1 nillion random elements in our to-do 1ist const int N 1082000; randonizer devicene_randanizer); uniform distribution dist = new distribution (1, N); Create a to-do list as a queue Queue toCoList; Neasure how 1ong it takes to push all the elements tinestanp insertstcurrent tine for (int 1 -e; i n; i++) { et a random nunber long a - sanple(dist, drvice); Push it into the queue toDoList.push a) tinestamp insertEndcurrent tine); You can print out the queue, but only do it far small /reDoList print 1 36 12:02 AM Type here to search 1114/2017Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started