# Develop a CPP program to test if an array conforms heap ordered binary tree.

**INSTRUCTIONS TO CANDIDATES**
###### ANSWER ALL QUESTIONS

Instructions

Develop a CPP program to test if an array conforms heap ordered binary tree. The program reads data from a_txt_file.txt, which is given as command prompt parameter. The program evaluates each line and display True if the array is heap ordered, False if not. The *.txt file has one array per line, which has at most with 20 items. Data consists of positive integer numbers between 0 and 100 and separated with a single space. The source file can include up to 200 lines.

For example, an input.txt file may include

33 65 55 64 37 25 33 34 -> True since all parent nodes conform A[k] >= A[2k] and A[k]>=A[2k+1] rules, for k > 0. Note that A[0] (33) is not part of the heap three therefore parent-child calculation starts with k=1. A[1] > A[2], A[1] > A[3]; A[2] > A[4], A[2] > A[5]; A[3] > A[6], A[3] > A[7], so on so

forth.

45 5 5 34 -> False since at least one parent does not conform A[k] >= A[2k] and A[k]>=A[2k+1] rules, for k > 0. The validation of A[1] >= A[3] for k=1 fails, since 5 < 34.

37 65 55 64 37 25 33 34 87 0 48 95 -> False since at least one parent does not conform A[k] >= A[2k] and A[k]>=A[2k+1] rules, for k > 0. The validation of A[4] >= A[8] for k=4 fails, since 37 < 87.

So, the output for the input.txt file,

>myProg.exe input.txt True

False False

You can use any code shared on D2L.

Do not include unnecessary headers and functions. Code syntax will be graded.

##### Attachments:

## Expert's Answer

319 Times Downloaded
## Related Questions

##### . Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

##### . The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

##### . Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

##### . SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1
Project 1
Introduction - the SeaPort Project series
For this set of projects for the course, we wish to simulate some of the aspects of a number of

##### . Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1
Project 2
Introduction - the SeaPort Project series
For this set of projects for the course, we wish to simulate some of the aspects of a number of