Lab3 - CS 284 Algorithms Summer semester 2010 Lab 3 Lab...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 284 Algorithms Summer semester 2010 Lab 3 Lab objectives: - Understand the heap properties. - Implements Heap sort using different techniques. Related chapter(s): 6. Lab instructions (steps): 1. Write the following program and run it. #include <time.h> #include <iostream> #include <stdio.h> void printA( int A[], int n); void checkHeap( int A[], int n); void Heapify( int A[], int n, int i); void BuildHeap( int A[], int n); void BuildHeapNEW( int A[], int n); void BuildHeapNEW2( int A[], int n); void HeapSort( int A[], int n); void HeapSortNEW( int A[], int n); void HeapSortNEW2( int A[], int n); int HeapSize=0; using namespace std; int main() { clock_t start1, finish1; int maxK=1; int initialN=10; int MaxRep=1; int n; // input size if (initialN>=20) cout << "Average Time Taken by Heap Sort : " <<endl; if (initialN>=20) cout << "n\ttime" <<endl; if (initialN>=20) cout << "-------------" <<endl; for ( int k=1, n=initialN; k<=maxK; k++, n*=2){ float TotalTime1=0; // Heap sort time for ( int
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/15/2011 for the course CS 284 taught by Professor Jamess. during the Spring '10 term at Jordan University of Science & Tech.

Page1 / 2

Lab3 - CS 284 Algorithms Summer semester 2010 Lab 3 Lab...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online