CS 480 Fall 2021 Programming Assignment #01

Due: Sunday, October 17th, 11:00 PM CST

Points: 20

Instructions:

1. Place all your deliverables (as described below) into a single ZIP file named:

LastName_FirstName_CS480_Programming01.zip

2. Submit it to Blackboard Assignments section before the due date. No late submissions will be accepted.

Objectives:

1. (20 points) Implement and evaluate two informed search algorithms.

Input data files:

You are provided two CSV (comma separated values) files (see Programming Assignment #01 folder in Blackboard):

? driving.csv – with driving distances between state capitals.

? straightline.csv – with straight line distances between state capitals.

You CANNOT modify nor rename input data files. Rows and columns in those files represent individual state data (state labels/names are in the first row and column). Numerical data in both files is either:

? a non-negative integer corresponding to the distance between two state capitals,

? negative integer -1 indicating that there is no direct “road” (no edge on the graph below) between two state capitals.

Deliverables:

Your submission should include:

? Python code file(s). Your py file should be named:

cs480_P01_AXXXXXXXX.py

where AXXXXXXXX is your IIT A number (this is REQUIRED!). If your solution uses multiple files, makes sure that the main (the one that will be run to solve the problem) is named that way and others include your IIT A number in their names as well.

? this document with your results and conclusions. You should rename it to:

LastName_FirstName_CS480_Programming01.doc

Problem description:

Consider the graph presented below (fig. 1). Each node represents a single state (or the District of Columbia (DC)). If two states are neighbors, there is an edge between them.

Figure 1: A graph representing all 48 contiguous US states and District of Columbia.

Assume that edge weights represent driving distances between state capitals.

Your task is to implement in Python two informed search algorithms:

? Greedy Best First Search algorithm, and

? A* algorithm,

and apply them to find a path between two state capitals using provided data.

Your program should:

? Accept two (2) command line arguments corresponding to two states / state capitals (initial and goal states) so your code could be executed with

python cs480_P01_AXXXXXXXX.py INITIAL GOAL

where:

? cs480_P01_AXXXXXXXX.py is your python code file name,

? INITIAL is the label/name of the initial state,

? GOAL is the label/name of the initial state.

Example:

python cs480_P01_A11111111.py WA TX

If the number of arguments provided is NOT two (none, one, or more than two), your program should display the following error message:

ERROR: Not enough or too many input arguments.

and exit.

? Load and process both input data files provided (assume that input data files are ALWAYS in the same folder as your code – this is REQUIRED!). Make sure your program is flexible enough to accommodate different input data sets (with a different graph of states and distances). Your submission will be tested using a different set of files!

? Run Greedy Best First Search and A* algorithms searches to find a path between INITIAL and GOAL states and measure execution time (in seconds) for both methods.

? Report results on screen in the following format:

Last Name, First Name, AXXXXXXXX solution:

Initial state: INITIAL

Goal state: GOAL

Greedy Best First Search:

Solution path: STATE1, STATE2, STATE3, …, STATEN-1, STATEN

Number of states on a path: X1

Path cost: Y1

Execution time: T1 seconds

A* Search:

Solution path: STATE1, STATE2, STATE3, …, STATEN-1, STATEN

Number of states on a path: X2

Path cost: Y2

Execution time: T2 seconds

where:

? AXXXXXXXX is your IIT A number,

? INITIAL is the label/name of the initial state,

? GOAL is the label/name of the initial state,

? STATE1, STATE2, STATE3, …, STATEN-1, STATEN is a solution represented as a list of visited states (including INITIAL and GOAL states), for example: IL, IA, NE,

If no path is found replace appropriate information with:

Solution path: FAILURE: NO PATH FOUND

Number of states on a path: 0

Path cost: 0

Execution time: T3 seconds

Now, recall the INITIAL / GOAL state pair that you used in Written Assignment #01 Problem 2 and run Greedy Best First and A* algorithms to find the path between them. Repeat this search ten (10) times and report your findings in the Table A below. If your Hill Climbing example did not reach the goal state write FAILURE.

TABLE A: Results comparison

Algorithm Visited states Number of visited states Path cost Average search time in seconds

Hill Climbing N/A

Greedy Best First Search

A*

What are your conclusions? Which algorithm performed better? Was the optimal path found? Write a summary below

Conclusions

BA3020QA – Assignment 3 – RESIT

Note to students:

There are FIVE tasks and you are expected to complete all of them. You are required to transfer the work of all tasks on to a single wordprocessed MS Word file and upload it on Turnitin, which is the submission of this assignment. The deadline for this assignment is (Thursday 21st October 2021 before 3pm).

Task 1 (25 Marks)

A supermarket manager wanted to investigate the profile of shoppers resistant to the use of self-checkout counters available at the store he manages and to find out the reasons behind their resistance. He asks three of his staff to conduct a survey among customers using the store in Sheffield Hallam area during a quiet working day in October of 2019 as they exited the store.

The short questionnaire used for the survey as well as the data collected can be found on an Excel file named “SCC”. There are two worksheets, one for the questionnaire used and the other worksheet for the raw data collected from the customers. The data worksheet has 18 columns. Column A “Customer” is simply a column to identify the customer surveyed – Customer 1, Customer 2 etc… Each of the other 17 columns refer to a question – Column B refers to the gender question, Column C refers to the age question etc…

The manager has employed you as data analyst to conduct this investigation.

Your analysis should use the statistical facilities on Excel as required below.

Required:

1. Label (show 5 rows) the codes for the categories of the following variables:

• Gender

• Age

• Education

• Are you a regular user of self-checkout

2. Produce frequency and percentage frequency tables (using Pivot tables) for each of the following variables:

• Gender

• Education

• Age

• SCC user

• Spending (£) For this last quantitative variable, the categories should be as follows:

100 100-

109 110-

119 120-

129 130-

140 140

3. Draw the graphical representation for each of the following variables:

• Education (Pie chart)

• Age (Bar chart)

• Spending (Histogram) using the following categories:

100 100-

109 110-

119 120-

129 130-

140 140

• Spending (Box and whisker) graph

4. Consider now the variable “Spending (£)”. • Calculate the minimum, maximum, median, quartiles and the mean average statistics (show Excel formulas).

Note:

The tasks and all their requirements should be clearly separated (preferably each task starts on a separate page). All variables should be clearly named and their correct categories clearly labelled. Graphs should be appropriate and correctly labelled and each of them on the same page. Any calculations should be clearly presented and explained.

Task 2 (20

A plumber has decided to use the techniques of project management in order to plan a job. He knew all the different activities of the job, their precedence and their average durations. They are shown on the table below.

Activity Duration (days) Preceding activities

A 3 None

B 3 None

C 4 A

D 8 A

E 2 B and C

Required:

1. Draw a network diagram representing the sequence of activities and the dependence between them.

2. Determine how long it will take to complete the job by conducting the forward pass

3. By conducting the backward pass, identify the critical path and the noncritical path(s).

Note:

The work for this task should be produced using Word drawing facilities. The forward and backward passes should be clearly shown on the diagram. The calculations should be shown next to the network diagram.

Task 3 (25

The quarterly sales figures for the number of shoes (pairs) sold at a shoe shop is shown on the table below. Enter the following data into Excel.

Year Quarter Sales

2017 1 139

2 135

3 91

4 113

2018 1 145

2 137

3 85

4 118

2019 1 150

2 141

3 89

4 119

2020 1 156

2 149

3 105

4 125

Required (using Excel):

1. Draw a line graph to represent the sales figures.

2. Show formulas and calculate the moving averages.

3. Show formulas and calculate the centre moving averages.

4. Present the original sales data and the trend of sales figures on the same line graph.

Task 4 (15

The following information relates to the probability of two different managers selecting a salesperson for a job:

Probability of Manager Toni choosing a Salesperson is 0.5

Probability of Manager Joe choosing a Salesperson is 0.4

Over the last 10 working days, Manager Toni has worked for 6 days and Manager Joe worked 4 days. Only one manager works in a day.

Required:

Build a Tree diagram to show the probabilities of a Salesperson being selected.

Show the different branches of the Tree diagram with all the calculations. Include in the Tree diagram the overall probabilities. Calculate the probability of the Salesperson.

Note:

The work for this task should be produced using Word drawing facilities.

Task 5 (15 Marks)

A small cheese maker specialises in two types of cheese – Brie and Gouda that he makes and sells in packets of 400 grams. The cheese maker has estimated that each packet of Brie uses 1.8 litres of special milk and 100 grams of special salt. For the Gouda cheese packet, the amounts of special milk and salt needed are 1.2 litre and 150 grams respectively. The cheese maker has a limited supply of special milk and salt and a maximum of only 120 litres of milk and 12000 grams of salt is made available each week. Once produced and sold, the Brie packet returns a £4.50 profit and £3 profit for the Gouda cheese.

Required:

1. Enter the information on the table below into an Excel file. You should also show an appropriate formula for “Total profit” and quantity “Used” for each of the “milk” and “salt” resource in the cells as indicated below.

Packet Brie Gouda

Quantity 0 0 Total Profit

Unit profit

(£) 4.5 3 Insert formula

Used Symbol Max

Milk

(litres) Insert

number Insert

number Insert formula 120

Salt (grams) Insert

number Insert

number Insert formula 12000

2. Find the solution of the linear programming problem (using Excel Solver)

3. State the production of each type of cheese that yield maximum profit. ]]>

BA3020QA

Assignment 1 (Nov20 cohort) – RESIT

Note to students:

There are FIVE tasks and you are expected to answer all of them. Answer each task on a separate worksheet on the same Excel file.

The deadline for this assignment is Thursday 21st October 2021 before 3pm. The submission is via the link on Weblearn in the Assessments folder.

Task 1 (10 marks)

Use Excel as a calculator to evaluate the following calculations. For each calculation you should provide the formula you have used (1 decimal place)

a. 34.2 -16.8 x 6.3

b.

c. (369 – 173 / 4) ÷ 68 x (2.3)4

d. 34.78 – (5.63)2

34.78 ÷ 53

e. (2864 – (143 x 36)/3

Task 2 (10 marks)

Use the Excel formatting facilities (show formulae) to answer the following questions:

a. Express 42.5% as a fraction in its simplest form.

b. Express 0.18 as a percentage.

c. 0.725 as a fraction in its simplest form.

d. Helen achieved 26/40 in a test. Express her result as a percentage.

e. Work out 4/9 ÷ 3/8, giving your answer as a fraction in simplest form.

Task 3 (10 marks)

Use Excel financial facilities to perform the following scenarios:

You need to show the financial formulae you have used in each case.

a. Calculate the total amount accrued after 5 years for saving a single amount of £10,000 in a bank account that pays interest of 3% per year. Assume that interest is calculated at the beginning of every year.

b. Calculate the monthly repayments for a 5 year loan of £20,000, with 4% interest per year. Repayments are made at the beginning of each month.

c. Calculate the total amount accrued after 10 years for regular monthly cash investments of £200 paid into a savings account at the beginning of each month and pays 3.25% interest per year.

d. Calculate the monthly repayments (payable at the end of each month) for a period of 25 years, for a mortgage of £250,000 at a fixed interest rate of 2.9% per year.

e. What is the single amount you need to save today so that you will have £30,000 in 5 years, if the saving rate is 4%? Assume that interest is applied to the account at the end of every year.

Task 4 (10 marks)

Use an Excel worksheet to setup one table to compare the UK Government spending for the two years. Calculate the amounts for each department (in £bn) for the following scenario:

Scenario

Total UK Government spending for the financial year 2020 was £874 bn. The sum is split between each of the departments as follows:

Pensions 18.4%

Healthcare 18.8%

Education 10.5%

Others 52.3%

Total UK Government spending for the financial year 2021 was estimated to be £908 bn. The sum is split between each of the departments as follows:

Pensions 18.5%

Healthcare 19.6%

Education 10.4%

Others 51.5%

By comparing the UK Government spending (£bn) in healthcare, work out the percentage increase for 2021 (show formula)

Task 5 (10 marks)

You are given the following employees’ information after their first six months at work. Enter the data as shown on an Excel spreadsheet and complete the following table:

Employee Holidays taken (days) Training completed (days) Logical Function

(Insert Formulapart c)

A 5 3

B 8 2

C 10 0

D 7 1

E 4 3

F 12 2

G 9 0

H 11 3

I 8 1

J 10 2

Number of Employees (Insert formulapart a) (Insert formulapart b)

a. Write down a function that will return the number of employees who have taken more than 10 days as holiday.

b. Write down a function that will return the number of employees who have completed less than 2 training days.

c. Write down a logical function with an “IF” statement to test whether an employee has taken more than 10 days as holiday and completed less than 2 training days. You should use “Yes” if the employee has taken more than 10 days as holiday and completed less than 2 training days.

Note: The functions you show in the table for questions a. to c. should be written using relative references to your spreadsheet rows and columns. ]]>

Richard and Helen are a married couple in their mid-thirties. They have two daughters – Anne, aged 14, and Clare, aged 6. They recently separated. Their relationship has deteriorated dramatically since Richard became unemployed and he now believes that Helen is having an affair with a woman. The children are currently living with Helen, but Richard wishes to care for them full time. Helen has petitioned for divorce and Richard has applied for a residence order. At the same time, Anne and Clare’s teachers have become concerned about both the girls’ behaviour. Anne’s schoolwork is deteriorating and she has been involved in bullying. Clare’s teacher is particularly concerned because she has noticed that Clare has become increasingly withdrawn whereas previously she was very lively. One day the teacher notices that Clare has bruises on her thighs, but she refuses to explain their cause. The teacher passes this information to social services. When the social worker contacts the parents, Helen claims that Richard must have caused the bruises when he took the girls out at the weekend. Richard denies the allegation. Anne has told the school nurse that her father smacks her and her sister but does not want the nurse to tell anybody about this. Consider how this case should progress.

Tommy is aged 12 and lives with his mother, Jean, and his two siblings. Tommy is coming to the end of his first term of secondary school. His attendance record is poor, with 18 days’ unauthorised absence out of a possible attendance of 52 days. Jean says that she can no longer control Tommy and, though she does try to encourage him to attend school, if he does not want to go she accepts there is nothing she can do. When Tommy is at school, he is frequently involved in fights with other boys, who accuse him (often with justification) of being dirty and smelly. Tommy’s form teacher has prepared a brief report, saying that Tommy is not a malicious child but he is large for his age, frequently clumsy, occasionally aggressive to his peers, and significantly behind his expected age-related attainment in reading and writing. What action do you consider taking to improve Tommy’s current educational underachievement?

You are the supervising social worker for Ruth, an 11-year-old girl who has been in the care of your local authority for three years since there was a finding of sexual abuse by her father. Until the care order was made, Ruth lived in a ‘traveller’ community. Ruth has been placed in long-term foster care. She displays significant behavioural problems and has already suffered two brief, fixed-term exclusions from her junior school. She is due to start secondary school next term. The foster carer has reported to you that she has visited the headteacher of the new school to discuss Ruth’s impending transfer. The head was frankly hostile. She commented that ‘kids in care always drag down the exam results’ and ‘these traveller children are a particular nuisance’. What support could you provide to Ruth in these circumstances, especially to deal with the transition to secondary school? Do any Human Rights Act considerations arise?

Jeannie, aged 15, has recently started going out with James, who is 28. Her parents are very unhappy about the relationship and think she may also be taking drugs. She has failed to attend school today and is picked up by the police in an area of town known for prostitution, in possession of £100 cash and £50-worth of cosmetics. Just as the police are about to drive off, James rushes over, shouting at Jeannie not to talk, and damages the police car with an iron bar. At the police station the custody officer calls Jeannie’s parents, who state that ‘she is no longer our daughter’ and refuse to come to the station. A social worker is called to be with Jeannie and notices injection marks on her arm. Jeannie admits to theft of the cosmetics but denies any knowledge of the money. She has no previous convictions. Initially she claims not to know James, but after a four-hour period of questioning she breaks down and states that he is her pimp, the money is for him, but she is frightened that he will beat her up if he finds out she has told the police. Consider the responsibilities of the social worker called to the station. If the social worker fulfils the role adequately, what changes to the above scenario might occur. What are the options for responding to Jeannie’s situation?

Surinder is an 18-year-old woman with Down’s syndrome. She lives at home with her parents; her two older brothers left home some years ago and have their own families. She attended a local comprehensive school until she reached the age of 16 and has stayed at home with her parents since then. The family have not received any support from social services. Her parents are very protective of Surinder and she is always accompanied by them if she goes out, even to the local shop. Surinder would like to go to college and meet up with her old school friends but her parents will not allow her to travel alone. Her parents are growing older and her father, who drove until recently, has lost his driving licence due to poor eyesight. Surinder’s sister-in-law, Jasmin, has said that Surinder could move in with her family and help to look after her children but Surinder’s parents will not allow this. They have a row with Jasmin and tell Surinder not to have any further contact with her. Surinder is becoming depressed and is eating very little. Jasmin contacts social services to see if they can help Surinder to gain more independence. What steps might a social worker take, once contacted by Jasmin?

Annie is 88 years old and cared for by her daughter, Dorothy, aged 66. They live in a thirdfloor flat, which Annie bought from the council. Annie is losing her sight and suffers from arthritis. She is on a waiting list for a hip replacement. She cannot use the stairs and the lift at the flats is often out of order. She does not want to go out much in any case, as she is anxious about falling. She has recently become incontinent and needs attention at night. They have no washing machine and the laundry is a bus ride away. Dorothy is finding caring for her mother very stressful and feels unable to leave her for more than a short time. She has not been able to do any of the things she had planned on retirement. She contacted social services and explained their situation. Three months later, a social worker visited. She spent approximately half an hour at the flat. She offered Annie a place at a day centre for elderly people, four miles away, one day a week but said she could not help with transport to get her there. She said that at the moment she could not offer any help such as meals on wheels or home help but she would come back in six months’ time, at the start of the next financial year. In response to Dorothy’s concerns that she was finding it hard to care for her mother, the social worker said Annie could move to a residential home but that the flat would have to be sold to pay for it. What are the legal and practice issues raised in this scenario?

George, aged 47, is susceptible to periods of depression and self-harming. He has been admitted to the local psychiatric hospital on a voluntary basis a number of times over the years. He recently lost his job, became depressed, stopped taking his medication and started to drink heavily. He refused to go back into hospital on a voluntary basis and has been detained for five months. His only relative, a sister whom he sees infrequently, has contacted the hospital and insists that George should be allowed home. His living accommodation is very poor and he has very few links in the community. He would also like to be discharged. The hospital are concerned that if discharged he will fail to take his medication and may start to self-harm again. Consider any options that would enable George to return safely to the community