Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please do both A and B parts quick and right solutions Important Notice: If your submitted code is not working properly, i.e. throws

Can you please do both A and B parts quick and right solutions image text in transcribed
image text in transcribed
image text in transcribed
Important Notice: If your submitted code is not working properly, i.e. throws error or fails in all test cases, your submission will be graded as 0 directly. Please comment out parts that cause to throw error and indicate both which parts work and which parts do not work in your report explicitly. Testing: You are provided some test cases under tests. scm. Please, check them to understand how your implementation should work. You can run all tests by running top.scm. We will test your program with additional cases but your submission should pass all provided test cases. 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? etc. Include your report as PDF format in your submission folder. Assumptions and Constraints. Read the following assumptions and constraints carefully. You may not consider the edge cases related to the assumptions. (1) For stack, you may 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 implementation from Part A. (3) It is guaranteed that the correct type of parameters will be passed to the operators. For example, in pop(s), s always be a stack. (4) If stack is empty, pop operation must return 1. (5) You CANNOT define global variables to keep track of the size or top element of a stack. The reason is we may create multiple stacks and each of them may have different sizes and front elements. (6) If you consider using list of references for vector and stack, find an efficient way to reach to an elements, you are NOT allowed to iterate over list. (7) Please consider that we will test your code with some additional test cases, which will not be shared publicly. Thus passing all tests does not guarantee full points. Project Definition: In this project, you will implement common data structures such as vector and stack to EREF. Please, read each part carefully, and pay attention to Assumptions and Construints 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 x ExpVal VecVal update-vector: VecVal x ExpVal x ExpVal Unspecified read-vector: VecVal ExpVal ExpVal length-vector: VecVal ExpVal swap-vector: VecVal ExpVal ExpVal Unspecified copy-vector: Vecval Vecval This leads us to define value types of EREF as: VecVal =(Ref(ExpVal)) ExpVal = Int + Bool + Proc + VecVal + Ref ( ExpVal ) DenVal = ExpVal Operators 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-vector (vec, index) returns the element of the vector vec at index index. length-vector (vec) returns the length of the vector vec. swap-vector (vec, index, index) swaps the values of the indexes in the vector vec. copy-vector (vec) initializes an new vector with the same values of the given vector vec. (Creates a deep copy of the given vector.) Part B. In this part, you will implement a Stack using vectors that you implemented 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 called, the element that is added latest is removed and returned from the stack. You will implement the following operators of Stack with the given grammar: newstack.(L) returns an empty stack with max-size L. push (s, val) adds the element val to the stack s. If the stack is full it throws a stack overflow error. pop (s) removes the last element of the stack s and returns its value. stack-size (s) returns the number of elements in the s. peek (s) returns the value of the last element in the stack s without removal. empty-stack? (s) returns true if there is no element inside the stack s and false otherwise. print-stack (s) prints the elements in the stack s. Important Notice: If your submitted code is not working properly, i.e. throws error or fails in all test cases, your submission will be graded as 0 directly. Please comment out parts that cause to throw error and indicate both which parts work and which parts do not work in your report explicitly. Testing: You are provided some test cases under tests. scm. Please, check them to understand how your implementation should work. You can run all tests by running top.scm. We will test your program with additional cases but your submission should pass all provided test cases. 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? etc. Include your report as PDF format in your submission folder. Assumptions and Constraints. Read the following assumptions and constraints carefully. You may not consider the edge cases related to the assumptions. (1) For stack, you may 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 implementation from Part A. (3) It is guaranteed that the correct type of parameters will be passed to the operators. For example, in pop(s), s always be a stack. (4) If stack is empty, pop operation must return 1. (5) You CANNOT define global variables to keep track of the size or top element of a stack. The reason is we may create multiple stacks and each of them may have different sizes and front elements. (6) If you consider using list of references for vector and stack, find an efficient way to reach to an elements, you are NOT allowed to iterate over list. (7) Please consider that we will test your code with some additional test cases, which will not be shared publicly. Thus passing all tests does not guarantee full points. Project Definition: In this project, you will implement common data structures such as vector and stack to EREF. Please, read each part carefully, and pay attention to Assumptions and Construints 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 x ExpVal VecVal update-vector: VecVal x ExpVal x ExpVal Unspecified read-vector: VecVal ExpVal ExpVal length-vector: VecVal ExpVal swap-vector: VecVal ExpVal ExpVal Unspecified copy-vector: Vecval Vecval This leads us to define value types of EREF as: VecVal =(Ref(ExpVal)) ExpVal = Int + Bool + Proc + VecVal + Ref ( ExpVal ) DenVal = ExpVal Operators 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-vector (vec, index) returns the element of the vector vec at index index. length-vector (vec) returns the length of the vector vec. swap-vector (vec, index, index) swaps the values of the indexes in the vector vec. copy-vector (vec) initializes an new vector with the same values of the given vector vec. (Creates a deep copy of the given vector.) Part B. In this part, you will implement a Stack using vectors that you implemented 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 called, the element that is added latest is removed and returned from the stack. You will implement the following operators of Stack with the given grammar: newstack.(L) returns an empty stack with max-size L. push (s, val) adds the element val to the stack s. If the stack is full it throws a stack overflow error. pop (s) removes the last element of the stack s and returns its value. stack-size (s) returns the number of elements in the s. peek (s) returns the value of the last element in the stack s without removal. empty-stack? (s) returns true if there is no element inside the stack s and false otherwise. print-stack (s) prints the elements in the stack s

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

Recommended Textbook for

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

1. Identify three approaches to culture.

Answered: 1 week ago

Question

2. Define communication.

Answered: 1 week ago