CS300 Sample Final Quest Ons PDF
CS300 Sample Final Quest Ons PDF
Given an array of integers, find the length of the longest subsequence such that elements in
the subsequence are consecutive integers, the consecutive numbers can be in any order.
Examples:
3)
a) Show the result of inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, and 2, one at a
time, into an initially empty binary heap.
b) Show the result of using the linear-time algorithm to build a binary heap using the
same input.
c) Show the result of performing three deleteMin operations in the heap of the
previous exercise.
This study source was downloaded by 100000770618860 from CourseHero.com on 01-08-2023 14:02:06 GMT -06:00
https://www.coursehero.com/file/175543102/CS300-SAMPLE-FINAL-QUEST%C4%B0ONSpdf/
4) Prove that for binary heaps, buildHeap does at most 2N−2 comparisons between
elements.
7) Show how heapsort processes the input 142, 543, 123, 65, 453, 879, 572, 434,111, 242,
811, 102.
10) Construct a permutation of 20 elements that is as bad as possible for quicksort using
median-of-three partitioning and a cutoff of 3.
This study source was downloaded by 100000770618860 from CourseHero.com on 01-08-2023 14:02:06 GMT -06:00
https://www.coursehero.com/file/175543102/CS300-SAMPLE-FINAL-QUEST%C4%B0ONSpdf/
11) Find a topological ordering for the graph below:
a. Use a queue and assume that vertices appear on an adjacency list alphabetically.
b. Use a stack and assume that vertices appear on an adjacency list alphabetically.
12) Find the shortest path from A to all other vertices for the graph below, show your
steps:
This study source was downloaded by 100000770618860 from CourseHero.com on 01-08-2023 14:02:06 GMT -06:00
https://www.coursehero.com/file/175543102/CS300-SAMPLE-FINAL-QUEST%C4%B0ONSpdf/
13) Find a minimum spanning tree for the graph below using Prim’s algorithm.
Is this minimum spanning tree unique? Why?
This study source was downloaded by 100000770618860 from CourseHero.com on 01-08-2023 14:02:06 GMT -06:00
https://www.coursehero.com/file/175543102/CS300-SAMPLE-FINAL-QUEST%C4%B0ONSpdf/
Powered by TCPDF (www.tcpdf.org)