Exam1C_Solutions

.pdf

School

Pennsylvania State University *

*We aren’t endorsed by this school

Course

465

Subject

Computer Science

Date

Dec 6, 2023

Type

pdf

Pages

11

Uploaded by MinisterBadgerMaster464

Report
Pennsylvania State University — CMPSC465 : Data Structures & Algorithms Exam 1 Lecturers: Antonio Blanca and Yana Safonova September 22, 2023 Exam 1 - C Name: Penn State access ID (xyz1234) in the following box: Student ID number (9XXXXXXXX): TA and/or section time: Instructions: Answer all questions. Read them carefully first. Be precise and concise. Handwriting needs to be neat. Box numerical final answers. Please clearly write your name and your PSU access ID (i.e., xyz1234) in the box on top of every page . Write in only the space provided. You may use the back of the pages only as scratch paper. Do not write your solutions in the back of pages! Do not write outside of the black bounding box : the scanner will not be able to read anything outside of this box. We are providing two extra page at the end if you need extra space. Make sure you mention in the space provided that your answer continues there. Good luck! 1
Name: PSU Access ID (xyz1234): Multiple choice questions (27 points) For each of the following questions, select the right answer by filling the corresponding grading bubble grading bubbles. 1. Run Build-Heap on the array [3 , 5 , 4 , 8 , 6 , 2 , 10 , 1 , 8 , 11] to construct a min heap. Select the resulting min heap. 1 2 6 11 8 5 8 3 10 4 (d) 1 3 5 8 8 6 11 2 4 10 (e) 1 3 5 4 10 6 11 2 8 8 (f) 2 3 5 8 10 8 6 4 1 11 (a) 3 5 8 8 6 11 2 4 10 1 (b) 1 2 6 8 10 5 11 3 4 8 (c) Answer. (a) (b) (c) (d) '! (e) (f) 2
Name: PSU Access ID: 2. Consider the min heap below. Suppose the number 2 is inserted into the heap. 4 5 7 8 6 Which one of the following is the resulting min heap? 4 5 7 8 6 2 (a) 2 5 7 8 4 6 (b) 2 4 6 7 5 8 (c) 2 5 6 8 4 5 (d) 4 5 7 8 2 6 (e) Answer. (a) '! (b) (c) (d) 3
Name: PSU Access ID: 3. Consider the min heap on the left below. Suppose that first the element at position 3 of the array is removed from the heap (remember that we use 0 indexed arrays), and after that the element at position 1 is removed from the heap. 3 6 7 10 12 8 14 12 5 9 13 10 7 Which one of the following is the resulting min heap? 3 8 10 12 12 14 5 9 13 10 7 (a) 3 13 10 10 12 8 14 12 5 9 7 (b) 3 8 10 10 12 12 14 13 5 9 7 (c) 3 8 10 13 12 10 14 12 5 9 7 (d) Answer. (a) (b) '! (c) (d) (e) 4
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help