Solution2.pdf - CSCE-629 Analysis of Algorithms Spring 2019...

This preview shows page 1 - 3 out of 4 pages.

CSCE-629 Analysis of Algorithms Spring 2019 Instructor: Dr. Jianer Chen Teaching Assistant: Qin Huang Office: HRBB 315C Office: HRBB 315A Phone: 845-4259 Phone: 402-6216 Email: [email protected] Email: [email protected] Office Hours: T,Th 11:00 am–12:30 pm Office Hours: MWF 3:00 pm–4:00 pm Solutions to Assignment #2 (Prepared with TA Qin Huang) 1. Design algorithms for Min( H ), Insert( H, a ), and Delete( H, i ), where the set H is stored in a heap, a is the element to be inserted into the heap H , and i is the index of the element in the heap H to be deleted. Analyze the complexity of your algorithms.
1
Algorithm 3 Delete( A [1 . . . max] , n ; i ) 1: A [ i ] = A [ n ]; n = n - 1; 2: if i 2 and A [ i ] < A [ b

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture