Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to do the following: 1) Read in a file named imagelist.txt. I wi

ID: 3832503 • Letter: W

Question

Write a program to do the following: 1) Read in a file named imagelist.txt. I will put the file on blackboard with this assignment. The file contains four pieces of information per line. Each line corresponds to an OCT image of the lining of the bladder. The first item on each line is the diagnosis associated with the image, a string. The second item on each line is the number of layers recognized when analyzing the image, an integer. The third item on each line is the intensity of the brightest layer in the image, a float. The fourth item is the width of the brightest layer in the image, an integer. The maximum allowed length for the diagnosis is 9 characters. Do not assume that I will use the same file to test your code. That means, the number of lines may change, so you have to check the end of file to see when you have read in everything. A small portion of the file is shown below: 2) As you read in the data, store the data in a binary search tree based on the diagnosis. a. Should we have 4 trees right there? 3) Each entry in the tree should contain the diagnosis, the number of images with that diagnosis, and a linked list containing information about each image with that diagnosis. 4) Each item in the linked list should contain the number of layers, the intensity, the width, and a pointer to the next item in the list. 5) Once all of the data has been read in, for each diagnosis calculate the mean, standard deviation, and range of three things: the # of layers, the intensity, and the width. 6) Display the diagnosis information in alphabetical order. For each diagnosis displayed, display the number of images with that diagnosis followed by the values calculated in step 4. Non integers should be displayed with only 1 digit after the decimal point. An example output would be:

Explanation / Answer

Here I am explain the sample code file imagelist.txt for reading and how the data is written binatry tree by code
In C programming, file is a place on your physical disk where information is stored.
-Create a variable of type "FILE*".
-Open the file using the "fopen" function and assign the "file" to the data variable.
-Check to make sure the file was successfully opened by checking to see if the data == NULL. Otherwise error occurred.
- fprintf or fscanf functions to write/read from the file.
Here I am providing sample code for file operation for reading and writing

Normally file operations include

-Creating a new file
-Opening an existing file
-Closing a file
-Reading from and writing information to a file
     
-For reading and writing to a text file, the functions arefprintf() and fscanf().
-They are just the file versions of printf() and scanf(). The only difference is that, fprint and fscanf expects a pointer to the structure FILE.
#define MAX_LINE_SIZE 50


typedef struct binarySearchTree {
        int data;
    int bstNo;
    struct binarySearchTree * left;

   struct binarySearchTree * right;
}
binarySearchTree;

typedef struct rootList {
    struct binarySearchTree * node;
    struct rootList* next;
}rootList;

void insert_ binarySearchTree (binarySearchTree ** node, int insertValue, int bstNo);
BST* createTreeNode(int nodeValue, int bstNo);
void printTrees(rootList* listHead);
void free_BSTs(binarySearchTree* node);
void insert_rootList(rootList** listHead, binarySearchTree * node);

int main (int argc, char* argv[]){


        if (argc != 5){
                printf("false input");
                return 1;
        }


        FILE *input = fopen(argv[1], "r");
        while(input == NULL){
                char file[100];
                printf("cannot open file ");
                scanf("%d", file);
                input = fopen(file, "r");
        }


        int data;
        int bstNo;
        binarySearchTree *node;


   while (fscanf(input, "%d", &data) != EOF){
                while(value =! -1){
                bstNo = 1;
                root = createTreeNode(data, bstNo)

        return 0;
}


//integer value will be inserted
//It returns binarySearchTree pointer
//Then create a node


BST* createTreeNode(int nodeValue, int bstNo){
   
//The function malloc is used to find the size of binarySearchTree

binarySearchTree *new_binarySearchTree = (binarySearchTree*)malloc(sizeof(binarySearchTree));
        N_binarySearchTree->value = nodeValue;
        N_binarySearchTree->bstNo = bstNo;
        N_binarySearchTree->right = N_bst->left = 0;

        return N_binarySearchTree;

}

//it is used to insert values from file to binary search tree
//The parameters which here using is pointer of binarySearchTree and integer value
//its return type is void

//It is used to find the postion of binary search tree whre value from file need to be inserted.

void add_ binarySearchTree (binarySearchTree ** node, int add, int bstNo){
    if(node != 0){


                if(value < node->data)
                        node->right = add_ binarySearchTree(node->right, data);
                else if (value > root->data)
                        node->left = add_ binarySearchTree (node->left, data);
                return;
        }

}


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote