Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

undefined a) Two integer variables x and number as well as a stack si of size 6 and a circular queue Q1 of size 15

image text in transcribedundefined

a) Two integer variables x and number as well as a stack si of size 6 and a circular queue Q1 of size 15 are created. What would be the contents of the circular queue Q1 after the following code is executed and the following data are entered? int x, number Q1 = createQueue S1 = createStack loop (not end of file) read number if (number not 0) pushStack (S1, number) enqueue (Q1, number) else popStack (S1,x) popStack (S1, x) loop (not empty S1) popStack (S1,x) enqueu (Q1,x) dequeu (Q1,x) end loop end if end loop The data are 23, 7, 9, 10, 0, 18, 7, 38, 0, 15, 36, 0, 42, 63, 8, 19, 28, 0 (5 marks) b) Describe in pseudo-code an implementation of the methods addLast(e) and addBefore(P,e) realized by using only methods in the set: { isEmpty() - a boolean function that checks if the list is empty, checkPosition(p) - a procedurre that checks / get the position specified by the pointer p. first() - a function that gets and returns the first position of the list, last() - a function that gets and returns the last position of the list, prev(p) - a function that gets and returns a pointer to the previous nodes of the current pointer p, addAfter(p, e) - a procedure that adds the element e to the position specified by a pointer p. addFirst(e) - a procedure that adds the element e to the first position of the list }

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_2

Step: 3

blur-text-image_3

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

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions