Discuss the differences between a queue and a stack.

What will be an ideal response?

(a) A stack is a last-in/first-out (LIFO) data structure. Items are removed in the reverse order in
which they were inserted. A queue is a first-in/first-out (FIFO) data structure. It mimics a line.
Items are inserted at the end of the structure and are removed from the front of the structure.

Computer Science & Information Technology

You might also like to view...

Upon encountering the designated delimiter character, the ignore member function will:

a. Ignore it and continue reading and discarding characters. b. Terminate. c. Replace it with an EOF character.

Computer Science & Information Technology

What does this code fragment store in d1 and d2 if the input file contains

``` string d1, d2; ... infile >>d1; getline( infile, d2 ); first line second line ``` a. d1 = "first" d2 = " line" b. d1 ="first" d2 = "second line" c. d1 = "first line" d2 = "second line" d. d1 = "first" d2 = " line second line"

Computer Science & Information Technology