3)
a)
with circular array, we can perform seeless enqueue and dequeue
operations on queue, without having conserns about,managing the gap
in the array,since it is circular
while in case of regular array, we must keep track of empty
locations, to fill the coming values, in first come first serve
fashion
b)
Traversal using stack on tree:
26,25,2,19,17,7,1
c)
while implemeting stack using linear Array, if we use index[0] as
top, then, whenever we push new element to stack, we have to move
all elements of the stack 1 position, so that the index[0] will be
freed to insert new element, so it increases the complexity of push
operation
which leads to poor performance
d)
priority queue: inserts elements in passed order, but deletes
element with highest priority
implementing stack using priority queue:
stack works in last in first out fashion
means last element inserted is to be deleted first
so, we ensure that every time when a new element is inserted its
priority will be highest of the already inserted elements
because, of this priority queue will deletes the last item, that is
inserted
which works as Last in first out fashion
implementing queue using priority queue:
queue works in first in first out fashion
means first element inserted is to be deleted first
so, we ensure that every time when a new element is inserted its
priority will be lowest of the already inserted elements
because, of this priority queue will deletes the first item which
has the highest priorty
which works as first in first out fashion
implementing randomizedqueue using priority queue:
randomized queue inserts in passed order and deletes in random
order
so, we ensure that every time when a new element is inserted its
priority will be randomized
because, of this priority queue will deletes the item which has the
highest priorty
3) Stacks vs Queues: a) A Circular Array is a common data structure for a buffer...
In C++ Implement a queue data structure using two stacks. Remember a queue has enqueue and dequeue functions. You could use either the array or linked list implementation for stacks and queues. Source for stack array: --------------------------------------------------- #include<iostream> #define SIZE 100 #define NO_ELEMENT -999999 using namespace std; class Stack { int arr[SIZE]; // array to store Stack elements int top; public: Stack() { top = -1; } void push(int); // push an element into Stack int pop(); // pop the...
(C++) (VISUAL STUDIO) Circular Queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle. In a normal Queue, we can insert elements until queue becomes full. But once queue becomes full, we cannot insert the next element even if there is a space in front of queue. Efficiently implement a queue class using a circular...
Can you please help with the below? 1) Which of the following is true about using a 2-3-4 tree? a. It is designed to minimize node visits while keeping to an O(log n) search performance b. It is designed to self-balance as new values are inserted into the tree c. As soon as a node becomes full, it performs the split routine d. None of the above 2) Which of the following is true about a binary search tree? a. ...
In this assignment you will be implementing two Abstract Data Types (ADT) the Queue ADT and the Stack ADT. In addition, you will be using two different implementations for each ADT: Array Based Linked You will also be writing a driver to test your Queue and Stack implementations and you will be measuring the run times and memory use of each test case. You will also be adding some functionality to the TestTimes class that you created for Homework 1....
help me answer the following questions please 1. Stack (LIFO) & its application 1. Stack overflow & underflow 2. Implementation: partially filled array & linked list 3. Applications: reverse string, backtracking Exercises: 1) Which of the following applications may use a stack? A. parentheses balancing program. B. Keeping track of local variables at run time. C. Syntax analyzer for a compiler. D. All of the above. 2) Consider the usual algorithm for determining whether a sequence of parentheses is balanced....
Lab 3 – Array-Based Stack and Queue Overview In this assignment, you will be implementing your own Array-Based Stack (ABS) and Array-Based Queue (ABQ). A stack is a linear data structure which follows the Last-In, First-Out (LIFO) property. LIFO means that the data most recently added is the first data to be removed. (Imagine a stack of books, or a stack of papers on a desk—the first one to be removed is the last one placed on top.) A queue...
JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question 12 pts Which is a valid constructor for Thread? Thread ( Runnable r, int priority ); Thread ( Runnable r, String name ); Thread ( int priority ); Thread ( Runnable r, ThreadGroup g ); Flag this Question Question 22 pts What method in the Thread class is responsible for pausing a thread for a specific amount of milliseconds? pause(). sleep(). hang(). kill(). Flag...
How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...