Consider the following definition of a doubly linked-list:
class LinkedList{
public:
LinkedList():head(0), tail(0){}
~LinkedList();
void reverse();
//reverses the order of elements in the linked list
void insert(int value);
private:
struct Node{
int data;
Node* next;
Node* prev;
};
Node* head;
Node* tail;
//Add your helper function here that recursively reverses the order of elements in the linked list
};
Write the declaration of a helper function in the class provided above that recursively reverses the order of elements in the linked list. This function will be used by the reverse() method. Then, write the implementation of both the reverse() method and the helper function.
In: Computer Science
C++ Linked Lists
Practice your understanding of linked lists in C++ by creating a list of songs/artist pairs. Allow your user to add song / artist pairs to the list, remove songs (and associated artist) from the list and be sure to also write a function to print the list! Have fun!
Make sure you show your implementation of the use of vectors in this lab (You can use them too )
You MUST modularize your code ( meaning, there must be functions written for each piece of functionality that you write... at the very least: add(), delete(), print() and main() functions should be obvious.
Thanks!!
In: Computer Science
Python 3.7.4
Costume = {'label': str, 'price': int, 'sizes': [str]}
''' C5. Define a function `most_expensive_costume` that consumes a list of costumes and produces a string representing the label of the costume with the highest price. In the event of a tie, give the label of the item later in the list. If there are no costumes, return the special value None. '''
''' C6. Define a function `find_last_medium` that consumes a list of costumes and produces the label of the last costume that is available in a medium. If no medium costumes are found, produce the special value `None`. '''
''' C7. Define a function `find_first_small` that consumes a list of costumes and produces the label of the first costume that is available in a small. If no small costumes are found, produce the special value `None`. '''
In: Computer Science
1. All social groups and families can be considered speech
communities meaning they have their own unique language. Reflect on
the words you use in your groups of friends, coworkers, clubs, etc.
and create a list of 15 WORDS that make up your own language.
Discuss the origins of these words in your language and provide a
definition for each of the words on the list. Internet, texting
jargon, and acronyms can apply to this activity.
LIST of 15 WORDS:
2. Consider the following quote, “Meaning is in people not words.”
Describe the words on your list and how they relate to this quote.
What happens when you use these words in other groups?
In: Psychology
All social groups and families can be considered speech communities meaning they have their own unique language. Reflect on the words you use in your groups of friends, coworkers, clubs, etc. and create a list of 15 WORDS that make up your own language. Discuss the origins of these words in your language and provide a definition for each of the words on the list. Internet, texting jargon, and acronyms can apply to this activity. LIST of 15 WORDS:
2. Consider the following quote, “Meaning is in people not words.” Describe the words on your list and how they relate to this quote. What happens when you use these words in other groups?
In: Psychology
*****************PLEASE GIVE THE CODE IN RACKET PROGRAMMING ONLY AND MAKE SURE THE CODE RUNS ON WESCHEME IDE***************
Write a recursive Racket function "keep-short-rec" that takes an integer and a list of strings as parameters and evaluates to a list of strings. The resulting list should be all of the strings from the original list, maintaining their relative order, whose string length is less than the integer parameter. For example, (keep-short-rec 3 '("abc" "ab" "a")) should evaluate to '("ab" "a") because these are the only strings shorter than 3. Your solution must be recursive. Note: (string-length s) evaluates to the length of string s
In: Computer Science
(1) Prompt the user to enter four numbers, each corresponding to
a person's weight in pounds. Store all weights in a list. Output
the list. (2 pts)
Ex:
Enter weight 1: 236 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3]
(2) Output the average of the list's elements. (1 pt)
(3) Output the max list element. (1 pt)
Ex:
Enter weight 1: 236 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3] Average weight: 166.95 Max weight: 236.0
(4) Prompt the user for a number between 1 and 4. Output the
weight at the user specified location and the corresponding value
in kilograms. 1 kilogram is equal to 2.2 pounds. (3 pts)
Ex:
Enter a list index (1 - 4): 3 Weight in pounds: 176.0 Weight in kilograms: 80.0
(5) Sort the list's elements from least heavy to heaviest
weight. (2 pts)
Ex:
Sorted list: [89.5, 166.3, 176.0, 236.0]
This is what I have so far:
# FIXME (1): Prompt for four weights. Add all weights to a list.
Output list.
weights = []
for i in range(4):
w = float(input("Enter weight "+str(i+1)+":"))
weights.append(w)
print("\nWeights:",weights)
# FIXME (2): Output average of weights.
avg = sum(weights) / float(len(weights))
print("Average weight:",avg)
# FIXME (3): Output max weight from list.
print("Max weight:",max(weights))
# FIXME (4): Prompt the user for a list index and output that
weight in pounds and kilograms.
index = int(input("\nEnter a list index location (1 - 4):
\n"))
print("Weight in pounds:",weights[index-1])
print("Weight in Kilograms:",weights[index-1]/2.2)
# FIXME (5): Sort the list and output it.
weights.sort()
print("\nSorted list:",weights)
Your output starts with
Enter weight 1:
Weights: [236.0]
Enter weight 2:
Weights: [236.0, 89.5].
Enter weight 3:
Weights: [236.0, 89.5, 176.0]
Enter weigt 4:
Weights: [236.0, 89.5, 176.0, 166.3]
Expected output starts with
Enter weight 1:
Enter weight 2:
Enter weight 3:
Enter weight 4:
Weights: [236.0, 89.5, 176.0, 166.3]
How do I fix this!?
In: Computer Science
I need some asistance understanding of what to do for this problem in javascript:
* Problem 9 - find the largest number in the list of arguments
*
* Allow any number of arguments to be passed to the function. Allow both
* String and Number arguments to be passed, but throw an error if any other
* type is passed to the function (e.g., Boolean, Date, etc.). If the list
* is empty (nothing passed to the function), return null. Otherwise, return
* the largest value that was passed to the function as an argument:
*
* findLargest(1, 2, '3', '4', 5) should return 5
* findLargest('5') should also return 5
* findLargest(5, 3, 2, 1) should also return 5
******************************************************************************/
function findLargest() {
// Your code here...
}
here are the test cases:
const { findLargest } = require('./solutions');
describe('Problem 9 - findLargest', function() {
test('should find the largest number in a list', function() {
let largest = findLargest(1, 2, 3);
expect(largest).toBe(3);
});
test('should find the largest number in a list of 1', function() {
const largest = findLargest(1);
expect(largest).toBe(1);
});
test('should find the largest number in a long list', function() {
// https://github.com/gromgit/jstips-xe/blob/master/tips/33.md
const list = Array.apply(null, { length: 5000 }).map(Function.call, Number);
const largest = findLargest.apply(null, list);
expect(largest).toBe(4999);
});
test('should work with negative numbers', function() {
const largest = findLargest(1, 2, 3, -1, -2, -3);
expect(largest).toBe(3);
});
test('should work with strings that are numbers', function() {
const largest = findLargest('1', '2', '3');
expect(largest).toBe(3);
});
test('should work with decimals', function() {
const largest = findLargest(0.01, 0.001);
expect(largest).toBe(0.01);
});
test('should throw if a Boolean is included in the list', function() {
function shouldThrow() {
findLargest(1, true, 3);
}
expect(shouldThrow).toThrow();
});
test('should throw if an Object is included in the list', function() {
function shouldThrow() {
findLargest(1, console, 3);
}
expect(shouldThrow).toThrow();
});
test('should throw if a null is included in the list', function() {
function shouldThrow() {
findLargest(1, null, 3);
}
expect(shouldThrow).toThrow();
});
test('should throw if a undefined is included in the list', function() {
function shouldThrow() {
findLargest(1, undefined, 3);
}
expect(shouldThrow).toThrow();
});
test('should return null if the list is empty', function() {
const largest = findLargest();
expect(largest).toBe(null);
});
});
In: Computer Science
In: Accounting
1. Two samples of a low hardness steel were tested using a Rockwell C hardness tester and the Rockwell B scale at the same lab on the same day. The difference between the average hardness of the two samples was 0.5 Rockwell C. Do you think there is a significant difference in the hardness? Justify your answer.
2. Two manufacturers produce a steel. Manufacturer B claims their steel is better than manufacturer A because their average Rockwell B hardness is 68.4 HRBW while that of manufacturer B is 60.5 HRBW. Do you think there is a significant difference in their hardness? Justify your answer. Hint: Use the specification!!
3. Find an important engineering failure that involves some of the topics discussed in MSE 350. Describe the failure, why it occurred, the damage (human, environmental, and economic) and the changes that could have been made in the design to avoid the failure. Was the failure caused by lack of engineering knowledge at the time, engineering error, or management/government error? Discuss!!
4.
For each of the following common items, identify what they are commonly made of, the material type (composite, metal, semiconductor, polymer <thermoplastic, thermoset or elastomer>, ceramic, glass. Describe why that material type is used. Include at least two references for your answers (websites are fine, but try and find good ones). If more than one material type is used in the items, include them all! Be careful to use proper engineering vocabulary when answering this question!
Abrasives for grinding metal
Automobiles
Integrated circuits
Airplanes
Bridges
Solar panels
Latex paint
Soda bottles
Polyvinylchloride (PVC) plumbing pipes
In: Mechanical Engineering