Question

Assume you have a stack and a queue implemented using an array of size 4. show...

Assume you have a stack and a queue implemented using an array of size 4. show the content of the array for the stack (then the queue) for the following operations: (for the queue replace push by add and pop by remove; keep in mind that the queue uses a circular array): push(-3), push(-5), push(-9), push(-10), pop(), pop(), push(-13), pop(), push( -15), push(-17).

Homework Answers

Answer #1

Ans

Stack operation performed on top of stack.

push increment top and insert element

pop remove element and decrement top.

,

Queue has two ends Front and Rear.

Insertion take place at rear and rear update as (rear+1)%size

Removal take place at front. Front update as (front+1)%capacity.

.

If any doubt ask in the comments.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1.A stack implemented with an array has what performance? Select one: a. O(n3) b. O(n log...
1.A stack implemented with an array has what performance? Select one: a. O(n3) b. O(n log n) c. O(n) d. O(n2) 2. A stack uses the first in first out insertion and deletion method. Select one: True False 3. Match the following stack operations with their meaning. object pop(); boolean isEmpty(); push (object); integer size(); object top(); meanings are: - returns the number of elements stored -just removes the last inserted elements - returns the last inserted elements without removing...
Create an add method for the BST (Binary Search Tree) class. add(self, new_value: object) -> None:...
Create an add method for the BST (Binary Search Tree) class. add(self, new_value: object) -> None: """This method adds new value to the tree, maintaining BST property. Duplicates must be allowed and placed in the right subtree.""" Example #1: tree = BST() print(tree) tree.add(10) tree.add(15) tree.add(5) print(tree) tree.add(15) tree.add(15) print(tree) tree.add(5) print(tree) Output: TREE in order { } TREE in order { 5, 10, 15 } TREE in order { 5, 10, 15, 15, 15 } TREE in order {...
   vi. Assume that a linked list stores the data, 20, 11, 13, 19, 12, 14...
   vi. Assume that a linked list stores the data, 20, 11, 13, 19, 12, 14 in that order. Assume that Node head references the first item in the list. What is the result to the linked list of       the following instructions? Assume that newNode          is a Node, already constructed. newNode.data = 1;                         newNode.next = head.next;                         head = newNode;       a. The value 1 is inserted into the linked list before 20       b. The...
ALL CODE MUST BE IN C++ Before you begin, you must write yourself a LinkedList class...
ALL CODE MUST BE IN C++ Before you begin, you must write yourself a LinkedList class and a Node class (please name your classes exactly ​as I did here). Please follow the below specifications for the two classes. Node.cpp ● This must be a generic class. ● Should contain a generic member variable that holds the nodes value. ● Should contain a next and prev Node* as denoted here. ● All member variables should be private. ● Use public and...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
You may either use SPSS for this problem or carry it out using hand calculations Below...
You may either use SPSS for this problem or carry it out using hand calculations Below are data for n = 20 individuals indicating the resting pulse rate of each person, and whether or not that person regularly exercises. Exercise and pulse rate data Person Resting pulse rate Regularly exercises 1 72 No 2 62 Yes 3 72 Yes 4 84 No 5 60 Yes 6 63 Yes 7 66 No 8 72 No 9 75 Yes 10 60 Yes...
For some reason I followed the steps in my project and I am getting the incorrect...
For some reason I followed the steps in my project and I am getting the incorrect output and when I am submitting it, it gives me compilation error. Printing empty array -- next line should be blank Testing append: Shouldn't crash! Should print 100 through 110 below, with 110 on a new line: 100 101 102 103 104 105 106 107 108 109 110 Checking capacity of new array: OK Append test #2: Should print 100 through 120 below, on...
can you please answer question 14-17. thank you, please show your work. Using the following information...
can you please answer question 14-17. thank you, please show your work. Using the following information find the ratios listed: Hamilton Company Comparative Balance Sheets December 31, 2018 and December 31, 2019 Assets         2018      2019   Difference Cash              15,000              47,000         32,000 Accounts Receivable              55,000              47,000         (8,000) Inventory           110,000           144,000         34,000 Prepaid Expenses                5,000                1,000         (4,000) Long term investments           127,000           115,000       (12,000) Land             55,000             55,000...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as possible: What is a checked exception, and what is an unchecked exception? What is NullPointerException? Which of the following statements (if any) will throw an exception? If no exception is thrown, what is the output? 1: System.out.println( 1 / 0 ); 2: System.out.println( 1.0 / 0 ); Point out the problem in the following code. Does the code throw any exceptions? 1: long value...
Can you please answer question 5-8. Thank you please show your work. Using the following information...
Can you please answer question 5-8. Thank you please show your work. Using the following information find the ratios listed: Hamilton Company Comparative Balance Sheets December 31, 2018 and December 31, 2019 Assets         2018      2019   Difference Cash              15,000              47,000         32,000 Accounts Receivable              55,000              47,000         (8,000) Inventory           110,000           144,000         34,000 Prepaid Expenses                5,000                1,000         (4,000) Long term investments           127,000           115,000       (12,000) Land             55,000             55,000...