haskell 1. 2pts) Implement a data type called Student. The student type has four
ID: 3715658 • Letter: H
Question
haskell
1. 2pts) Implement a data type called Student.
The student type has four fields, first name, last name, major, and age.
2. 2 pts) Implement a tree node type that has a student as one of its fields. The tree will be a binary search tree on the attribute age.
3. 1 pt) Write a comma separated file in which each line (ended by new line character) contains a student, with its fields separated by commas
4. Write a program that will:
a. 5pts) Read the comma separated file (specified by a command line argument) and produce a list of students.
b. 5pts) Construct a binary search tree using the tree nodes you created, according to the ages of students.
c. 3pts) Write a function that will search through the tree to see if it contains a student of age x. It returns true if there is, otherwise it
returns false.
d. 4pts) Write a function that takes a string for last name uses depth-first
search to find if a student with that name is in the tree.
what i have so far
import Data Maybe import Data. List import qualified Data Map hiding (map) i do data Student Student (firstName String, lastName String, ageInt) deriving (Show) main do data Tree Student EmptyTree Node Studentage Tree Studentage) Tree Studentage) deriving (show) singleton Studentage Tree Studentage singleton agex :: Node age_ EmptyTree EmptyTree Tree Studentage Tree Studentage tre e Insert age x EmptyTree = singleton age-x treeInsert age-x (Node Student age = left right) Iage_xStudentage Node age x left right lage-x Studentage-Node Studentage left (treeinsert age-x right)Explanation / Answer
1)
Note :
Data type Student with four fields can be declared as follows:
data Person = Person { firstName :: String
, lastName :: String
, major :: String
, age :: Int
} deriving (Show)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.