CSE
Lecture 7.pptx

Lecture 7.pptx - Lecture 7 Handling a Case Statement...

• Notes
• 26

This preview shows pages 1–11. Sign up to view the full content.

Lecture 7

This preview has intentionally blurred sections. Sign up to view the full version.

Handling a Case Statement condition1 true false condition2 true false Condition 3 true false condition2 true false
First Function in Problem 3 MaxHeapify(A, i) l = left(i) r = right(i) if l <= heapsize and A[l] > A[i] then largest = l else largest = i if r <= heapsize and A[r] > A[largest] then largest = r if largest != i then swap A[i] with A[largest] MaxHeapify(A, largest) end func l a r g l e s t = l qq sta rts start l r end cond1 cond2 cond3 Largest=l Largest=i Largest=r swap MaxHeapify

This preview has intentionally blurred sections. Sign up to view the full version.

Second Function in Problem 3 BuildMaxHeap(A) Heapsize = length[A] for i = |length[A]/2| downto 1 do MaxHeapify(A, i) end func start heap= i= i>=1? Max…. i=i-1 End
Third Function in Problem 3 HeapSort(A) BuildMaxHeap(A) for i = length[A] downto 2 do swap A[1] with A[i] heapsize = heapsize – 1 MaxHeapify(A, 1) start BuildM i= i>=2? End Swap heap…. i=i-1 Max

This preview has intentionally blurred sections. Sign up to view the full version.

Modeling Binary Search Operation index Meaning 1 Low = 1 2 High = n 3 Loc = 0 4 Middle = (low+high) DIV 2 5 X = table[middle]? 6 Loc= middle 7 Table[middle] > x ? 8 High = middle -1 9 Low = middle + 1 10 Low > high?
Data Flow Graph for the Binary Search

This preview has intentionally blurred sections. Sign up to view the full version.

Control Flow Graph Start e 1 e 8 e 7 e 3 e 9 e 0 e 10 e 6 e 2 e 4 e 5 e 1 e 8 e 10 e 2 e 3 e 4 e 5
With these, the flow balance equations are developed. Flow Balance Equations e0 e6 e7 e9 Equation e1= e0 e1=1 e2= e0 +e9 e2=1+e9 e3= +e6 +e9 e3=e6+e9 e4= e0 -e6 e4=1-e6 e5= +e9 e5=e9 e8= -e7 +e9 e8=e9-e7 e10= e0 e10=1

This preview has intentionally blurred sections. Sign up to view the full version.

Examination of the equation reveals there is a constant term, corresponding to initialization, it is a fixed time, and there are also data dependencies.
This is the end of the preview. Sign up to access the rest of the document.
• Spring '14
• Ammar,R

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern