Question: This assignment aims to help you practice binary search tree ADT, in particular AVL Tree. You will write a program that can be used to

This assignment aims to help you practice binary search tree ADT, in particular AVL Tree. You will
write a program that can be used to analyze the collected fish data. You will use this application
to index the fish.
Requirements:
In this assignment, you are given a list of fishes in an external text file called fishes.txt. In this text
file, you can find several fishes.
This file includes the following information:
Name: the name of the fish
Weight: weight of the fish in grams
Length: length of the fish in cm
Date: the fishing date
City: the fishing city
And sample data is as follows where each part is separated by a "," character:
Name,Weight,Date,City
Beam,242,23.2,02/02/2022,city1
Whitefish,270,23.6,22/02/2022,city2
Roach,40,12.9,15/09/2022,city3
Parkki,300,26.0,15/09/2022,city4
Whitefish,270,24.1,15/09/2022;city3
Parkki,300,26.5,18/09/2022,city5
Your task here is to process this file and generate an AVL tree based on the weight. If there is
more than one fish with the same weight, they should then be stored together in the same node
as shown below.
MIDDLE EAST TECHNICAL UNIVERSITY, NORTHERN CYPRUS CAMPUS
CNG213 Data Structures Programming Assignment 3
Page 2 of 4
Based on this data representation, you need to write a program that provides the following
functionalities to the user:
1. Display the full index: This will display the full AVL tree constructed. For traversal, you need
to display the fishes sorted in ascending order based on their weight.
2. The fish with the maximum weight: This will display the details (Name, Weight, Length,
Date, City) of the fish(es) that has the maximum weight.
3. The fish with the maximum length: This will display the details (Name, Weight, Length,
Date, City) of the fish(es) that has the maximum lenght.
Programming Requirements:
You will start by taking the file name as a command line argument and then you will need to
implement at least the following functions:
readData(): This function will mainly process the external file. As an input, it will take the file
name and it will return an AVL tree.
insertFish(): This function will take an AVL tree and the details of the fish, and then it will
insert the fish into the AVL tree. The fish will be interested in the tree based on its weight. You
cannot make assumptions about the number of fish that have the same weight. Therefore, if
the node with the given weight exists then you will add your fish details to that node.
displayIndex(): This function will mainly take an AVL tree and display the data in the tree in
ascending order according to the weight of the fish.
heaviestFish(): This function will mainly take an AVL tree, and will find and display the
details of the fishes which has the maximum weight. In the comment part of this function,
discuss the complexity of this function based on your current representation of data. You also
need to discuss if there is a way you could improve this.
longestFish(): This function will mainly take an AVL tree and will find and display the fish
which has the maximum length. In the comment part of this function, discuss the complexity of
this function based on your current representation of data. You also need to discuss if there is a
way you could improve this.
Please note that in this assignment, you can make use of the functions in the string.h library and
similar external libraries. You cannot assume about the number of fish in this external file.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!