assignment6
.pdf
keyboard_arrow_up
School
University of California, Davis *
*We aren’t endorsed by this school
Course
680
Subject
Computer Science
Date
Dec 6, 2023
Type
Pages
3
Uploaded by ConstableBeaverMaster735
Homework Assignments
Homework Assignment 6
This is your final project report, and talk.
Homework Assignment 5
This is a short video synopsis of your final project.
Homework Assignment 4
This was your final project proposal
Homework Assignment 3
Paper part due Thursday, March 5, at the start of class, code by midnight.
This assignment focusses on intelligent search. See handout for details.
Clarifications
N starts at 0.
floating point input sequences are possible, i.e.:
odd05% ./prog1 .2 .4 .6 .8
With floating point numbers, remember there is a roundoff issue. Be sure to include a tolerance when determing
if floating point numbers are equal.
Your goal is to find the shortest (smallest number of leaf nodes) possible sequence function that solves the
problem.
Use the command line to input sequences to your program, i.e.:
odd05% ./prog1 0 1 2 3 4 5
Shortest function is:
N
Next item is:
6
odd05% ./prog1 2 3 4 5
Shortest function is:
N + 2
Next item is:
6
Be sure to include a
Makefile
, and include any special instructions for running your program by using a
readme.txt
file.
I will be testing your code on the Ubuntu machines (the machines in Stocker 307), so be sure it compiles and
runs there!
C++ programs must use the suffix ".cc".
You MAY NOT use the suffix ".cpp" which some other operating
systems use.
Text files, e.g. script output, should be submitted with the suffix ".txt" e.g. "testcase1.txt", or "test1.txt".
You are to turn in your code electronically by using the
submit
program on the Ubuntu machines, i.e. those in
Stocker 307
(BE SURE TO USE THE MACHINES IN 307 TO RUN SUBMIT(e.g. odd01.cs.ohio.edu, or
pu1.cs.ohio.edu), DO NOT USE PRIME, P1, or P2.).
To use this method to submit this first program:
~cs6800/bin/submit prog1 prog1.cc test1.txt test2.txt test3.txt Makefile readme.txt
or using the unix wildcard '*' command:
~cs6800/bin/submit prog1 prog1.cc test* Makefile readme.txt
Note: the first word after the submit command is the name of the assignment to submit, this will change
depending on which assignment you are submitting. For homework assignments you will use
prog1
,
prog2
, etc.
Be sure to limit any single submission to at most 20 files.
There is also an interactive version of the command:
odd01.cs.ohio.edu>
~cs6800/bin/submit
This version allows you to check what has been submitted, as well as several other commands. Here is an
example of its use:
odd01.cs.ohio.edu>
~cs6800/bin/submit
**
Welcome to the submit program.
**
- This program submits programs for CS6800.
Remember you can use this program either as menu driven, or
command-line driven. Type submit -h for more help.
Please type the assignment name to submit:
prog1
At any point: ^C will quit, with no changes to any files.
Enter one of the following choices:
s: submit new files
r: review the files submitted
d: delete/remove all files previously submitted
l: check late record
q: quit
Choice:
Or for help:
/home/cs6800/bin/submit -h
Homework Assignment 2
Due Thursday, February 13 at the start of class.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Searching - a user should be able to search by ID or by item name
create only one menu item for searching
a user should be able to enter the name of the item using any case, (for example, sTRolleR)
you may wish to store items in all lower/upper case to expedite the search
write one search function that can search by ID and name and goes through the array of structs/objects only once
show the entire record if found or an appropriate message if not
Sorting - sort by any field
write one function to sort by any field using a parallel array of pointers
use Bubble Sort is not the most effective but the easiest to modify.
do not copy and paste sort code five times into the same function.
sorting using pointers is faster because you have to swap pointers only, which are normally stored in 4 bytes each; it also allows you to preserve the original order of the items
If you choose to have a submenu, a submenu must have an option to go back to the previous menu or main menu
if a user got…
arrow_forward
Q.Create an interesting educational information chat box that asks the user to give an input question and then answers the question given by user with a suitable answer. You can make use of list for different questions and answers.Save two to three answers for a single question and then for random selection of elements from those answers use random choice(list) method from random module that returns a random element. Also for a user question that doesn't matches with the questions present in the chat box it should display statement like "oops i can't answer that" "sorry i am not intelligent enough" "could u please ask something else" using random method so that every time one of these statements appear
**coding language python
***try using basic programming techniques in python without using arrays and pointers
* * * copy paste the program itself and also the screenshot of program and output
* * * use any type of data for questions such as name details of cities species etc depends on…
arrow_forward
Q.Create an interesting educational information chat box that asks the user to give an input question and then answers the question given by user with a suitable answer. It should match the question of user with a suitable answer avaliable . You can make use of list for different questions and answers. (if possible) Save two to three answers for a single question and then for random selection of elements from those answers use random choice(list) method from random module that returns a random element. Also for a user question that doesn't matches with the questions present in the chat box it should display statement like "oops i can't answer that" "sorry i am not intelligent enough" "could u please ask something else" using random method so that every time one of these statements appear
**coding language python
***try using basic programming techniques in python without using arrays and pointers
* * * copy paste the program itself and also the screenshot of program and output…
arrow_forward
appropriate r code?
arrow_forward
Q.Create an interesting educational information chat box that asks the user to give an input question and then answers the question given by user with a suitable answer. It should match the question of user with the answer avaliable. Make use of list for different questions and answers. (if possible) Save two to three answers for a single question and then for random selection of elements from those answers use random choice(list) method from random module that returns a random element. Also for a user question that doesn't matches with the questions present in the chat box it should display statement like "oops i can't answer that" "sorry i am not intelligent enough" "could u please ask something else" using random method so that every time one of these statements appear
**coding language python
***try using basic programming techniques in python without using arrays and pointers
* * * copy paste the program itself and also the screenshot of program and output
* * * use any…
arrow_forward
get_column_choice(): this function will allow us to ask the players which pocket they want to grab stones from. Since we know which row they are grabbing from (since it is not allowed to grab stones from your opponent’s side), we only need to get the column they want. As previously stated, we are using letters to represent the columns to make it easier on the player. This function accepts the current player (should be a 0 or 1), the board, and a list of letters (the same as the list you passed to the print_game_board function) and it will return the index of the column being chosen.
The function should ask the player to enter a column letter, then it should check that the conditions listed below hold. If they don’t meet these conditions, it should ask again until it gets a valid letter, otherwise it should return the corresponding column index for that letter.
Letter entered must be on the game board. It can be lower case or upper case. (Hint: this doesn’t need to be hard coded,…
arrow_forward
Activity Duration Predecessors
A
2
B
10
A
1
D
7
В
E
B
F
2
D, C
G
10
А
Using the above information, Insert the Early Start (ES), Early Finish (EF), Late Start (LS), Late Finish (LF) and Slack Time of the following
specified nodes.
(Only integer value, no decimal points. For example if your ans is 7.4 or 7.6 , insert 7 only)
Activity
ES
EF
LS
LF
Slack Time
A
E
F
G
arrow_forward
Nearest polygonal number def nearest_polygonal_number(n, s):
Any positive integer s > 2 defines an infinite sequence of s-gonal numbers whose i:th element is given by the formula ((s-2)i2 - (s-4)i)/2, as explained on the Wikipedia page "Polygonal Number". In this formula, positions start from 1, not 0, and we use the letter i to denote the position since we will be using the letter n for something else. For example, the sequence of "octagonal numbers" that springs forth from s = 8 starts with 1, 8, 21, 40, 65, 96, 133, 176...
Given the number of sides s and an arbitrary integer n, this function should return the s-gonal integer closest to n. If n falls exactly halfway between two s-gonal numbers, return the smaller one.
As you can see from the last row of the previous table, this function must be efficient even for gargantuan values of n. The simplest way to make this function efficient is to harness the power of repeated halving to pull your wagon with a clever application of…
arrow_forward
Q29:A teacher stores the most recent quiz scores for her class in the list scores. The first element in the list holds the maximum possible number of points that can be awarded on the quiz, and each remaining element holds one student’s quiz score. Assume that scores contains at least two elements. Which of the following code segments will set the variable found to true if at least one student scored the maximum possible number of points on the quiz and will set found to false otherwise?
arrow_forward
Sum of two squares
def sum_of_two_squares(n):
Some positive integers can be expressed as a sum of two squares of some positive integers greater than zero. For example, 74 = 49 + 25 = 7^2 + 5^2. This function should find and return a tuple of two positive integers whose squares together add up to n, or return None if the parameter n cannot be broken into a sum of two squares.To facilitate the automated testing, the returned tuple must present the larger of its two numbers first. Furthermore, if some integer can be broken down to a sum of squares in several ways, return the breakdown that maximizes the larger number. For example, the number 85 allows two such representations 7^2 + 6^2 and 9^2 + 2^2 , of which this function must return (9, 2).The technique of two approaching indices that start from the beginning and end of a sequence, respectively, and approach each other until they meet somewhere is directly applicable to this problem. In this problem, these indices crawl towards each…
arrow_forward
cvcxvcvxvcv
arrow_forward
Non dynamic.arrays are allocated at runtime where dynamic arrays are allocated at compile time.
True
False
Question 4
There are other ways to end a loop other than just the loop condition evaluating to false.
True
False
arrow_forward
The Apgar Medical group keeps a patient file for each doctor in the office. Each record contains the patient's first and last name, home address, and birth year. The records are sorted in ascending birth year order. Write a program so that display a count of the number of patients born each year
John Hanson, 23 Elm, 1927Mary Locust, 476 Maple, 1950Susan Monroe, 512 Peachtree, 1957Carol Fortune, 2819 Locust, 1960James Fortune, 2819 Locust, 1963Lawrence Fish, 12 Elm, 1968Janice Weiss, 234 Birch, 1971Henry Garza, 199 Second, 1973Kimberly Swanson, 310 Appletree, 1980Louis Claude, 2716 Third, 1981Jill Fox, 12 Oak, 1985Opal Reynolds, 78 County Line, 1987Francis Dumas, 67 Fourth, 1992Madison Conroy, 23 Fifth, 1996Daniel Moy, 100 Sunset, 1987
arrow_forward
Sum of two squares def sum_of_two_squares(n):
Some positive integers can be expressed as a sum of two squares of some positive integers greater than zero. For example, 74 = 49 + 25 = 72 + 52. This function should find and return a tuple of two positive integers whose squares together add up to n, or return None if the parameter n cannot be broken into a sum of two squares.
To facilitate the automated testing, the returned tuple must present the larger of its two numbers first. Furthermore, if some integer can be broken down to a sum of squares in several ways, return the breakdown that maximizes the larger number. For example, the number 85 allows two such representations 72 + 62 and 92 + 22 , of which this function must return (9, 2).
The technique of two approaching indices that start from the beginning and end of a sequence, respectively, and approach each other until they meet somewhere, used in the function two_summers in one of our class examples, is directly applicable to this…
arrow_forward
Sum of two squares def sum_of_two_squares(n): Some positive integers can be expressed as a sum of two squares of some positive integers greater than zero. For example, 74 = 49 + 25 = 72 + 52. This function should find and return a tuple of two positive integers whose squares together add up to n, or return None if the parameter n cannot be broken into a sum of two squares.To facilitate the automated testing, the returned tuple must present the larger of its two numbers first. Furthermore, if some integer can be broken down to a sum of squares in several ways, return the breakdown that maximizes the larger number. For example, the number 85 allows two such representations 72 + 62 and 92 + 22 , of which this function must return (9, 2).The technique of two approaching indices that start from the beginning and end of a sequence, respectively, and approach each other until they meet somewhere, used in the function two_summers in one of our class examples, is directly applicable to this…
arrow_forward
Overview: Create a coin flip game that allows the user to guess whether the coin will be heads or tails. Save the data associated with the flip. Repeat for a total of 10 guesses/flips. Display result summary and details at end.
Technical Requirements:
Participant will guess whether a coin flip will result in Heads or Tails
Computer will "flip" a coin to determine the side it lands using random generator
import random at top of program
result = random.randint(x,x)
The program will display the results: Guess, Flip, Outcome (Match or No Match)
The program will track the results and, when the game is over, display:
Summary
Detailed result of each turn
Use parallel arrays to collect details from each turn that can be displayed as a table when the game is over
Use running totals of each result detail to display at end
arrow_forward
radius_mean gives the average size of the cells in terms of the radius of
circles drawn around each cell in the biopsy. texture_mean provides the
amount of variation in light to dark values in an image of the cells.
sb.regplot (data = cancer, x = "radius_mean", y = "texture_mean",
"lowess = True, line_kws = {"color": "orange"})
--INSERT--
40
texture_mean
35
20
15
10
10
15
20
radius_mean
25
Provide a brief explanation of what is displayed in this plot. Be sure to
comment on the orange line and how it expresses the conditional
mean of "texture_mean" for different values of "radius_mean."
arrow_forward
A for construct is a loop that processes a list of items. As a consequence, it continues to run as long as there are items to process. Is this statement true or false?
arrow_forward
1c) Average sentence length
We will create a function ( avg_sentence_len ) to calculate the average sentence length across a piece of text.
This function should take text as an input parameter.
Within this function:
1. sentences : Use the split() string method to split the input text at every '.'. This will split the text into a list of sentences. Store this in the
variable sentences . To keep things simple, we will consider every "." as a sentence separator. (This decision could lead to misleading answers. For
example, "Hello Dr. Jacob." is actually a single sentence, but our function will consider this 2 separate sentences).
2. words : Use the split() method to split the input text into a list of separate words, storing this in words . Again, to limit complexity, we will assume
that all words are separated by a single space (" "). (So, while "I am going.to see you later" actually has 7 words, since there is no space after the ".", so
we will assume the this to contain 6 separate…
arrow_forward
Lab 8 (TT3)
C for Loop (With Exam ples) X
9 (124) WhatsApp
My Questions |E
u/1/c/MTcyMjAyOTM×NzY4/a/M¡U5NZU2OTMYMJEY/details
vinah TV
Netflix
YouTube
AK Animekisa
Discord
Gmail
1
Calendar
Classroom
MMU PORTAL
DCP 5101 PROGRAM DESIGN
LAB 8
Open with
ARRAY
QUESTION 1
This program will calculate the average of quiz marks for students.
In main():
Declare an empty array called test for 4 students with 3 quizzes each.
Call function get_marks(...) and pass the test array as argument.
Use while loops:
dd
Calculate the total marks and average for each students.
Call function display(...) and pass the necessary arguments.
In function get_marks(...):
Use for loops to ask each user to enter their marks.
The marks are stored into the array.
In function display(...):
Print the average of each students.
(There are no loops here, just a print statement.)
hts
Sample Output
Student 1 :
Enter quiz 1 marks :
Enter quiz 2 marks : 8
Enter quiz 3 marks :
6.5
10
Student 2 :
Enter quiz 1 marks :
Enter quiz 2…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Related Questions
- Searching - a user should be able to search by ID or by item name create only one menu item for searching a user should be able to enter the name of the item using any case, (for example, sTRolleR) you may wish to store items in all lower/upper case to expedite the search write one search function that can search by ID and name and goes through the array of structs/objects only once show the entire record if found or an appropriate message if not Sorting - sort by any field write one function to sort by any field using a parallel array of pointers use Bubble Sort is not the most effective but the easiest to modify. do not copy and paste sort code five times into the same function. sorting using pointers is faster because you have to swap pointers only, which are normally stored in 4 bytes each; it also allows you to preserve the original order of the items If you choose to have a submenu, a submenu must have an option to go back to the previous menu or main menu if a user got…arrow_forwardQ.Create an interesting educational information chat box that asks the user to give an input question and then answers the question given by user with a suitable answer. You can make use of list for different questions and answers.Save two to three answers for a single question and then for random selection of elements from those answers use random choice(list) method from random module that returns a random element. Also for a user question that doesn't matches with the questions present in the chat box it should display statement like "oops i can't answer that" "sorry i am not intelligent enough" "could u please ask something else" using random method so that every time one of these statements appear **coding language python ***try using basic programming techniques in python without using arrays and pointers * * * copy paste the program itself and also the screenshot of program and output * * * use any type of data for questions such as name details of cities species etc depends on…arrow_forwardQ.Create an interesting educational information chat box that asks the user to give an input question and then answers the question given by user with a suitable answer. It should match the question of user with a suitable answer avaliable . You can make use of list for different questions and answers. (if possible) Save two to three answers for a single question and then for random selection of elements from those answers use random choice(list) method from random module that returns a random element. Also for a user question that doesn't matches with the questions present in the chat box it should display statement like "oops i can't answer that" "sorry i am not intelligent enough" "could u please ask something else" using random method so that every time one of these statements appear **coding language python ***try using basic programming techniques in python without using arrays and pointers * * * copy paste the program itself and also the screenshot of program and output…arrow_forward
- appropriate r code?arrow_forwardQ.Create an interesting educational information chat box that asks the user to give an input question and then answers the question given by user with a suitable answer. It should match the question of user with the answer avaliable. Make use of list for different questions and answers. (if possible) Save two to three answers for a single question and then for random selection of elements from those answers use random choice(list) method from random module that returns a random element. Also for a user question that doesn't matches with the questions present in the chat box it should display statement like "oops i can't answer that" "sorry i am not intelligent enough" "could u please ask something else" using random method so that every time one of these statements appear **coding language python ***try using basic programming techniques in python without using arrays and pointers * * * copy paste the program itself and also the screenshot of program and output * * * use any…arrow_forwardget_column_choice(): this function will allow us to ask the players which pocket they want to grab stones from. Since we know which row they are grabbing from (since it is not allowed to grab stones from your opponent’s side), we only need to get the column they want. As previously stated, we are using letters to represent the columns to make it easier on the player. This function accepts the current player (should be a 0 or 1), the board, and a list of letters (the same as the list you passed to the print_game_board function) and it will return the index of the column being chosen. The function should ask the player to enter a column letter, then it should check that the conditions listed below hold. If they don’t meet these conditions, it should ask again until it gets a valid letter, otherwise it should return the corresponding column index for that letter. Letter entered must be on the game board. It can be lower case or upper case. (Hint: this doesn’t need to be hard coded,…arrow_forward
- Activity Duration Predecessors A 2 B 10 A 1 D 7 В E B F 2 D, C G 10 А Using the above information, Insert the Early Start (ES), Early Finish (EF), Late Start (LS), Late Finish (LF) and Slack Time of the following specified nodes. (Only integer value, no decimal points. For example if your ans is 7.4 or 7.6 , insert 7 only) Activity ES EF LS LF Slack Time A E F Garrow_forwardNearest polygonal number def nearest_polygonal_number(n, s): Any positive integer s > 2 defines an infinite sequence of s-gonal numbers whose i:th element is given by the formula ((s-2)i2 - (s-4)i)/2, as explained on the Wikipedia page "Polygonal Number". In this formula, positions start from 1, not 0, and we use the letter i to denote the position since we will be using the letter n for something else. For example, the sequence of "octagonal numbers" that springs forth from s = 8 starts with 1, 8, 21, 40, 65, 96, 133, 176... Given the number of sides s and an arbitrary integer n, this function should return the s-gonal integer closest to n. If n falls exactly halfway between two s-gonal numbers, return the smaller one. As you can see from the last row of the previous table, this function must be efficient even for gargantuan values of n. The simplest way to make this function efficient is to harness the power of repeated halving to pull your wagon with a clever application of…arrow_forwardQ29:A teacher stores the most recent quiz scores for her class in the list scores. The first element in the list holds the maximum possible number of points that can be awarded on the quiz, and each remaining element holds one student’s quiz score. Assume that scores contains at least two elements. Which of the following code segments will set the variable found to true if at least one student scored the maximum possible number of points on the quiz and will set found to false otherwise?arrow_forward
- Sum of two squares def sum_of_two_squares(n): Some positive integers can be expressed as a sum of two squares of some positive integers greater than zero. For example, 74 = 49 + 25 = 7^2 + 5^2. This function should find and return a tuple of two positive integers whose squares together add up to n, or return None if the parameter n cannot be broken into a sum of two squares.To facilitate the automated testing, the returned tuple must present the larger of its two numbers first. Furthermore, if some integer can be broken down to a sum of squares in several ways, return the breakdown that maximizes the larger number. For example, the number 85 allows two such representations 7^2 + 6^2 and 9^2 + 2^2 , of which this function must return (9, 2).The technique of two approaching indices that start from the beginning and end of a sequence, respectively, and approach each other until they meet somewhere is directly applicable to this problem. In this problem, these indices crawl towards each…arrow_forwardcvcxvcvxvcvarrow_forwardNon dynamic.arrays are allocated at runtime where dynamic arrays are allocated at compile time. True False Question 4 There are other ways to end a loop other than just the loop condition evaluating to false. True Falsearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT