Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use the following code given below to write another code with the following instructions give in the picture. please follow all the steps given.

Please use the following code given below to write another code with the following instructions give in the picture. please follow all the steps given.

Code: #include #include #include #include #include #include using namespace std; default_random_engine generator((unsigned int)time(NULL)); uniform_int_distribution distribution(INT_MIN, INT_MAX); void randomStream(string filename, int length) { ofstream outFile(filename.c_str()); string characters = "ADPECS"; for (int i = 0; i > lines; randomStream(filename, lines); system("pause"); return 0; }

image text in transcribed

Description: In assignment 1 you wrote a program that produced a file. For example, it may be A-3245 A 2344 A 344322 A-34 1.000 D Use the program to produce a file with 20 instructions. Please draw the sequence of 20 stacks (you may draw them similar to the way we draw them in class) as follows: Your stack should change at each line of the file, processing the file as if it was a set of instructions: If the letter is "A" & should get the number from the remainder of the line as a string, and push() that string into the stack You should tel me the return value of the push() operations If the letter is a "P", it should peek) the stack It must tell me the return value of the peek () operations and the value passed back by reference If the letter is a "D", it should check the top of the stack It should pop the stack and tell me the return value and the value passed back by reference For example, using the sample file above On line 1 The system reads "p" it will try to peek () the stack. Since it's empty, it will return FAILURE On line 2 The system reads "D". It will try to pop the stack. Since it's empty, it will return FAILURE On line 3 The system reads "A-3245" It will try to push() -3245 into the stack. This will succeed, and return SUCCESS The system reads "A 2344" It will try to push() 2344 into the stack. This will succeed, and return SUCCESS On line 5 The system reads "D" It will try to pop() the stack. It will return SUCCESS The reference parameter will be 2344. Some time later On line 4 On line 1000 The system reads "D". It will try to pop() all three stacks. Depending on what happens in operations 8999 and the capacity, it may return SUCCESS or FAILURE. If it returns SUCCESS then it will have some reference value Please hand in a Word (.docx) file with: The 20 operations produced by HW1 The sequence of pictures you drew (with operations and return values, as above)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

socialist egalitarianism which resulted in wage levelling;

Answered: 1 week ago

Question

soyuznye (all-Union, controlling enterprises directly from Moscow);

Answered: 1 week ago