DATA STRUCTURES
What is returned when calling this method with the singly list contains (1,5,5,7,8)
public static int m1(SinglyList list1)
{
if(list1.size()!=2)
return list1.removeFirst()+m1(list1);
return s;
}
In: Computer Science
1. Suppose that you want to program an AI agent to navigate out of a maze. The agent starts at the maze’s center facing the north direction. The agent can turn to face the south, north, east, or west. The agent can be directed to move forward for a certain distance but will stop before hitting a wall.
a) Formulate this as a search problem defining initial state, goal test, transition function, and cost function.
b) What can you tell about the size of the state space?
c) In maze navigation, it is only necessary to turn at the intersection of two or more corri-dors. Using this observation, reformulate the search problem. What can you say about the size of the state space now?
d) What simplifications or abstractions about the real world, actions, or details did we make in our problem formulation? List three of this simplifications and briefly discuss how realistic they are. For example, we assume that the agent can move as far as it can without battery charging.
In: Computer Science
Explain the concept of information systems planning.
Compare at least two development planning methods.
Clarify why each planning method is appropriate for new system implementation
In: Computer Science
Programming
How does readability can affect cost?
In: Computer Science
IN JAVA: Build a class called ExamPractice from scratch. This class should include a main method that does the following:
For example, if a user entered 100000 inches, the program would output:
100000 inches is equivalent to:
Miles: 1
Yards: 1017
Feet: 2
Inches: 4
In: Computer Science
CODE IN C++ PLEASE
When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making periodic payments over a certain period of time. Of course, the lending company will charge interest on the loan. Every periodic payment consists of the interest on the loan and the payment toward the principal amount. To be specific, suppose that you borrow $1,000 at an interest rate of 7.2% per year and the payments are monthly. Suppose that your monthly payment is $25. Now, the interest is 7.2% per year and the payments are monthly, so the interest rate per month is 7.2/12 = 0.6%. The first month’s interest on $1,000 is 1000 X 0.006 = 6. Because the payment is $25 and the interest for the first month is $6, the payment toward the principal amount is 25 - 6 = 19. This means after making the first payment, the loan amount is 1,000 - 19 = 981. For the second payment, the interest is calculated on $981. So the interest for the second month is 981 X 0.006 = 5.886, that is, approximately $5.89. This implies that the payment toward the principal is 25 - 5.89 = 19.11 and the remaining balance after the second payment is 981 - 19.11 = 961.89. This process is repeated until the loan is paid. Instructions Write a program that accepts as input: The loan amount The interest rate per year The monthly payment. (Enter the interest rate as a percentage. For example, if the interest rate is 7.2% per year, then enter 7.2.) The program then outputs the number of months it would take to repay the loan. (Note that if the monthly payment is less than the first month’s interest, then after each payment, the loan amount will increase.) In this case, the program must warn the borrower that the Monthly payment is too low. The loan cannot be repaid. Since your program handles currency, make sure to use a data type that can store decimals with a decimal precision of 2.
In: Computer Science
1. Answer “True” or “False”.
(a) A doubly linked list structure is worse than a singly linked list if we plan to do a lot of insertions.
(b) A doubly linked list structure is worse than a singly linked list if we plan to do a lot of deletions.
(c) A doubly linked list structure is worse than a singly linked list if we plan to print the entire list frequently.
(d) An array implementation of a queue is more difficult to manage than the array implementation of a stack.
Solution:
In: Computer Science
JAVA program to simulate a customer’s online grocery shopping. The customer will shop fruit and vegetable each week online. The customer will select one vegetable and one fruit from the Table 1 and 2 respectively.
The program that is needed for the online ordering system will allow the customer to place a single order, calculating subtotals, additional fee, and outputting a shopping summary. When completing an order, an itemized summary is to be displayed. This bill should include a 3.5% service rate and flat fee of $5 for delivery should be added after the service fee has been applied to the bill.
Vegetable Name |
Price Per Pound |
Broccoli |
$3.12 |
Yellow Onion |
$1.15 |
Chili Pepper |
$4.58 |
Greens Bundle |
$2.82 |
Table 1: Vegetable names with corresponding price per pound
Fruit Name |
Price Per Pound |
Apple |
$1.73 |
Grape |
$2.15 |
Key Lime |
$2.58 |
Navel Orange |
$1.86 |
Table 2: Fruit names with corresponding price per pound
The main requirement of this program that is different from your earlier assignments is that you are required to create 2 different Java classes in the design of your program. Here are some other design details that may be helpful:
Design:
The classes should be placed in a package with the name edu.ilstu
The GroceryShopping class should have proper Javadoc comments
The GroceryShopping class
Keeps track of the information for 1 order. Write the class GroceryShopping that has the following fields:
Instance Variables:
Named Constants
Methods:
Additional fee = subtotal * service rate + delivery fee
GroceryShoppingApp class:
This is the starting point for the application which is the only class to contain a main method. You will use the GroceryShopping class here. For this program, the main method handles all of the input and output for the program and will perform the following tasks:
Input:
Output:
Print the title, a line with the selected vegetable and the number of pounds purchased, a line with the selected fruit and the number of pounds purchased, a subtotal of the cost of the items ordered, additional fee, and the total bill.
In: Computer Science
In: Computer Science
// ==== Challenge 1: Write your own closure ====
// Write a closure of your own creation.
// Keep it simple! Remember a closure is just a function
// that manipulates variables defined in the outer scope.
// The outer scope can be a parent function, or the top level of the script.
/* STRETCH PROBLEMS, Do not attempt until you have completed all previous tasks for today's project files */
// ==== Challenge 2: Implement a "counter maker" function ====
const counterMaker = () => {
// IMPLEMENTATION OF counterMaker:
// 1- Declare a `count` variable with a value of 0. We will be mutating it, so declare it using `let`!
// 2- Declare a function `counter`. It should increment and return `count`.
// NOTE: This `counter` function, being nested inside `counterMaker`,
// "closes over" the `count` variable. It can "see" it in the parent scope!
// 3- Return the `counter` function.
};
// Example usage: const myCounter = counterMaker();
// myCounter(); // 1
// myCounter(); // 2
// ==== Challenge 3: Make `counterMaker` more sophisticated ====
// It should have a `limit` parameter. Any counters we make with `counterMaker`
// will refuse to go over the limit, and start back at 1.
// ==== Challenge 4: Create a counter function with an object that can increment and decrement ====
const counterFactory = () => {
// Return an object that has two methods called `increment` and `decrement`.
// `increment` should increment a counter variable in closure scope and return it.
// `decrement` should decrement the counter variable and return it.
};
In: Computer Science
Describe the following disk concepts or compo- nents.
a. Platter and recording surface. b. Track. c. Cylinder. d.
Read/write head.
e. Access-arm mechanism.
In: Computer Science
I'm confused about upper bound and worst case are different. Can you provide an explanation/examples to help me separate these two concepts in my mind?
In: Computer Science
The decimal value of ‘252’ has which of the following hexadecimal value: (choose one and explain)
2) If the following are using default subnet masks, which one(s) of the following are valid node IP addresses: (select one and explain)
a) 220.1.1.255 b) 10.10.0.10 c) 208.5.48.0 d) 1.255.255.255
3) Which of the following are valid Private IP addresses? (Select all Valid choices)
Private IP address is an address that is reserved for internal use behind a router.
In: Computer Science
c++ question
Question 2: X = 7777
Modify the code below and use conditional branching (if, else,
etc.)
to print the following:
if X is between 0 and 33333 then print the word: red
if X is between 33334 and 66666 then print the word: blue
if X is between 66667 and 99999 then print the word: green
if none of the above condition matches then print the word:
white
In: Computer Science
Suppose you are writing a program to compute the semester GPA for a person based on knowing the grades earned and the number of credit hours for each course taken.
What type of tests would you need to create to check that your program was working correctly? Be specific, and remember to keep in mind tests that might contain unexpected input. How would your program react to those?
After you have made your post, you need to provide thoughtful comments on at least two other posts (or replies).
Your original post is due Sep 8; your replies are due Sep 11.
In: Computer Science