Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please be quick and do both parts right and readable solutions Bonus part is not necessarily can you just do it the A

Can you please be quick and do both parts right and readable solutions
image text in transcribed
Bonus part is not necessarily can you just do it the A and B
image text in transcribed
image text in transcribed
your tank regeirmente caffially. Cinand lierk" Pheselrainis arollian ipdateryecest Yocral n. Eepral a EsyNal on Untpeetfled read-rentare VacVat % Expial on txpila Jength+westori Yeciaj ilxpial. Ewap-wecteri WesVal a Explat x EepVat-7 tenseectfied erpy-weetate YereVah. of Heeval Thin Irabe se tad diwe vahe types if IDIU an: Vectal - iketiferyalian Denval = Irxpirat hewvect ot ileagth, valoel isnlahon a vieter of woe length milb sto valur valief. Index ler nup vadue. [C'moles a doju ady of elle tives tolit ] Erimmac: owther rimat Project Definition: In this project, you will implement common data structures such as vector and stack to EREF. Please, read cach part carefully, and pay attention to Asranptions and Constraints section. Part A. In this part, you will add vector to EREF. Introduce new operators newvector, updatevector, read-vector, length-vector, and swap-vector with the following definitions: (50 pts) newvector: ExpVal ExpVal VecVal update-vector: VecVal x ExpVal x ExpVal Unspecified read-vector: VecVal x ExpVal ExpVal length-vector: VecVal ExpVal swap-vector: VecVal x ExpVal x ExpVal Unspecified copy-vector: VecVal VecVal This leads us to define value types of EREE as: VeeVal =(Ref(ExpVaI)) ExpVal = Int + Bool + Proc + VecVal + Ref (ExpVal) DenVal = ExpVal Operatoss of vectors is defined as follows; newvector (length, value) initializes a vector of size length with the value value. update-vector (vec, index, value) updates the value of the vector vec at index index by value value. read-vectior (vec, Index) returns the element of the vector vec at index index. length-vector (vec) returns the length of the voctor vec. swap-vector (vec, index, index) swajr the values of the indexes in the vector vec. copy-vector (vec) initializes an new wector with the same values of the given wector vec(Creates a deep copy of the given vector.) Part B. In this part, you will implesneat a Stack using vectors that you impletneated in Part A. Stack is a linear type of data structure that follows the LIFO (Last-In-First-Out) principle and allows insertion and deletion operations from one end of the stack data structure, that is top. In other words, whenever pop is callexl, the element that is added latest is removed and returned from the stack. Yon will implement the following operatons of Stack with the given grammane: newstack (L) returns an empty stack with max-size L. push(s, val) adds the element val to the stark s. If the stack is full it throms a stark overflow error. pOp (s) removes the Last element of the stack s and returns its value. stack-size (s) returns the number of eleanents in the s. peek (s) returns the value of the last elenent in the stack s without removal. empty-stack? (s) returns true if there is no eleanent inside the stack s and false otherwise. print-stack (s) prints the elements in the stack s. Part C (bonus). In this part, you will implement multiplication function for vectors, in order to support interpreter level vector multiplication, which is more efficient: 2 vec-mult talos two vectors, calculates their pairwise maltiplication and outputs a new vetor. If the sizes of the vectors are not equal, it throws an error Expression:: = vec-mult (Expression, Expression) vec-mult-exp (vecl, vecl) Example: Figure 1. Syntax for wec-mult Expression Report. Your report should include the following: (1) Workload distribution of group members. (2) Parts that work properly, and that do not work properly. (3) Your approach to implementations: How does your stack work?, How did you implement vec-mult? ete. Include your report as PDF format in your sabunission folder. Assumptions and Constraints. Read the followitg assumptions and constraints carefully. You may not consider the edge cases related to the assumptions. (1) For stack, you nay assume print-stack will only be used for stacks of integers. (2) Stack does not have to be new defined data types, you can utilize the vector implenentation from Part A. (3) It is guaranterd that the correct type of paraneters will be passed to the operators. For example, in pop(s), s always be a stack. (4) If stack is empty, pop operation must retarn 1, (5) You CANNOT define global vatiables to keep trark of the size or top elenent of at stack. The renson is we may create multiple stacks and each of them may have different sizes and froat elements. (6) If you consider using list of references for vector and stack, find an efficient way to reach to an elerments, you are NOT allowed to iterate over list. (7) Please consider that we will test your code with some additional test casses, which will not be shared pablicly. Thus passing all tests does not guarantee full points, your tank regeirmente caffially. Cinand lierk" Pheselrainis arollian ipdateryecest Yocral n. Eepral a EsyNal on Untpeetfled read-rentare VacVat % Expial on txpila Jength+westori Yeciaj ilxpial. Ewap-wecteri WesVal a Explat x EepVat-7 tenseectfied erpy-weetate YereVah. of Heeval Thin Irabe se tad diwe vahe types if IDIU an: Vectal - iketiferyalian Denval = Irxpirat hewvect ot ileagth, valoel isnlahon a vieter of woe length milb sto valur valief. Index ler nup vadue. [C'moles a doju ady of elle tives tolit ] Erimmac: owther rimat Project Definition: In this project, you will implement common data structures such as vector and stack to EREF. Please, read cach part carefully, and pay attention to Asranptions and Constraints section. Part A. In this part, you will add vector to EREF. Introduce new operators newvector, updatevector, read-vector, length-vector, and swap-vector with the following definitions: (50 pts) newvector: ExpVal ExpVal VecVal update-vector: VecVal x ExpVal x ExpVal Unspecified read-vector: VecVal x ExpVal ExpVal length-vector: VecVal ExpVal swap-vector: VecVal x ExpVal x ExpVal Unspecified copy-vector: VecVal VecVal This leads us to define value types of EREE as: VeeVal =(Ref(ExpVaI)) ExpVal = Int + Bool + Proc + VecVal + Ref (ExpVal) DenVal = ExpVal Operatoss of vectors is defined as follows; newvector (length, value) initializes a vector of size length with the value value. update-vector (vec, index, value) updates the value of the vector vec at index index by value value. read-vectior (vec, Index) returns the element of the vector vec at index index. length-vector (vec) returns the length of the voctor vec. swap-vector (vec, index, index) swajr the values of the indexes in the vector vec. copy-vector (vec) initializes an new wector with the same values of the given wector vec(Creates a deep copy of the given vector.) Part B. In this part, you will implesneat a Stack using vectors that you impletneated in Part A. Stack is a linear type of data structure that follows the LIFO (Last-In-First-Out) principle and allows insertion and deletion operations from one end of the stack data structure, that is top. In other words, whenever pop is callexl, the element that is added latest is removed and returned from the stack. Yon will implement the following operatons of Stack with the given grammane: newstack (L) returns an empty stack with max-size L. push(s, val) adds the element val to the stark s. If the stack is full it throms a stark overflow error. pOp (s) removes the Last element of the stack s and returns its value. stack-size (s) returns the number of eleanents in the s. peek (s) returns the value of the last elenent in the stack s without removal. empty-stack? (s) returns true if there is no eleanent inside the stack s and false otherwise. print-stack (s) prints the elements in the stack s. Part C (bonus). In this part, you will implement multiplication function for vectors, in order to support interpreter level vector multiplication, which is more efficient: 2 vec-mult talos two vectors, calculates their pairwise maltiplication and outputs a new vetor. If the sizes of the vectors are not equal, it throws an error Expression:: = vec-mult (Expression, Expression) vec-mult-exp (vecl, vecl) Example: Figure 1. Syntax for wec-mult Expression Report. Your report should include the following: (1) Workload distribution of group members. (2) Parts that work properly, and that do not work properly. (3) Your approach to implementations: How does your stack work?, How did you implement vec-mult? ete. Include your report as PDF format in your sabunission folder. Assumptions and Constraints. Read the followitg assumptions and constraints carefully. You may not consider the edge cases related to the assumptions. (1) For stack, you nay assume print-stack will only be used for stacks of integers. (2) Stack does not have to be new defined data types, you can utilize the vector implenentation from Part A. (3) It is guaranterd that the correct type of paraneters will be passed to the operators. For example, in pop(s), s always be a stack. (4) If stack is empty, pop operation must retarn 1, (5) You CANNOT define global vatiables to keep trark of the size or top elenent of at stack. The renson is we may create multiple stacks and each of them may have different sizes and froat elements. (6) If you consider using list of references for vector and stack, find an efficient way to reach to an elerments, you are NOT allowed to iterate over list. (7) Please consider that we will test your code with some additional test casses, which will not be shared pablicly. Thus passing all tests does not guarantee full points

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

8. Demonstrate aspects of assessing group performance

Answered: 1 week ago