THE PROGRAM: This project is the first in a two-phase project. This project shou
ID: 3602741 • Letter: T
Question
THE PROGRAM: This project is the first in a two-phase project.
This project should process (at least) the following record types: integer-valued keys string-valued keys ordered pairs of string-valued and integer-valued keys You should provide a comparison method for each record type. When we sort our records we will first perform replacement selection then merge. The number of entries in the k-way tournament sort (k) will be the number of sorted runs. Write the following statistics to a log file: an identification of which file the (input) unsorted records are from, an identification of which file the (output) sorted records are placed in, the number of records that can fit in memory, the number of records, the number of runs, the smallest, largest and arithmetic mean number or records in all of the runs, A sorted file of records will be generated for each of our categories of record. Write a program that demonstrates that your file sorter works for a sufficiently large count of records in memory Your team will implement:
Component A.1
Implement in C++ a back-to-back, dual heap, replacement selection algorithm. Initialize: a vector to serve as the replacement selection container. Once the vector size (defaulting to 8 fixed-size records) has been set, the vector size will be fixed at that value for its lifetime. The vector's type should be templated. Files: a file to receive a sequence of sorted lists. a file to receive the byte offsets (or RRNs) of the sequence of sorted lists. a heap direction flag. If TRUE, the active heap's head is on the left end, and the pending heap's head is on the right end. Else if FALSE, the active heap's head is on the right end, and the pending heap's head is on the left end. The default value is TRUE While the replacement selection vector is not full: heapify a new element (if there is one) While there's a new element: Pop the root of the current heap, adding it to the current sorted list. If the new element is (for a min-heap) greater than or equal to the last element popped, push it onto the current heap If the new element is (for a min-heap) less than the last element popped, push it onto the pending heap decrement the current heap size counter, and increment the pending heap size counter. If the current heap size is zero, terminate the current sorted list initialize a new sorted list toggle the heap direction flag you will have current_heap_push(), current_heap_pop(), and pending_heap_push() methods, as they'll operate differently. When the input is exhausted, pop the remaining elements of the active heap into the current list and then then (if not empty) pop the remaining elements of the pending heap into the final list. Finishing (consistency checks): Verify that the count of records in the entry-sequenced file is equivalent to the count of records in the set of sorted lists file. Verify that each sorted list is monotonically ordered.
Component A.2
Create a sorted file of records via k-way tournament, heap-mediated, merging of replacement selection sorted lists. Component A lays the foundation for the next team component which implements a B+Tree.
Explanation / Answer
#include<stdio.h>
int main()
{
int i,MAX;
int a[5];
for(i=0;i<5;i++)
{
scanf("%d",a[i]);/* input 5 numbers */
}
MAX=a[0];/*initialize the first number as maximum value*/
for(i=0;i<5;i++)
{
if(a[i]>MAX)
{
MAX=a[i];
}
}
printf("the maximum of 5 numbers is%d",MAX);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.