Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a. Let A[1..n] and B[1..m] be two arrays, where n ? m ? 1. Use pseudocode to write an algorithm which prints TRUE if the

a. Let A[1..n] and B[1..m] be two arrays, where n ? m ? 1. Use pseudocode to write an algorithm which prints TRUE if the array A contains the sequence B, and FALSE otherwise. The elements from B must appear in order, but they do not have to occur as a contiguous sequence in A. The running time of the algorithm must be O(n).

Here are some examples:

- if A = <10, 3, 21, 5, 6, 14, 17, 9, 5, 6, 8, 11, 12> and B = <5, 6, 8> then the algorithm prints TRUE.

- if A = <10, 3, 21, 5, 6, 14, 17, 9, 5, 6, 8, 11, 12> and B = <3, 14, 11, 12>, then the algorithm prints TRUE

- if A = <10, 3, 21, 5, 6, 14, 17, 9, 5, 6, 8, 11, 12> and B = < 6, 5, 14>, then the algorithm prints FALSE

b. Consider the array A = <18, 10, 14, 3, 5, 7, 15, 12, 25, 80>.

1) (5 points) write A after calling the function BUILD-MAX-HEAP(A)

2) (5 points) write A after calling the function HEAP-INCREASE-KEY(A,9,50).

3) (5 points) write A after calling the function HEAP-EXTRACT-MAX(A)

Part 2) uses the array A resulted from part 1). Part 3) uses the array A resulted from part 2).

* Note that HEAP-INCREASE-KEY and HEAP-EXTRACT-MAX operationsare implemented in the Priority Queue.

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

Step: 3

blur-text-image

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

Creating A Database In Filemaker Pro Visual QuickProject Guide

Authors: Steven A. Schwartz

1st Edition

0321321219, 978-0321321213

More Books

Students also viewed these Databases questions

Question

5. Do you have any foreign language proficiency?

Answered: 1 week ago