subject

Let D represent a data structure, and let add and remove denote the appropriate operations on that particular structure (i. e. add is push if D is a Stack and enqueue if D is a Queue; remove is pop or dequeue respectively). Consider the following program. Procedure doSomething D := a data structure for(int i = 0; i < 10; i++) D. add(i) int num := random(D. size())* for(int j = 0; j < num; j++) print D. remove() end for end for while(!D. isEmpty()) print D. remove() end while *generates a random integer from the interval [0, D. size()) Determine if each of the following is a possible result of the procedure if (1) D is a Stack and (2) D is a Queue. Explain your reasoning.

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 21:30, dpazmembreno
Ajeweler designing a pin has decided to use five stones chosen from diamonds, rubies, and emeralds. in how many ways can the stones be selected?
Answers: 3
image
Computers and Technology, 22.06.2019 04:30, ParallelUniverse
Which of the statements below is true? the formatting, standard, and drawing commands are unavailable. the formatting, standard, and drawing commands have been used. the formatting, standard, and drawing toolbars are displayed. the formatting, standard, and drawing toolbars are hidden.
Answers: 1
image
Computers and Technology, 22.06.2019 22:00, bbysl15
What is the name of the option in most presentation applications with which you can modify slide elements? 1. the option enables you to modify a slide element in most presentation applications.
Answers: 3
image
Computers and Technology, 23.06.2019 18:30, sawyerfauver
The computers in the sales department did not have enough data storage capacity to contain all the information the department needed to store, and it was taking a long time for team members to access the data they needed. to fix the problem, the technician installed new, larger hard drives on all the computers.
Answers: 1
You know the right answer?
Let D represent a data structure, and let add and remove denote the appropriate operations on that p...

Questions in other subjects:

Konu
Mathematics, 28.08.2020 01:01