write a program to perform the following in C
In: Computer Science
Create two lists; one contains 5 elements and the other one is empty. Write a python program that iterates through the first one, pops the elements from the end of it, then it pushes them one by one to the empty list. As your program iterates through the first list, clean it before processing the data, meaning if any element is like a special character ( , . ; : ) it must be discarded and not gets pushed to the second list.
In: Computer Science
Bucket List
Many people have "Bucket Lists" - things that they want to experience/accomplish before they die. What are some of the things that are on your Bucket List? Why are these things important to you? How do those wishes reflect your developmental stage in life? Do you think they will change as you get older?
****If you have not seen the movie, The Bucket List, I highly suggest it!
In: Psychology
C++ only
Large Program
Create a magical creature (or monster) zoo inventory program that will allow a zookeeper to add magical creatures (either manually or from a file), delete a creature, and display all creatures in the zoo.
The zoo creatures will be organized in a linked list.
----------------------------------------------------------------------------
Zoo.cpp – this file will contain your main function that will allow the user to enter, delete, and print creatures. The main function will create the linked list of creatures.
Creature.h – class specification for the Creature class
Creature.cpp – class implementation for the Creature class
LinkedList.h – a Singly-Linked List template class that you create (DO NOT USE THE LIST CLASS PROVIDED IN THE STANDARD TEMPLATE LIBRARY). All the member functions should be defined in this file as well (either inline or below the class declaration).
creatureFile.txt – this is the text file that contains creature data in it. You should submit a file with at least five creatures/monsters.
----------------------------------------------------------------------------
Create a template class (LinkedList.h) that declares a singly-linked list. This template class should be able to create a linked list of any type of object.
LinkedList class should have the following attributes:
A structure (struct) ADT named ListNode, which defines a node with a value & a pointer to the next ListNode.
A pointer to a ListNode named head
A pointer to a ListNode named tail
An integer named numNodes
LinkedList class should have the following member functions:
Constructor – should initialize head & tail to point to nothing and initialize numNodes to zero
Destructor – like a “RemoveAll” function – should deallocate memory for all existing nodes
getLength – should return the number of nodes in the list
getNodeValue – this function accepts a position (integer) as a parameter and then returns the value (object) inside the node at that position
appendNode – this function accepts a value (object) as a parameter. It creates a new node at the end of the list with the sent object inside of it and increments the number of nodes. This function does not return anything.
deleteNode – this function accepts a position (integer) as a parameter, which indicates the position of the node to be deleted. It updates the links of the nodes on either side of this node to be deleted. Then it deletes the node. Then, it decrements the number of nodes.
----------------------------------------------------------------------------
Create a class specification (Creature.h) & class implementation (Creature.cpp) file for a class named Creature. The purpose of the Creature class is to allow for creation of a Creature object.
Creature should have the following attributes:
The creature’s name (string)
A description of the creature (string)
The cost (float) of the creature (per month) to care for it (food, grooming, destruction, etc)
A boolean representing whether the creature is dangerous or not (1 means true – it is dangerous and 0 means false, it is not dangerous)
Creatures should have the following member functions:
Constructor – default constructor (doesn’t have to have anything inside it)
Constructor with parameters – string, string, bool, & float – should initialize the creature’s attributes
Accessor functions
getName
getDescription
getDangerous
getCost
Mutator functions
setName
setDescription
setDangerous
setCost
printCreature – a function to print a single creature’s information to the screen in a nice, easy to read format
printCreatureToFile – a function to print a single creature’s information to the file – unformatted – one piece of information per line. This is so the program would be able to read the creature’s information back later.
----------------------------------------------------------------------------
This is the driver. This file should have a main function and several other functions to organize or help the main function as described below:
main – This function should create a creature linked list, based on the LinkedList template class you create. Then it should display a menu of four options until the user chooses option 4, which is to end the program. Look at sample output to see the flow of the program.
If user chooses option 1, then a sub-menu should be shown to ask user if they want to enter creatures manually or from file. If manually, then the enterMagicalCreature function should be called, sending the address of the creatureList to this function. If from a file, then the enterMagicalCreatureFromFile function should be called, sending the address of the creature list to this function.
If user chooses option 2, then the deleteCreature function should be called, sending the address of the creature list to this function.
If user choses option 3, then the printCreatures function should be called, sending the address of the creature list to this function.
If user chooses
option 4, then the program should ask the user if they want to save
their creature list to a file. If user chooses yes, then call the
saveCreaturesToFile function, sending the creature
list to this function. Print “GOODBYE!” before the program
ends.
enterMagicalCreature – this function should ask
the user for the creature’s name, description, if it is dangerous,
and the cost per month to care fo rhte creature. Then it should
create a new creature object with this data. Then, it should append
the creature object to the linked creature list. Then it should
print a confirmation that the creature (print creature’s name) has
been added to the zoo. The function should then ask the user if
they want to add more creatures. If they answer yes, then repeat
this process. Otherwise, the function should end and it doesn’t
return any data.
enterMagicalCreatureFromFile – this function
should ask the user for the name of the file they want to read
from. Then, if the file is able to be opened (print a message if
can’t be opened) then read the creature data from the file (one at
a time) with a loop and after reading in one creature, create a new
creature object with this data, then append the creature to the
creature linked list. After reading all the creatures from the file
& adding them to the linked list, print how many creatures FROM
THE FILE were added to the zoo. This may or may not be the current
number of creatures in the linked list! This function does not
return any data.
deleteCreature – this function should first print
a numbered list of the names of all the creatures in the linked
list. Then ask the user which creature number they want to delete.
Then the creature should be removed from the linked list. A
confirmation should be printed out that the creature was removed.
This function does not return anything.
printCreatures – this function should print “THERE
ARE NO CREATURES AT YOUR ZOO!” if there are no creatures in the
linked list. If there are creatures in the linked list then it
should print each creature’s detail in the list. This function does
not return anything.
saveCreaturesToFile – this function should either print “THERE ARE NO CREATURES AT YOUR ZOO!” if there are no creatures in the linked list. If there are creatures in the linked list then it should ask the user for the filename that they wish to use to save the creatures and then use a loop to get a creature from each node, and then call this creature’s printCreatureToFile function, sending the filename to the function.
--------------------------------------------------------------------------
In: Computer Science
In this assignment we are not allowed to make changes to Graph.h it cannot be changed! I need help with the Graph.cpp and the Driver.cpp.
Your assignment is to implement a sparse adjacency matrix data structure Graph that is defined in the header file Graph.h. The Graph class provides two iterators. One iterator produces the neighbors for a given vertex. The second iterator produces each edge of the graph once.
Additionally, you must implement a test program that fully exercises your implementation of the Graph member functions. Place this program in the main() function in a file named Driver.cpp.
The purpose of an iterator is to provide programmers a uniform way to iterate through all items of a data structure using a forloop. For example, using the Graph class, we can iterate thru the neighbors of vertex 4 using:
Graph::NbIterator nit ; for (nit = G.nbBegin(4); nit != G.nbEnd(4) ; nit++) { cout << *nit << " " ; } cout << endl ;
The idea is that nit (for neighbor iterator) starts at the beginning of the data for vertex 4 in nz and is advanced to the next neighbor by the ++ operator. The for loop continues as long as we have not reached the end of the data for vertex 4. We check this by comparing against a special iterator for the end, nbEnd(4). This requires the NbIterator class to implement the ++, !=and * (dereference) operators.
Similarly, the Graph class allows us to iterate through all edges of a graph using a for loop like:
Graph::EgIterator eit ; tuple<int,int,int> edge ; for (eit = G.egBegin() ; eit != G.egEnd() ; eit++) { edge = *eit ; // get current edge cout << "(" << get<0>(edge) << ", " << get<1>(edge) << ", " << get<2>(edge) << ") " ; } cout << endl ;
Note that each edge should be printed only once, even though it is represented twice in the sparse adjacency matrix data structure.
Since a program may use many data structures and each data structure might provide one or more iterators, it is common to make the iterator class for a data structure an inner class. Thus, in the code fragments above, nit and eit are declared asGraph::NbIterator and Graph::EgIterator objects, not just NbIterator and EgIterator objects.
Here are the specifics of the assignment, including a description for what each member function must accomplish.
Requirement: your implementation must dynamically resize the m_nz and m_ci arrays. See the descriptions of Graph(constructor) and addEdge, below.
Requirement: other than the templated tuple class, you must not use any classes from the Standard Template Library or other sources, including vector and list. All of the data structure must be implemented by your own code.
Requirement: your code must compile with the original Graph.h header file. You are not allowed to make any changes to this file. Yes, this prevents you from having useful helper functions. This is a deliberate limitation of this project. You may have to duplicate some code.
Requirement: a program fragment with a for loop that uses your NbIterator must have worst case running time that is proportional to the number of neighbors of the given vertex.
Requirement: a program fragment with a for loop that uses your EgIterator must have worst case running time that is proportional to the number of vertices in the graph plus the number of edges in the graph.
Graph.h:
#ifndef _GRAPH_H_
#define _GRAPH_H_
#include <stdexcept> // for throwing out_of_range exceptions
#include <tuple> // for tuple template
class Graph {
public:
// Graph constructor; must give number of vertices
Graph(int n);
// Graph copy constructor
Graph(const Graph& G);
// Graph destructor
~Graph();
// Graph assignment operator
const Graph& operator= (const Graph& rhs);
// return number of vertices
int numVert();
// return number of edges
int numEdge();
// add edge between u and v with weight x
void addEdge(int u, int v, int x);
// print out data structure for debugging
void dump();
// Edge Iterator inner class
class EgIterator {
public:
// Edge Iterator constructor; indx can be used to
// set m_indx for begin and end iterators.
EgIterator(Graph *Gptr = nullptr, int indx = 0);
// Compare iterators; only makes sense to compare with
// end iterator
bool operator!= (const EgIterator& rhs);
// Move iterator to next printable edge
void operator++(int dummy); // post increment
// return edge at iterator location
std::tuple<int,int,int> operator*();
private:
Graph *m_Gptr; // pointer to associated Graph
int m_indx; // index of current edge in m_nz
int m_row; // corresponding row of m_nz[m_indx]
};
// Make an initial edge Iterator
EgIterator egBegin();
// Make an end iterator for edge iterator
EgIterator egEnd();
// Neighbor Iterator inner class
class NbIterator {
public:
// Constructor for iterator for vertices adjacent to vertex v;
// indx can be used to set m_indx for begin and end iterators
NbIterator(Graph *Gptr = nullptr, int v = 0, int indx = 0);
// Compare iterators; only makes sense to compare with
// end iterator
bool operator!=(const NbIterator& rhs);
// Move iterator to next neighbor
void operator++(int dummy);
// Return neighbor at current iterator position
int operator*();
private:
Graph *m_Gptr; // pointer to the associated Graph
int m_row; // row (source) for which to find neighbors
int m_indx; // current index into m_nz of Graph
};
// Make an initial neighbor iterator
NbIterator nbBegin(int v);
// Make an end neighbor iterator
NbIterator nbEnd(int v);
private:
int *m_nz; // non-zero elements array
int *m_re; // row extent array
int *m_ci; // column index array
int m_cap; // capacity of m_nz and m_ci
int m_numVert; // number of vertices
int m_numEdge; // number of edges
};
#endifIn: Computer Science
I want the linked list to be inserted by the user and donot use getline to insert it
#include <bits/stdc++.h>
using namespace std;
// A linked list Node
struct Node {
int data;
struct Node* next;
};
// Size of linked list
int size = 0;
// function to create and return a Node
Node* getNode(int data)
{
// allocating space
Node* newNode = new Node();
// inserting the required data
newNode->data = data;
newNode->next = NULL;
return newNode;
}
// function to insert a Node at required position
void insertPos(Node** current, int pos, int data)
{
// This condition to check whether the
// position given is valid or not.
if (pos < 1 || pos > size + 1)
cout << "Invalid position!" << endl;
else {
// Keep looping until the pos is zero
while (pos--) {
if (pos == 0) {
// adding Node at required position
Node* temp = getNode(data);
// Making the new Node to point to
// the old Node at the same position
temp->next = *current;
// Changing the pointer of the Node previous
// to the old Node to point to the new Node
*current = temp;
}
else
// Assign double pointer variable to point to the
// pointer pointing to the address of next Node
current = &(*current)->next;
}
size++;
}
}
// This function prints contents
// of the linked list
void printList(struct Node* head)
{
while (head != NULL) {
cout << " " << head->data;
head = head->next;
}
cout << endl;
}
// Driver Code
int main()
{
// Creating the list 3->5->8->10
Node* head = NULL;
head = getNode(3);
head->next = getNode(5);
head->next->next = getNode(8);
head->next->next->next = getNode(10);
size = 4;
cout << "Linked list before insertion: ";
printList(head);
int data = 12, pos = 3;
insertPos(&head, pos, data);
cout << "Linked list after insertion of 12 at position 3: ";
printList(head);
// front of the linked list
data = 1, pos = 1;
insertPos(&head, pos, data);
cout << "Linked list after insertion of 1 at position 1: ";
printList(head);
// insetion at end of the linked list
data = 15, pos = 7;
insertPos(&head, pos, data);
cout << "Linked list after insertion of 15 at position 7: ";
printList(head);
return 0;
}
In: Computer Science
Three sections of Econ 002 have 50, 50, and 100 students. Find the simple average and the weighted average. Include the units in your answer if this is an absolute measure.
In: Finance
In more than 800 words, Demonstrate with practical examples how students’ knowledge in the following concepts could lead to increase in organizational performance:
a) Personality
b) Leadership
In: Accounting
I need more 10 pages research governmental fraud nicely and clearly. Do not provide me the others students paper. I need solid and nice.
In: Accounting
1. Suppose a sample of 30 students take an IQ test. If the sample has a standard deviation of 12.23, find a 90% confidence
interval for the population standard deviation.
In: Statistics and Probability