Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. We saw that Queues and Stacks are quite similar. One may ask a natural question , how similar they are; c an you buil

1.

We saw that

Queues

and Stacks

are quite similar.

One may ask a

natural

question

, how similar they are;

c

an you buil

d one of them from the other

?

It turns

out that, they can not be conver

ted to each other trivially.

In fact,

[1] shows that

(

i

) Simulating one stack by one queue requires

O

(n

4/3

log n)

time

and in the

opposite direction

(

ii

) Simulating one queue by one stack requires

O(n

2

) time.

Howev

er, following questions are attackable.

(a)

I

mplement a queue from two stacks and O(1) extra storage.

(b)

I

mplement a stack from two queues and O(1) extra storage.

2

.

Priority Queues

:

(a) Build a priority queue using arrays.

(b) Build a priority queue using linked lists.

3

.

Binary heap

:

(a)

Bui

ld a

binary heap

using arrays (i.e. implement max and insert functions

which need heap

-

up and heap down operations)

.

(b) Build a binary heap using trees

.

(c) Design and implement an algorithm that has O(log

n

)

complexity for all max,

min and insert functions.

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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

Students also viewed these Databases questions

Question

=+2.23. 1 Extend (2.29) to ordinals & Answered: 1 week ago

Answered: 1 week ago

Question

What is a verb?

Answered: 1 week ago

Question

What were your most important educational experiences?

Answered: 1 week ago

Question

Which personal relationships influenced you the most?

Answered: 1 week ago