There are two parts to lab lesson 8. The entire lab will be worth 100 points.

Part of lab lesson 8

There are two parts to lab lesson 8. The entire lab will be worth 100 points.

Lab lesson 8 part 2 is worth 50 points

For part 2 you will have 40 points if you enter the program and successfully run the program tests. An additional 10 points will be based on the style and formatting of your C++ code.

Style points

The 10 points for coding style will be based on the following guidelines:

  • Comments at the start of your programming with a brief description of the purpose of the program.
  • Comments throughout your program
  • Proper formatting of your code (follow the guidelines in the Gaddis text book, or those used by your CS 1336 professor)
  • If you have any variables they must have meaningful names.

Development in your IDE

For lab lesson 8 (both parts) you will be developing your solutions using an Integrated Development Environment (IDE) such as Visual Studio, Code::Blocks or Eclipse. You should use whatever IDE you are using for your CS 1336 class. Once you have created and tested your solutions you will be uploading the files to zyBooks/zyLabs. Your uploaded file must match the name specified in the directions for the lab lesson. You will be using an IDE and uploading the appropriate files for this and all future lab lessons.

For this and all future labs the name of the source files must be:

lessonXpartY.cpp

Where X is the lab lesson number (8 for lab lesson 8) and Y is the part number (1 for part 1, 2 for part 2).

You will need to develop and test the program in your IDE. Once you are satisfied that it is correct you will need to upload the source file to zyBooks/zyLabs, and submit it for the Submit mode tests. If your program does not pass all of the tests you need to go back to the IDE, and update your program to fix the problems you have with the tests. You must then upload the program from the IDE to zyBooks/zylabs again. You can then run the tests again in Submit mode.

When running your program in Submit mode it is very important that you look at the output from all of the tests. You should then try and fix all of the problems in your IDE and then upload the updated code to zyBooks/zyLabs.

C++ requirements

You are not allowed to use any global variables. Use of global variables will result in a grade of zero for part 1.

Your program must have function main, function presentValue, three read functions, and a display function. Including main this is six functions.

The presentValue function must have the following signature:

double presentValue(double futureValue, double interestRate, int numberYears)

The presentValue needs to calculate the present value and return that back to the calling function. The formula for this is above. Note that the annual interest would be .08 for 8%.

Failure to follow the C++ requirements could reduce the points received from passing the tests.

General overview

In part 2 you will be creating multiple functions to calculate the present value.

You may be asking what a “present value” is. Suppose you want to deposit a certain amount of money into a savings account and then leave it alone to draw interest for some amount of time, say 12 years. At the end of the 12 years you want to have $15,000 in the account. The present value is the amount of money you would have to deposit today to have $15,000 in 12 years.

The formula used needs the future value (F) and annual interest rate (r) and the number of years (n) the money will sit in the account, unchanged. You will be calculating the present value (P).

P = F / ( (1 + r) ^ n)

In the above expression the value (1 + r) needs to be raised to the nth power. Assume that ^ is the power function and x^2 is x to the 2nd power (x squared)

You are not allowed to use any global variables. Use of global variables will result in a grade of zero for part 2.

Three read functions

You must have functions to read in the future value, the annual interest rate, and the number of years. That would be three different functions. Give these functions meaningful names. Note that the order of the values will be future value, annual interest rate, and number of years.

In all cases you need to return any valid value back to the calling function.

For all three functions you will write out to cout as prompt for an input value. You will read in that value from cin. If the value is invalid (zero or negative) you need to display an error message and reread the value (with another prompt). You need to do this in a loop and continue looping until a valid value has been entered. Only the number of years can be an int value. The rest should be of type double.

Here are the prompts for the three values you need to read in:

Enter future value
Enter annual interest rate
Enter number of years

Note that the interest rate will be a number such as 10 or 12.5. These are to be read in as percentages (10% and 12.5%). You will need to divide these values by 100 to convert them into the values needed in the function (.1 and .125 for the above values). This conversion needs to be done before you call the presentValue function (see below). If you do the conversion in the presentValue function your program will fail the unit tests, so do the conversion before you call the calculate function.

Here are the error messages you need to display if the values are negative:

The future value must be greater than zero
The annual interest rate must be greater than zero
The number of years must be greater than zero

You will also need a function called presentValue with the following signature:

double presentValue(double futureValue, double interestRate, int numberYears)

The presentValue needs to calculate the present value and return that back to the calling function. The formula for this is above. Note that the annual interest would be .08 for 8%.

Note that the interest rate will be a number such as 10 or 12.5. These are to be read in as percentages (10% and 12.5%). You will need to divide these values by 100 to convert them into the values needed in the function (.1 and .125 for the above values). This conversion needs to be done before you call the presentValue function (see below). If you do the conversion in the presentValue function your program will fail the unit tests, so do the conversion before you call the calculate function.

The display function

You also need a function that displays the present value, future value, interest rate, and number of years. The function needs to display the interest rate as %, so .05 would display as 5.000%. Give your display function a meaningful name. You will be passing a number of values to this function.

Here is the sample output for a present value of $69,046.56, a future value of $100,000, an interest rate of 2.5% and a number of years of 15,

Present value: $69046.56
Future value: $100000.00
Annual interest rate: 2.500%
Years: 15

Note that the present value and future value have three digits of precision to the right of the decimal point but the interest rate only has one digit to the right of the decimal point.

The main function will be the driver for your program.

Your program will only be processing one set of valid values for future value, annual interest rate and number of years.

Get the values for these by calling the read functions you created above.

Once you have the values you need to call your presentValue. Using the result from the presentValue and the input values you read in with your read functions you need to call your display function (written above) to display the values.

The main function

The main function will be the driver for your program. All of the non-main functions are called from main.

For the following sample run assume the input is as follows:

1000000.0
5.0
25

Your program should output the following:

Enter future value
Enter annual interest rate
Enter number of years
Present value: $295302.77
Future value: $1000000.00
Annual interest rate: 5.000%
Years: 25

Here is an example with some invalid data

Input values:

-100
0
1000000.0
5.0
25

Output:

Enter future value
The future value must be greater than zero
Enter future value
The future value must be greater than zero
Enter future value
Enter annual interest rate
Enter number of years
Present value: $295302.77
Future value: $1000000.00
Annual interest rate: 5.000%
Years: 25

Failure to follow the requirements for lab lessons can result in deductions to your points, even if you pass the validation tests. Logic errors, where you are not actually implementing the correct behavior, can result in reductions even if the test cases happen to return valid answers. This will be true for this and all future lab lessons.

Expected output

There are eight tests. The first test will run your program with input and check your output to make sure it matches what is expected. The next three tests are unit tests. The unit tests will directly call the presentValue function. The compilation of the unit test could fail if your presentValue function does not have the required signature. The final four tests will run your program with various input values and make sure you are calculating the correct answers.

You will get yellow highlighted text when you run the tests if your output is not what is expected. This can be because you are not getting the correct result. It could also be because your formatting does not match what is required. The checking that zyBooks does is very exacting and you must match it exactly. More information about what the yellow highlighting means can be found in course “How to use zyBooks” – especially section “1.4 zyLab basics”.

Finally, do not include a system("pause"); statement in your program. This will cause your verification steps to fail.

Note: that the system("pause"); command runs the pause command on the computer where the program is running. The pause command is a Windows command. Your program will be run on a server in the cloud. The cloud server may be running a different operating system (such as Linux).

Error message “Could not find main function”

Now that we are using functions some of the tests are unit tests. In the unit tests the zyBooks environment will call one or more of your functions directly.

To do this it has to find your main function.

Right now zyBooks has a problem with this when your int main() statement has a comment on it.

For example:

If your main looks as follows:

int main() // main function

You will get an error message:

Could not find main function

You need to change your code to:

// main function
int main()

If you do not make this change you will continue to fail the unit tests.

Students in a history class are asked to take a quiz posted on the course Web site.

1. Students in a history class are asked to take a quiz posted on the course Web site. The instructor has explained the following rules to the students: First, they are supposed to do their own work. Second, they are free to consult their lecture notes and the textbook while taking the quiz. Third, in order to get credit for the quiz, they must correctly answer at least 80 percent of the questions. If they do not get a score of 80 percent, they may retake the quiz as many times as they wish.

Mary and John are both taking the quiz. They are sitting next to each other in the computer room. John asks Mary for help in answering one of the questions. He says, “What’s the difference if you tell me the answer, I look it up in the book, or I find out from the computer that my answer is wrong and retake the quiz? In any case, I’ll end up getting credit for the right answer.” Mary tells John the correct answer to the question.

Discuss the morality of Mary’s decision.

It is important to understand the different types of attacks that can occur depending on both the operating system and underlying hardware in order to properly provide effective local-oriented cybersecurity defensive strategies.

It is important to understand the different types of attacks that can occur depending on both the operating system and underlying hardware in order to properly provide effective local-oriented cybersecurity defensive strategies.

Create a 10- to 15-slide or a 6- to 8-minute narrated presentation that outlines the vulnerabilities of embedded operating systems, such as, but not limited to, IoT devices, programmable logic devices, and vehicle control systems. This presentation can be created using your choice of presentation application as long as it is downloadable to the learning management system and/or instructor approved. Address the following within the presentation:

  1. Discuss the tools used by hackers to penetrate these devices and the effects of each penetration type.
  2. Provide insight as to how embedded operating system vendors provide defenses against hacking attempts
  3. Describe, in steps, at least one strategy used to attack embedded operating systems.
  4. Describe, in steps, at least one strategy used to defend against the chosen attack.
  5. Explain ways in which you feel the programmers of embedded operating systems can improve on their existing attempts to secure the devices which host their programs.

This assignment uses a rubric (attached). Please review the rubric prior to beginning the assignment to become familiar with the expectations for successful completion.

Embedded OS Presentation Scoring Guide

CYB-610 Embedded OS Presentation Scoring Guide

Performance Level Ratings

Meets Expectations

 

Performance consistently met expectations in all essential areas of the assignment criteria, at times possibly exceeding expectations, and the quality of work overall was very good. The most critical goals were met.
Near Expectations

 

Performance did not consistently meet expectations. Performance failed to meet expectations in one or more essential areas of the assignment criteria, one or more of the most critical goals were not met.
Below Expectations

 

Performance was consistently below expectations in most essential areas of the assignment criteria, reasonable progress toward critical goals was not made. Significant improvement is needed in one or more important areas.

 

CriteriaBelow Expectations

 

Near Expectations

 

Meets Expectations

 

Earned
The students clearly describes the tools used by hackers to penetrate the specified devices and the effects of each penetration type.0 pts – 6 pts7 pts – 9 pts10 pts 
The student provides insight as to how embedded operating system vendors provide defenses against hacking attempts.0 pts – 6 pts7 pts – 9 pts10 pts 
The students describes, in steps, at least one strategy used to attack embedded operating systems.0 pts – 6 pts7 pts – 9 pts10 pts 
The students describes, in steps, at least one strategy to defend against the chosen attack.0 pts – 2 pts3 pts – 4 pts5 pts 
The student clearly explains innovative ideas to secure devices which host the programs.0 pts – 2 pts3 pts – 4 pts5 pts 
Industry standard technical writing is correct and utilized throughout.0 pts – 6 pts7 pts – 9 pts10 pts 
TOTAL   /50
Instructor Feedback

 

 

 

 

 

 

© 2018. Grand Canyon University. All Rights Reserved.

Students will create a Disaster Recovery Plan for either the organization they work for or one they wish to work for in the future.

Students will create a Disaster Recovery Plan for either the organization they work for or one they wish to work for in the future. The plan will follow the template/example provided. Student should request prior authorization of company to be addressed to ensure that all students are working on unique companies. **Even though this is a technical document, for academic purposes, all sources should be cited and referenced.

Describe how one can implement each of the following operations on an array so that the time it takes does not depend on the array’s size n. a. Delete the ith element of an array

1. Describe how one can implement each of the following operations on an array so that the time it takes does not depend on the array’s size n. a. Delete the ith element of an array (1 ≤ i ≤ n).

b. Delete the ith element of a sorted array (the remaining array has to stay sorted, of course).

2. If you have to solve the searching problem for a list of n numbers, how can you take advantage of the fact that the list is known to be sorted? Give separate answers for

a. lists represented as arrays.

b. lists represented as linked lists.

3. a. Show the stack after each operation of the following sequence that starts with the empty stack: push(a), push(b), pop, push(c), push(d), pop

b. Show the queue after each operation of the following sequence that starts with the empty queue: enqueue(a), enqueue(b), dequeue, enqueue(c), enqueue(d), dequeue

Once you have Racket installed, open DrRacket. Here is what DrRacket looks like on Linux; it should look similar on Windows and macOS:

Lab #2 — Scheme Exercises CS 152 Section 5 — Fall 2020 Michael McThrow San José State University

Prelude – Installing and Using DrRacket We will be using the DrRacket IDE in this course for running Scheme programs. DrRacket is available for Windows, macOS, and Linux. You can download it by going to https://racket-lang.org, clicking on the “Download” button on the top right of the page, and choosing the appropriate platform for your computer.

Once you have Racket installed, open DrRacket. Here is what DrRacket looks like on Linux; it should look similar on Windows and macOS:

Note that the window has two sections. The first section where you see “#lang racket” is the source code file. The second section is the interpreter, which some programmers call the REPL, which stands for the “Read Eval Print Loop,” which describes how the user interface for interactive Lisp interpreters is implemented. (This REPL terminology has been now widely applied for other interactive interpreters, such as those for Python and JavaScript.) When you write your programs, you’re going to use the upper portion. However, if you just want to evaluate an expression on the fly, you can use the REPL on the lower portion.

Now, notice the “#lang racket” in the source code file section of DrRacket. That indicates that the program written below that line will be in the Racket programming language, which is a variant of

 

 

Scheme. For this assignment, however, we will be sticking to functions that are included in the R6RS version of Scheme. This enables us to use the REPL (sadly R6RS Scheme doesn’t have REPL support implemented in DrScheme) and to make use of DrScheme’s excellent debugging facilities.

Let’s try out the REPL by evaluating (+ 2 (* 3 5)). Type “(+ 2 (* 3 5))” at the prompt (with no quotes) and press Enter.

When you write your code, you are going to use the upper portion of the window, and you are going to use the Run button to run your code, either the entirety of the source code or a selection of it.

For a more detailed tutorial of the DrRacket IDE, please visit the DrRacket IDE manual at https://docs.racket-lang.org/drracket/.

Warmup Exercises (40 points) 1. (10 points) Write a function named fizz-buzz that accepts no arguments. The fizz-buzz

function outputs numbers 1 to 100 (inclusive) and prints them line-by-line as standard output. If a number is divisible by 3, we print “fizz” instead of the number. If a number is divisible by

 

 

5, we print “buzz” instead of the number. If a number is divisible by both 3 and 5 (e.g., 15), we print “fizzbuzz” instead of the number.

Hint: Scheme provides a remainder function (e.g., (remainder 3 2) evaluates to 1.) The display function accepts both numbers and strings. Note, though, that unlike Java’s System.out.println() function, display does not automatically append a new line.

2. (15 points) Write a function named gcd that accepts two arguments m and n. This computes the greatest common denominator of m and n; you may assume these are integers. For example, if m is 16 and n is 36, the greatest common denominator is 4. You may assume that m and n are integers.

3. (5 points) Write a function named linear-search that accepts two arguments: items and key. This function performs a linear search on the list items, determining whether key (an integer) is among those items. The function evaluates to true (#t) if the key is found, and false (#f) is the key is not found. For this function, when it comes to operating on the list, you are only allowed to use the Scheme functions first and rest; you may not use Scheme’s built-in search functions, nor are you allowed to take advantage of maps and filters.

4. (10 points) Write a function named my-remove that accepts two arguments: items (a list) and key. This function returns a new list that does not have any elements that match the key. Once again, you may only use first and rest for traversing the existing list, and for creating the new list, you are limited to the cons, list, and append functions.

Binary Search Tree (60 points) We will be writing a binary search tree in Scheme. Recall from CS 146 that a binary search tree is a data structure that allows for the storage of elements in a manner that is amenable to performing searches in O(log n) in the average case. For example, suppose we are adding the elements 3, 4, 2, 5, 8, 1, and 4.5 (in that order) to construct a binary search tree. We will end up with the resulting tree:

 

 

In Scheme, we could represent the above binary search tree as a collection of embedded lists:

(3 (2 (1)) (4 () (5 (4.5) (8))))

Each node is a list with up to three elements. The first element of the list refers to the node’s value. If a node is terminal (i.e., has no children), then it is represented as a one-element list. If a list has only two elements, that means the node only has a left child. If a node has only a right child, then it has three elements, but because there is no left child, the second element is the empty list (). A node with both a left and right child has three elements: the value, the left child, and the right child.

Let’s do each insertion step by step:

3 => (3) 4 => (3 () (4)) 2 => (3 (2) (4)) 5 => (3 (2) (4 () (5))) 8 => (3 (2) (4 () (5 () (8)))) 1 => (3 (2 (1)) (4 () (5 () (8)))) 4.5 => (3 (2 (1)) (4 () (5 (4.5) (8))))

Note that no duplicate elements are allowed in the binary search tree.

Write the following functions as follows (note: you may assume that all elements in the binary search tree are numbers): 1. (22.5 points) add-to-binary-search-tree with two arguments bst (the binary search tree)

and item, which is the item to be inserted into the binary search tree. This function returns a new binary search tree in its correct order. Note that if item is already in the binary search tree, then this function simply returns the existing binary search tree.

2. (7.5 points) create-binary-search-tree with argument items, a list of items to be inserted into the binary search tree. This function returns a new binary search tree with all of the items inside, excluding duplicates.

3. (15 points) search-binary-search-tree with two arguments bst (the binary search tree) and key, which is the item to search for in the binary search tree. This function returns #t if found and #f otherwise.

4. (15 points) binary-search-tree-to-list with two arguments bst (the binary search tree) and traversal, a symbol that indicates the traversal method. If the symbol is preorder, then place the elements in a list using preorder traversal. If the symbol is inorder, then use inorder traversal. If the symbol is postorder, then use postorder traversal.

Rules • No side effects are allowed with the exception of the display function and other functions that

print to the screen. • No mutation is allowed; this includes the use of set! • No do loops; either use recursion or map/filter/fold style functions (for-all is acceptable). • Make sure all of your code cleanly runs when turning it in; if I cannot evaluate your function,

that function gets a grade of zero.

 

 

• No external libraries or Racket-only libraries; use only the R6RS Scheme standard library.

Recommendations and Hints • I highly recommend writing some test cases for your code. One of the nice things about coding

without side effects is that you can just use simple equality functions to test what your functions evaluate to.

• Functional programming can sometimes feel like a mind-bending exercise for beginners. I highly recommend working out your programs on paper and thinking about how you would express with recursion, map, filter, and/or fold what you would normally express with loops in your Java programs. In some ways it’s like learning how to code again. But don’t feel discouraged; remember the first time you learned how to program, or the first time you learned how to write in assembly language. With practice, though, then functional programming will be second nature for you.

• Helper functions are vital in an immutable world. Remember that you can have as many arguments as you can in your helper functions.

• You are allowed to define your own top-level functions besides the ones that have been specified as common helper functions, but these functions are subject to the same restrictions as the others (for example, these functions can’t take advantage of any features that the functions specified cannot take advantage of).

Instructions for Turning In the Assignment Please place all of your functions in a file called lab2.rkt. This is the file that you will be turning in to me via Canvas.

 

  • Prelude – Installing and Using DrRacket
  • Warmup Exercises (40 points)

Scheme Exercises

Lab #2 — Scheme Exercises CS 152 Section 5 — Fall 2020 Michael McThrow San José State University

Prelude – Installing and Using DrRacket We will be using the DrRacket IDE in this course for running Scheme programs. DrRacket is available for Windows, macOS, and Linux. You can download it by going to https://racket-lang.org, clicking on the “Download” button on the top right of the page, and choosing the appropriate platform for your computer.

Once you have Racket installed, open DrRacket. Here is what DrRacket looks like on Linux; it should look similar on Windows and macOS:

Note that the window has two sections. The first section where you see “#lang racket” is the source code file. The second section is the interpreter, which some programmers call the REPL, which stands for the “Read Eval Print Loop,” which describes how the user interface for interactive Lisp interpreters is implemented. (This REPL terminology has been now widely applied for other interactive interpreters, such as those for Python and JavaScript.) When you write your programs, you’re going to use the upper portion. However, if you just want to evaluate an expression on the fly, you can use the REPL on the lower portion.

Now, notice the “#lang racket” in the source code file section of DrRacket. That indicates that the program written below that line will be in the Racket programming language, which is a variant of

 

 

Scheme. For this assignment, however, we will be sticking to functions that are included in the R6RS version of Scheme. This enables us to use the REPL (sadly R6RS Scheme doesn’t have REPL support implemented in DrScheme) and to make use of DrScheme’s excellent debugging facilities.

Let’s try out the REPL by evaluating (+ 2 (* 3 5)). Type “(+ 2 (* 3 5))” at the prompt (with no quotes) and press Enter.

When you write your code, you are going to use the upper portion of the window, and you are going to use the Run button to run your code, either the entirety of the source code or a selection of it.

For a more detailed tutorial of the DrRacket IDE, please visit the DrRacket IDE manual at https://docs.racket-lang.org/drracket/.

Warmup Exercises (40 points) 1. (10 points) Write a function named fizz-buzz that accepts no arguments. The fizz-buzz

function outputs numbers 1 to 100 (inclusive) and prints them line-by-line as standard output. If a number is divisible by 3, we print “fizz” instead of the number. If a number is divisible by

 

 

5, we print “buzz” instead of the number. If a number is divisible by both 3 and 5 (e.g., 15), we print “fizzbuzz” instead of the number.

Hint: Scheme provides a remainder function (e.g., (remainder 3 2) evaluates to 1.) The display function accepts both numbers and strings. Note, though, that unlike Java’s System.out.println() function, display does not automatically append a new line.

2. (15 points) Write a function named gcd that accepts two arguments m and n. This computes the greatest common denominator of m and n; you may assume these are integers. For example, if m is 16 and n is 36, the greatest common denominator is 4. You may assume that m and n are integers.

3. (5 points) Write a function named linear-search that accepts two arguments: items and key. This function performs a linear search on the list items, determining whether key (an integer) is among those items. The function evaluates to true (#t) if the key is found, and false (#f) is the key is not found. For this function, when it comes to operating on the list, you are only allowed to use the Scheme functions first and rest; you may not use Scheme’s built-in search functions, nor are you allowed to take advantage of maps and filters.

4. (10 points) Write a function named my-remove that accepts two arguments: items (a list) and key. This function returns a new list that does not have any elements that match the key. Once again, you may only use first and rest for traversing the existing list, and for creating the new list, you are limited to the cons, list, and append functions.

Binary Search Tree (60 points) We will be writing a binary search tree in Scheme. Recall from CS 146 that a binary search tree is a data structure that allows for the storage of elements in a manner that is amenable to performing searches in O(log n) in the average case. For example, suppose we are adding the elements 3, 4, 2, 5, 8, 1, and 4.5 (in that order) to construct a binary search tree. We will end up with the resulting tree:

 

 

In Scheme, we could represent the above binary search tree as a collection of embedded lists:

(3 (2 (1)) (4 () (5 (4.5) (8))))

Each node is a list with up to three elements. The first element of the list refers to the node’s value. If a node is terminal (i.e., has no children), then it is represented as a one-element list. If a list has only two elements, that means the node only has a left child. If a node has only a right child, then it has three elements, but because there is no left child, the second element is the empty list (). A node with both a left and right child has three elements: the value, the left child, and the right child.

Let’s do each insertion step by step:

3 => (3) 4 => (3 () (4)) 2 => (3 (2) (4)) 5 => (3 (2) (4 () (5))) 8 => (3 (2) (4 () (5 () (8)))) 1 => (3 (2 (1)) (4 () (5 () (8)))) 4.5 => (3 (2 (1)) (4 () (5 (4.5) (8))))

Note that no duplicate elements are allowed in the binary search tree.

Write the following functions as follows (note: you may assume that all elements in the binary search tree are numbers): 1. (22.5 points) add-to-binary-search-tree with two arguments bst (the binary search tree)

and item, which is the item to be inserted into the binary search tree. This function returns a new binary search tree in its correct order. Note that if item is already in the binary search tree, then this function simply returns the existing binary search tree.

2. (7.5 points) create-binary-search-tree with argument items, a list of items to be inserted into the binary search tree. This function returns a new binary search tree with all of the items inside, excluding duplicates.

3. (15 points) search-binary-search-tree with two arguments bst (the binary search tree) and key, which is the item to search for in the binary search tree. This function returns #t if found and #f otherwise.

4. (15 points) binary-search-tree-to-list with two arguments bst (the binary search tree) and traversal, a symbol that indicates the traversal method. If the symbol is preorder, then place the elements in a list using preorder traversal. If the symbol is inorder, then use inorder traversal. If the symbol is postorder, then use postorder traversal.

Rules • No side effects are allowed with the exception of the display function and other functions that

print to the screen. • No mutation is allowed; this includes the use of set! • No do loops; either use recursion or map/filter/fold style functions (for-all is acceptable). • Make sure all of your code cleanly runs when turning it in; if I cannot evaluate your function,

that function gets a grade of zero.

 

 

• No external libraries or Racket-only libraries; use only the R6RS Scheme standard library.

Recommendations and Hints • I highly recommend writing some test cases for your code. One of the nice things about coding

without side effects is that you can just use simple equality functions to test what your functions evaluate to.

• Functional programming can sometimes feel like a mind-bending exercise for beginners. I highly recommend working out your programs on paper and thinking about how you would express with recursion, map, filter, and/or fold what you would normally express with loops in your Java programs. In some ways it’s like learning how to code again. But don’t feel discouraged; remember the first time you learned how to program, or the first time you learned how to write in assembly language. With practice, though, then functional programming will be second nature for you.

• Helper functions are vital in an immutable world. Remember that you can have as many arguments as you can in your helper functions.

• You are allowed to define your own top-level functions besides the ones that have been specified as common helper functions, but these functions are subject to the same restrictions as the others (for example, these functions can’t take advantage of any features that the functions specified cannot take advantage of).

Instructions for Turning In the Assignment Please place all of your functions in a file called lab2.rkt. This is the file that you will be turning in to me via Canvas.

 

  • Prelude – Installing and Using DrRacket
  • Warmup Exercises (40 points)

Create a Python dictionary that returns a list of values for each key. The key can be whatever type you want. 

Create a Python dictionary that returns a list of values for each key. The key can be whatever type you want.

Design the dictionary so that it could be useful for something meaningful to you. Create at least three different items in it. Invent the dictionary yourself. Do not copy the design or items from some other source.

Next consider the invert_dict function from Section 11.5 of your textbook.

# From Section 11.5 of:
# Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts: Green Tree Press.

def invert_dict(d):
inverse = dict()
for key in d:
val = d[key]
if val not in inverse:
inverse[val] = [key]
else:
inverse[val].append(key)
return inverse

Modify this function so that it can invert your dictionary. In particular, the function will need to turn each of the list items into separate keys in the inverted dictionary.

Run your modified invert_dict function on your dictionary. Print the original dictionary and the inverted one.

Include your Python program and the output in your Learning Journal submission.

Describe what is useful about your dictionary. Then describe whether the inverted dictionary is useful or meaningful, and why.

PART 2

 

Describe how tuples can be useful with loops over lists and dictionaries, and give Python code examples. Create your own code examples. Do not copy them from the textbook or any other source. 

Your descriptions and examples should include the following: the zip function, the enumerate function, and the items method.

Each student, independently of the team will prepare a brief summary for the week’s simulation efforts. This report will include the following information: 

Each student, independently of the team will prepare a brief summary for the week’s simulation efforts. This report will include the following information:

  1. What was your one corporate generic strategy as reviewed from our text for the week?  Break this down by your target market and your competitive advantage.  Why?  Did your overall strategy change since week 1?  Why?
  2. What was your strategic action plan going into the rounds detailed in Blackboard including the reasons for the moves and how it relates to your overall strategy?  What are your objective and measurable goals for the moves?  Did you have to make operationally reactive moves not related to your strategy?  Why?
  3. What was the objective, fact-based results compared to your intended moves and the reasons of these moves generally? How did your moves advance your one Generic Strategy?  Be specific.  Did you get the objective results you expected?  Why/why not?  Share any objective measures from the simulation program that are pertinent to the strategic implementation results and note any purely operational moves.  How did your competition and the external environment impact your moves?  What is your analysis of this data results compared to your intended results?
  4. What do you think the next set of objective and measurable moves you will have to consider, and what will you suggest to your partners regarding next week’s moves?
  5. What have you learned and how does this relate to other lessons in this course and to your career?
  6. Provide a log regarding the specific dates and times that you accessed the simulation system including specifically when and how you and your teammate reviewed and discussed the simulation system data and decided on your moves to make.  A sample is provided in week 1.

Your report this week should cover periods 5 thru 6 inclusively with fact-based objective data that you analyze from both periods.  DO NOT copy from your first paper.  Each paper must be written in your own words with proper APA referencing.

Your grade for each of the simulation report papers will be based on your analysis and critical thinking around the selection and implementation of the corporate strategy for your company.  Your analysis must be increasingly more thorough with each paper as you become more familiar with the simulation program and with the concepts from our course.

Your assignment will be between 1000 and 1500 words and follow APA Guidelines. Include a cover page and at least your course text as a reference.

References: Thompson textbook 2021.

Feedback: Please use the documents I have attached and no google words copied. Every letter should be written on own.