Questions
List all the eras of music and the years that they range from. List the characteristics...

List all the eras of music and the years that they range from. List the characteristics that make up each period, and two famous composers from each era.

In: Psychology

In this homework, you will implement a single linked list to store a list of employees...

In this homework, you will implement a single linked list to store a list of employees in a company. Every employee has an ID, name, department, and salary. You will create 2 classes: Employee and EmployeeList. Employee class should have all information about an employee and also a “next” pointer. See below:

Employee

Type

Attribute

int

ID

string

name

string

department

int

salary

Employee*

next

Return Type

Function

(constructor)

Employee(int ID, string name, string department, int salary)

EmployeeList class should have a head pointer and a size as attributes. The head pointer points to list of the employee nodes. In the class, following member functions should be implemented:

EmployeeList

Type

Attribute

Employee*

head

int

size

Return Type

Function

(constructor)

EmployeeList()

void

addEmployee(int ID, string name, string department, int salary)

void

removeEmployee(int ID)

void

print()

void

print(string department)

void

print(int ID)

int

getSize()

bool

isEmpty()

addEmployee (): Adds a new employee to the list. The new employee is placed based on his/her salary from lowest to highest. For example, if you have following three employees:

A new employee, “11 / Mike / Marketing / $65000” will be placed between Jim and John since his salary is more than $50000 and less than $70000.

removeEmployee(): This functions will remove the employee using by his/her ID. If the given ID number is not in the list, it will give an error.

print(): Prints all employees in (salary) order. ID, name, department, and salary should be printed for each employee.

print(string department): Prints all employees whose department matches with the user input department.

print(int ID): Prints the employee with given input ID.

getSize(): returns the number of employees in the list.

isEmpty(): returns true if list is empty, returns false otherwise.

The main program is provided for you. So you will only implement the Employee and EmployeeList classes. I expect you to have 2 files: EmployeeList.h and EmployeeList.cpp. Employee class definition should be in the EmployeeList.h file.

main.cpp includes all necessary functions to read the dataset file (dataset.txt). Also, several test cases are prepared for you to see whether your code is running or not. You do not need to change any code in the main.cpp file.

In: Computer Science

numUnique returns the number of unique values the list * Precondition: the list is not empty...

numUnique returns the number of unique values the list * Precondition: the list is not empty and is sorted from low to high. * { your solution can assume this is true } * * For full credit, your solution must go through the list exactly once. * Your solution may not call any other functions. * * Examples: * { abcdef }.numUnique() == 6 * { aaabcd }.numUnique() == 4 * { bccddee }.numUnique() == 4 * { abcddd }.numUnique() == 4 * { a }.numUnique() == 1

FOR JAVA

In: Computer Science

Assignment: The Ordered List In this assignment, you will create an ordered list of movies. The...

Assignment: The Ordered List

In this assignment, you will create an ordered list of movies. The list will always be maintained in sorted order (ascending order, by movie title) by assuring that all new movies are inserted in the correct location in the list.

Create a new project to hold your implementation of an ordered singly-linked list. You will need a main.cppto use as a test driver, as well as header and implementation files as described below.

Movie

To represent movies for this assignment, create a library implementing a structure Movie. Use the files Movie.h and Movie.cpp to implement the movie library. The class definition is shown below:

struct Movie {
    std::string title;              /// Movie title
    unsigned short year;            /// Movie release year
    std::string director;           /// Director's name
    std::string rating;             /// Movie audience rating

    Movie( std::istream& infile );  /// construct given an input stream
    void write( std::ostream& outfile ) const;
};
std::ostream& operator<<( std::ostream& outfile, const Movie& movie );

Use the Item structure you created in lab as a guide for implementing the write() method and overloaded stream insertion operator for Movie. Movies should be written a format matching the following example:

Blade Runner 2049 (2017) R - Denis Villeneuve

Where “Blade Runner 2049” is the movie title, 2017 is the release year, the director’s name is “Denis Villeneuve”, and the audience rating is “R” (info from imdb.com).

The Movie constructor takes an input stream and reads the values for the movie from that input stream, provided they are in the following format:

Blade Runner 2049|2017|Denis Villeneuve|R

Specifically, the values for each attribute are provided in the order they are listed in the class (title, year, director, rating), and fields are separated by a vertical bar (“pipe”) symbol. You may assume the rating will be followed by the end of a line or end-of-file.

MovieNode

Create a library to represent a singly-linked list node that will contain a Movie as its payload. Call the node class MovieNode. Use the files MovieNode.h and MovieNode.cpp to implement the MovieNode library.

Use the ItemNode class you implemented in lab as a guide to create MovieNode; it should implement all the same functionality.

MovieNode Constructor
The constructor for MovieNode will need to use member initializer list syntax to sink the value of the Movieparameter into its payload attribute. See (http://en.cppreference.com/w/cpp/language/initializer_list). The reason for this is that unlike the Item you created in lab, the Movie structure does not have a default constructor. By the time the body of the MovieNode constructor begins executing, C++ requires that all members of the object must be fully constructed. But, since Movie does not have a default constructor, there is no way for it to be fully constructed before the MovieNode constructor begins to execute — except that a member initializer list is evaluated before the constructor itself begins executing! So, this solves the timing problem without requiring you to modify the Movie definition.

MovieNode Comparisons
When we create the method to insert in order to our list, it will be necessary to compare the titles stored in two nodes to find the correct location for an addition to take place. For convenience, we can overload the “less than” operator for the nodes themselves to perform this comparison. Add the following method to the MovieNode class:

bool operator < ( const MovieNode& rhs ) const;

This method will compare the title of the Movie it contains with the title contained in rhs’s Movie. The operator<() method should return true or false based on the comparison of the titles.

OrderedMovieList

Create a library to represent an ordered singly-linked list of movies called OrderedMovieList. Use the files OrderedMovieList.h and OrderedMovieList.cpp to implement the library. The class OrderedMovieList should follow the basic outline of the unordered list you created in lab. It will need a head pointer, but not a tail pointer (a tail isn’t useful for ordered lists). Also create implementations for write(), erase(), remove_front(), destructor, and an overloaded stream-insertion operator based on the ones you had in the unordered list class.

Implement an is_empty() method that will return true if the list is empty, or false otherwise.

Implement a method insert() which will insert a new Movie into the list while maintaining the order of the list; “order” will be defined here as alphabetical order by title. The insert() method must take a Movieas its only parameter, and will not return any value.

Complete method insert() to put the Movie (we’ll refer to it as new_movie here) in place. An overview of the algorithm is shown below.

   * create new node containing new_movie
   * initialize "current" & "previous" pointers for list traversal
   * while correct location not yet found
      * move on to next location to check
   * insert new_movie at correct location (2 cases: "at head" or "not at head")

Add the code shown below to function main() and use it to test the new methods. An input file movies.txt is provided as a resource with this assignment. Be sure to try adding different movies to movies.txt to be sure your implementation works in all possible cases.

OrderedMovieList movie_list;
std::ifstream    movie_db {"movies.txt"};
if( movie_db ) {
    while ( movie_db.good() ) {
      movie_list.insert( Movie{movie_db} ); 
    }
    movie_db.close();
    cout << "Alphabetical listing of movies available:\n"
         << movie_list << "\n\n";
}
else{
    cout << "file not found!\n";
}

Note that this class must not expose public methods similar to add_front() and add_back() as the consistency or integrity of the list object’s data could be compromised by their use — write a comment block in the class definition for OrderedMovieList that explains how. These two methods could be implemented as private, but there is little value in doing so.

In: Computer Science

Below is a list of pairs of compounds. Choose the pairs from the list that would...

Below is a list of pairs of compounds. Choose the pairs from the list that would NOT form a precipitate if mixed together.

a. KCl and Na3PO4

b. Ca(NO3)2 and MgSO4

c. FeCl3 and LiOH

d. CuSO4 and (NH4)3PO4

e. sodium nitrate and calcium chloride

f. sodium sulfate and barium nitrate

g. zinc nitrate and potassium sulfate

h. lead(II) nitrate and sodium carbonate

i. potassium phosphate and cobalt(II) chloride

j. copper(I) nitrate and magnesium chloride

In: Chemistry

What is a neuromuscular junction? List and describe the junction. List and describe the roles of...

What is a neuromuscular junction? List and describe the junction. List and describe the roles of the chemicals involved at that site

In: Anatomy and Physiology

Given the list values = [], write code that fills the list with each set of...

  1. Given the list values = [], write code that fills the list with each set of numbers below. Note: use loops if it is necessary
  1. 1 2 3 4 5 6 7 8 9 10
  2. 0 2 4 6 8 10 12 14 16 18 20
  3. 1 4 9 16 25 36 49 64 81 100
  4. 0 0 0 0 0 0 0 0 0 0
  5. 1 4 9 16 9 7 4 9 11
  6. 0 1 0 1 0 1 0 1 0 1
  7. 0 1 2 3 4 0 1 2 3 4

2. Write a function that takes a tuple as an argument and returns the tuple sorted.

3. Write a statement that creates a dictionary containing the following key-value pairs:

'a' : 1

'b' : 2

'c' : 3

4. After the following code executes, what elements will be members of set3, ?

set1 = set([10, 20, 30, 40])

set2 = set([40, 50, 60])

set3 = set1.union(set2)

set4 = set1.intersection(set2)

set5= set1.difference(set2)

In: Computer Science

List the three phases of matter in order of the distance between the particles. List the...

List the three phases of matter in order of the distance between the particles. List the properties of each phase. Explain what causes matter to change states.

In: Physics

What are the advantages and disadvantages of the list box? when should a list box be...

What are the advantages and disadvantages of the list box? when should a list box be used? Describe some guidelines for when to use a list box.

In: Computer Science

Complete the code(in C) that inserts elements into a list. The list should always be in...

Complete the code(in C) that inserts elements into a list. The list should always be in an ordered state.

#include <stdio.h>
#include <stdlib.h>

/* list of nodes, each with a single integer */
struct element {
struct element *next;
int value;
};

/* protypes for functions defined after main */
struct element *elementalloc(void);
struct element *listinitialize();
struct element *insertelement(struct element *, int);
void printlist(struct element *);

/* main
* Creates an ordered list
* Elements added to the list must be inserted maintaining the list
* in an ordered state
*/
int main() {
struct element *listhead = NULL;
listhead = listinitialize();
for (int i = 3; i < 100; i+=11){
listhead = insertnewelement(listhead, i);
}
printlist(listhead);
}

/* allocate memory for a new list element */
struct element *elementalloc(void) {
return (struct element *)malloc(sizeof(struct element));
}

/* simple list initialization function */
struct element *listinitialize() {
const int numbers[7] = {4, 9, 13, 18, 27, 49, 60};
struct element *newlist = NULL;
struct element *tail = NULL;
struct element *temp = NULL;
for (int i = 0; i < 7; i++) {
if (newlist == NULL) {
newlist = elementalloc();
newlist->next = NULL;
newlist->value = numbers[i];
tail = newlist;
} else {
temp = elementalloc();
temp->value = numbers[i];
temp->next = NULL;
tail->next = temp;
tail = tail->next;
}
}
return newlist;
}

/* function to insert elements into an ordered list */
struct element *insertnewelement(struct element *listhead, int x) {
struct element *newelement;
newelement = elementalloc();

struct element *iter = listhead;
while( ) {

}

return listhead;
}

/* print the list and the respective memory locations in list order */
void printlist(struct element *listhead)
{
while (listhead != NULL) {
printf("Memory: %p contains value: %d\n", listhead, listhead->value);
listhead = listhead->next;
}
}

In: Computer Science