Using the C++ programming language1. Implement the UnsortedList cl.pdfmallik3000
Using the C++ programming language
1. Implement the UnsortedList class to store a list of numbers that are input into the list from
data.txt.
- create a main.cpp file that gets the numbers from the file
- insert the number 7 into the list
- insert another number 300 into the list
- delete the number 6 from the list
- print out the following:
--the entire list
- the greatest
- the least
2. Attach the main.cpp, UnsortedList.cpp, the ItemType.h, and the output file two called
outfile2.txt
Use the files below:
// listDriver.cpp
// Test driver
#include
#include
#include
#include
#include
#include \"unsorted.h\"
using namespace std;
void PrintList(ofstream& outFile, UnsortedType& list);
int main()
{
ifstream inFile; // file containing operations
ofstream outFile; // file containing output
string inFileName; // input file external name
string outFileName; // output file external name
string outputLabel;
string command; // operation to be executed
int number;
ItemType item;
UnsortedType list;
bool found;
int numCommands;
// Prompt for file names, read file names, and prepare files
cout << \"Enter name of input command file; press return.\" << endl;
cin >> inFileName;
inFile.open(inFileName.c_str());
cout << \"Enter name of output file; press return.\" << endl;
cin >> outFileName;
outFile.open(outFileName.c_str());
cout << \"Enter name of test run; press return.\" << endl;
cin >> outputLabel;
outFile << outputLabel << endl;
if (!inFile)
{
cout << \"file not found\" << endl;
exit(2)
}
inFile >> command;
numCommands = 0;
while (command != \"Quit\")
{
if (command == \"PutItem\")
{
inFile >> number;
item.Initialize(number);
list.PutItem(item);
item.Print(outFile);
outFile << \" is in list\" << endl;
}
else if (command == \"DeleteItem\")
{
inFile >> number;
item.Initialize(number);
list.DeleteItem(item);
item.Print(outFile);
outFile << \" is deleted\" << endl;
}
else if (command == \"GetItem\")
{
inFile >> number;
item.Initialize(number);
item = list.GetItem(item, found);
item.Print(outFile);
if (found)
outFile << \" found in list.\" << endl;
else outFile << \" not in list.\" << endl;
}
else if (command == \"GetLength\")
outFile << \"Length is \" << list.GetLength() << endl;
else if (command == \"IsFull\")
if (list.IsFull())
outFile << \"List is full.\" << endl;
else outFile << \"List is not full.\" << endl;
else if (command == \"MakeEmpty\")
list.MakeEmpty();
else if (command == \"PrintList\")
PrintList(outFile, list);
else
cout << command << \" is not a valid command.\" << endl;
numCommands++;
cout << \" Command number \" << numCommands << \" completed.\"
<< endl;
inFile >> command;
};
cout << \"Testing completed.\" << endl;
inFile.close();
outFile.close();
return 0;
}
void PrintList(ofstream& dataFile, UnsortedType& list)
// Pre: list has been initialized.
// dataFile is open for writing.
// Post: Each component in list has been written to dataFile.
// dataFile is still open.
{
int length;
ItemType item;
list.ResetList();
length = list.GetLength();
for .
In C++Add the function min as an abstract function to the classar.pdffantoosh1
In C++:
Add the function min as an abstract function to the classarrayListTypeto return the smallest
element of the list.
Also, write the definition of the function min in the classunorderedArrayListTypeand write a
program to test this function.
arrayListType.h
#ifndef H_arrayListType
#define H_arrayListType
class arrayListType
{
public:
bool isEmpty() const;
//Function to determine whether the list is empty
//Postcondition: Returns true if the list is empty;
// otherwise, returns false.
bool isFull() const;
//Function to determine whether the list is full
//Postcondition: Returns true if the list is full;
// otherwise, returns false.
int listSize() const;
//Function to determine the number of elements in
//the list.
//Postcondition: Returns the value of length.
int maxListSize() const;
//Function to determine the maximum size of the list
//Postcondition: Returns the value of maxSize.
void print() const;
//Function to output the elements of the list
//Postcondition: Elements of the list are output on the
// standard output device.
bool isItemAtEqual(int location, int item) const;
//Function to determine whether item is the same as
//the item in the list at the position specified
//by location.
//Postcondition: Returns true if list[location]
// is the same as item; otherwise,
// returns false.
// If location is out of range, an
// appropriate message is displayed.
virtual void insertAt(int location, int insertItem) = 0;
//Function to insert insertItem in the list at the
//position specified by location.
//Note that this is an abstract function.
//Postcondition: Starting at location, the elements of
// the list are shifted down,
// list[location] = insertItem; length++;
// If the list is full or location is out of
// range, an appropriate message is displayed.
virtual void insertEnd(int insertItem) = 0;
//Function to insert insertItem at the end of
//the list. Note that this is an abstract function.
//Postcondition: list[length] = insertItem; and length++;
// If the list is full, an appropriate
// message is displayed.
void removeAt(int location);
//Function to remove the item from the list at the
//position specified by location
//Postcondition: The list element at list[location] is
// removed and length is decremented by 1.
// If location is out of range, an
// appropriate message is displayed.
void retrieveAt(int location, int& retItem) const;
//Function to retrieve the element from the list at the
//position specified by location
//Postcondition: retItem = list[location]
// If location is out of range, an
// appropriate message is displayed.
virtual void replaceAt(int location, int repItem) = 0;
//Function to replace the elements in the list
//at the position specified by location.
//Note that this is an abstract function.
//Postcondition: list[location] = repItem
// If location is out of range, an
// appropriate message is displayed.
void clearList();
//Function to remove all the elements from the list
//After this operation, the size of t.
helpInstructionsAdd the function max as an abstract function to .pdfalmonardfans
help
Instructions
Add the function max as an abstract function to the class arrayListType to return the largest
element of the list.
Also, write the definition of the function max in the class unorderedArrayListType and write a
program to test this function.
files:
main.cpp:
//Data: 18 42 78 22 42 5 42 57
arrayListType.h:
#ifndef H_arrayListType
#define H_arrayListType
class arrayListType
{
public:
bool isEmpty() const;
//Function to determine whether the list is empty
//Postcondition: Returns true if the list is empty;
// otherwise, returns false.
bool isFull() const;
//Function to determine whether the list is full
//Postcondition: Returns true if the list is full;
// otherwise, returns false.
int listSize() const;
//Function to determine the number of elements in
//the list.
//Postcondition: Returns the value of length.
int maxListSize() const;
//Function to determine the maximum size of the list
//Postcondition: Returns the value of maxSize.
void print() const;
//Function to output the elements of the list
//Postcondition: Elements of the list are output on the
// standard output device.
bool isItemAtEqual(int location, int item) const;
//Function to determine whether item is the same as
//the item in the list at the position specified
//by location.
//Postcondition: Returns true if list[location]
// is the same as item; otherwise,
// returns false.
// If location is out of range, an
// appropriate message is displayed.
virtual void insertAt(int location, int insertItem) = 0;
//Function to insert insertItem in the list at the
//position specified by location.
//Note that this is an abstract function.
//Postcondition: Starting at location, the elements of
// the list are shifted down,
// list[location] = insertItem; length++;
// If the list is full or location is out of
// range, an appropriate message is displayed.
virtual void insertEnd(int insertItem) = 0;
//Function to insert insertItem at the end of
//the list. Note that this is an abstract function.
//Postcondition: list[length] = insertItem; and length++;
// If the list is full, an appropriate
// message is displayed.
void removeAt(int location);
//Function to remove the item from the list at the
//position specified by location
//Postcondition: The list element at list[location] is
// removed and length is decremented by 1.
// If location is out of range, an
// appropriate message is displayed.
void retrieveAt(int location, int& retItem) const;
//Function to retrieve the element from the list at the
//position specified by location
//Postcondition: retItem = list[location]
// If location is out of range, an
// appropriate message is displayed.
virtual void replaceAt(int location, int repItem) = 0;
//Function to replace the elements in the list
//at the position specified by location.
//Note that this is an abstract function.
//Postcondition: list[location] = repItem
// If location is out of range, an
// appropriate message is displayed.
void clearList();
//Function to remove all th.
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfcallawaycorb73779
C++ problem
Part 1: Recursive Print (40 pts)
Please write the recursive List reverse print function, whose iterative version we wrote in class.
Below are the function signatures for the functions you are going to need:
public:
/**Additional Operations*/
void print_reverse();
//Wrapper function that calls the reverse helper function to print a list in reverse
//prints nothing if the List is empty
private:
void reverse(Nodeptr node);
//Helper function for the public printReverse() function.
//Recursively prints the data in a List in reverse.
Why do we need the private helper function here?
Since we are going to be reversing our list node by node, in a recursive fashion, we want to pass
a one node at a time to our reverse function.
However, since our nodes are private, we cannot access them if we call the function inside of
main.
Add these function signatures to your List.h file along with your other function prototypes inside
the class definition.
Make sure that you place the reverse function inside the private portion of your List class
definition and the print_reverse function prototype to the public portion of your List class
definition.
Now, implement these two functions inside of List.h, under your section for additional
operations.
Important: Test each function carefully inside of your ListTest.cpp to make sure that it is
working properly.
Part 2: Adding an Index to Your List Nodes (20 pts)
Next, you will add the following functions to your List.h
/**Accessor Functions*/
int get_index();
//Indicates the index of the Node where the iterator is currently pointing
//Nodes are numbered from 1 to length of the list
//Pre: length != 0
//Pre: !off_end()
...
int List::get_index()
{
//Implement the function here
}
/**Manipulation Procedures*/
void scroll_to_index(int index);
//Moves the iterator to the node whose index is specified by the user
//Pre: length != 0
...
void scroll_to_index(int index)
{
//Implement function here
}
Part 3: Implementing Search as Part of Your List (40 pts)
Now, we are going to add two search functions to our List so that we can search for elements in
our List.
The first of these functions is going to be a simple linear search function.
You will need to add the following function prototype and function definition to your List.h:
/**Additional Operations*/
int linear_search(listitem item);
//Searchs the list, element by element, from the start of the List to the end of the List
//Returns the index of the element, if it is found in the List
//Returns -1 if the element is not in the List
//Pre: length != 0
...
int List::linear_search(listitem item)
{
//Implement the function here
}
You are also going to add a function to perform recursive binary search on your List.
You will need to add the following function prototype and function definition to your List.h:
int binary_search(int low, int high, listitem item);
//Recursively searchs the list by dividing the search space in half
//Returns the index of the element, if it is fo.
(Unordered Sets) As explained in this chapter, a set is a collection.pdfssuserc77a341
(Unordered Sets) As explained in this chapter, a set is a collection of distinct elements of the
same type. Design the class unorderedSetType, derived from the class unorderedArrayListType,
to manipulate sets. Note that you need to redefine only the functions insertAt, insertEnd, and
replaceAt. If the item to be inserted is already in the list, the functions insertAt and insertEnd
output an appropriate message. Similarly, if the item to be replaced is already in the list, the
function replaceAt outputs an appropriate message.Include the set operations of union and
intersection in your class. Also write a program to test your class. (C++)
#ifndef UNORDEREDARRAYLISTTYPE_H
#define UNORDEREDARRAYLISTTYPE_H
#include \"arrayListType.h\"
class unorderedArrayListType : public arrayListType {
public:
void insertAt(int location, int insertItem);
// Function to insert an item at a particular location
// Postcondition: The item has been added to the list and the length has
// been increased by 1.
void insertEnd(int insertItem);
// Function to insert an item at the end of the list
// Postcondition: The item has been added at the end of the list and the
// length has been increased by 1.
void replaceAt(int location, int repItem);
// Function to replace an item in the list.
// Postcondition: repItem overrwrites the item at the specified location
// in the list. The length of the list is unchanged.
int seqSearch(int searchItem) const;
// Function to search the list for searchItem. Note that this is an
// abstract function.
//Postcondition: If the item is found, returns the location in the array
// where the item is found; otherwise, returns -1.
void remove(int removeItem);
// Function to remove an item from the list
// Postcondition: If the item is found in the list, it is removed and the
// length of the list is decreased by 1; if the item is not in the list
// an appropriate message is displayed.
void removeAll(int removeItem);
// Function to remove all occurrences of an item from the list
// Postcondition: If the item is found in the the list, all occurrences are
// removed and the length of the list is decreased accordingly. If the
// item is not in the list an appropriate message is displayed.
unorderedArrayListType(int size = 100);
//Constructor.
};
#endif // UNORDEREDARRAYLISTTYPE_H
#include \"UnorderedArrayListType.h\"
#include
using namespace std;
void unorderedArrayListType::insertAt(int location,
int insertItem) {
if (location < 0 || location >= maxSize)
cout<<\"The position of the item to be inserted is out of range.\"<= maxSize) //list is full
cout << \"Cannot insert in a full list\" << endl;
else {
for (int i = length; i > location; i--)
list[i] = list[i - 1]; //move the elements down
list[location] = insertItem; //insert the item at the specified position
length++; //increment the length
}
} //end insertAt
void unorderedArrayListType::insertEnd(int insertItem) {
if (length >= maxSize) //the list is full
cout << \"Cannot insert in a full list.\.
2.(Sorted list array implementation)This sorted list ADT discussed .pdfarshin9
2.(Sorted list: array implementation)This sorted list ADT discussed in class should be extended
by the addition of two new methods:
//Interface: ArrayListADT
//works for int
public interface ArrayListADT {
public boolean isEmpty(); //Method to determine whether the list is empty.
public boolean isFull(); //Method to determine whether the list is full.
public int listSize(); //Method to return the number of elements in the list.
public int maxListSize(); //Method to return the maximum size of the list.
public void print(); //Method to output the elements of the list.
public boolean isItemAtEqual(int location, int item); //Method to determine whether item is
the same as the item in the list at location.
public void insertAt(int location, int insertItem); //Method to insert insertItem in the list at
the position
public void insertEnd(int insertItem); //Method to insert insertItem at the end of the list.
public void removeAt(int location); //Method to remove the item from the list at location.
public int retrieveAt(int location); //Method to retrieve the element from the list at location.
public void replaceAt(int location, int repItem); //Method to replace the element in the list at
location with repItem.
public void clearList(); //Method to remove all the elements from the list.
public int search(int searchItem); //Method to determine whether searchItem is in the list.
public void remove(int removeItem); //Method to remove an item from the list.
}
//Class: ArrayListClass implements
//Interface: ArrayListADT
public abstract class ArrayListClass implements ArrayListADT {
protected int length; //to store the length of the list
protected int maxSize; //to store the maximum size of the list
protected int[] list; //array to hold the list elements
//Default constructor
public ArrayListClass() {
maxSize = 100;
length = 0;
list = new int[maxSize];
}
//Alternate Constructor
public ArrayListClass(int size) {
if(size <= 0) {
System.err.println(\"The array size must be positive. Creating an array of size 100.\");
maxSize = 100;
}
else
maxSize = size;
length = 0;
list = new int[maxSize];
}
public boolean isEmpty() {
return (length == 0);
}
public boolean isFull() {
return (length == maxSize);
}
public int listSize() {
return length;
}
public int maxListSize() {
return maxSize;
}
public void print() {
for (int i = 0; i < length; i++)
System.out.print(list[i] + \" \");
System.out.println();
}
public boolean isItemAtEqual(int location, int item) {
if (location < 0 || location >= length) {
System.err.println(\"The location of the item to be compared is out of range.\");
return false;
}
return list[location]== item;
}
public void clearList() {
for (int i = 0; i < length; i++)
list[i] = 0;
length = 0;
System.gc(); //invoke the Java garbage collector
}
public void removeAt(int location) {
if (location < 0 || location >= length)
System.err.println(\"The location of the item to be removed is out of range.\");
else {
for(int i = location; i < length - 1; i++)
list[i] .
All code should be in C++Using the UnsortedList class (UnsortedLis.pdfakashenterprises93
All code should be in C++
Using the UnsortedList class (UnsortedList.h file below) write a function sublist which extracts
elements that are smaller than a given item from the given list and forms a new list. The
precondition of the function is: the list has been initialized and is not empty. The postconditions
are: newList contains all the items of the list whose values are less than the given item.
Implement the sublist function as a friend function of the UnsortedList class whose declaration
is:
friend void sublist(const UnsortedList& list,
const ItemType& item,
UnsortedList& newList);
(Hint: The UnsortedList class has private members
ItemType list[MAX_LENGTH];
int length;
and the member functions getLength, resetList, insert, remove, etc.)
//**********************************************************
// SPECIFICATION FILE (UnsortedList.h)
// This file gives the specification of a basic class
// template for unsorted array-based lists.
// The list components are not assumed to be in order by
// value.
//**********************************************************
#ifndef UNSORTEDLIST_H
#define UNSORTEDLIST_H
#include
#include // Needed for the exit function
using namespace std;
const int MAX_LENGTH = 100; // Maximum number of components
template // You may also choose to use
// typedef statement
class UnsortedList
{
public:
// Constructor
UnsortedList();
// Post: Empty list has been created. length has been set to zero.
// Knowledge responsibilities
int getLength() const;
// Post: Returns the length of the list
bool isEmpty() const;
// Post: Returns true if list is empty; false otherwise
bool isFull() const;
// Post: Returns true if list is full; false otherwise
bool isInList(const ItemType& item) const;
// Post: Returns true if item is int the list; false otherwise
int seqSearch(const ItemType& item) const;
// Function to search the list for a given item.
// Post: If item is found, returns the index in the array where
// item is found; otherwise, return -1.
// Action Responsibilities
void resetList();
// Post: The list becomes empty. length has been set to zero.
void insert(const ItemType& item);
// Function to insert item to the end of the list. However, first
// the list is searched to see whether the item to be inserted is
// already in the list.
// Post: list[length] = item and length++. If item is already in
// the list or the list is already full, an appropriate message is
// displayed.
void remove(const ItemType& item);
// Function to remove item from the list.
// Post: If item is found in the list, it is removed from the list
// and length is decremented by one.
// Overloaded [] operator declaration.
// This function returns a reference to the element in the
// array indexed by index.
ItemType& operator[](const int& index);
// Additional operations
void sort();
// Post: list items have been put into ascending order by selection sort
void selectionSort();
// Function to sort the items in the list.
// Post: list items have been put int.
please follow all instructions and answer the inbedded questions- and.pdfIan5L3Allanm
please follow all instructions and answer the inbedded questions, and written in C pls
// Write your name here
// Write the compiler used: Visual studio or gcc
// Reminder that your file name is incredibly important. Please do not change it.
// Reminder that we are compiling on Gradescope using GCC.
// READ BEFORE YOU START:
// You are given a partially completed program that creates a linked list of game
items like you'd see in a folder.
// Each item has this information: item name, game name, type of item, item ID.
// The struct 'itemRecord' holds the information of one item. Variety is an enum.
// A linked list of structs called 'list' is declared to hold the list of items.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the
directions carefully.
// You should not modify any of the given code, the return types, or the
parameters. Otherwise, you risk getting compilation errors.
// You are not allowed to modify main().
// You can use all string library functions.
// You will have to write your functions from scratch by looking at what is
expected to be passed into them in the pre-existing functions
// WRITE COMMENTS FOR IMPORANT STEPS IN YOUR CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_ITEMS 15
#define MAX_NAME_LENGTH 25
typedef enum { Health = 0, Equip, Etc } itemType; // enum type
struct itemRecord { // struct for item details
char itemName[MAX_NAME_LENGTH];
char gameName[MAX_NAME_LENGTH];
itemType variety;
unsigned int itemID;
struct itemRecord* next; // pointer to next node
};
struct itemRecord* list = NULL; // declare linked list
'list'
int count = 0; // the number of items
currently stored in the list (initialized to 0)
// functions already pre-implemented last homework
void flushStdIn();
void executeAction(char);
void save(char* fileName);
void display();
// functions that need implementation: add, sort, delete, load
// Implement your own headers.
int main()
{
char* fileName = "Item_List.txt";
load(fileName); // load list of items from file (if it exists).
Initially there will be no file.
char choice = 'i'; // initialized to a dummy value
do
{
printf("\nEnter your selection:\n");
printf("\t a: add a new item\n");
printf("\t d: display item list\n");
printf("\t r: remove a item from list\n");
printf("\t s: sort item list by ID\n");
printf("\t q: quit\n");
choice = getchar();
flushStdIn();
executeAction(choice);
} while (choice != 'q');
save(fileName); // save list of items to file (overwrites file if it
exists)
return 0;
}
// flush out leftover '\n' characters
void flushStdIn()
{
char c;
do c = getchar();
while (c != '\n' && c != EOF);
}
// ask for details from user for the given selection and perform that action
void executeAction(char c)
{
char itemName_input[MAX_NAME_LENGTH], gameName_input[MAX_NAME_LENGTH];
unsigned int itemId_input, add_result = 0;
char itemtype_input[20];
switch (c)
{
case 'a'.
Using the C++ programming language1. Implement the UnsortedList cl.pdfmallik3000
Using the C++ programming language
1. Implement the UnsortedList class to store a list of numbers that are input into the list from
data.txt.
- create a main.cpp file that gets the numbers from the file
- insert the number 7 into the list
- insert another number 300 into the list
- delete the number 6 from the list
- print out the following:
--the entire list
- the greatest
- the least
2. Attach the main.cpp, UnsortedList.cpp, the ItemType.h, and the output file two called
outfile2.txt
Use the files below:
// listDriver.cpp
// Test driver
#include
#include
#include
#include
#include
#include \"unsorted.h\"
using namespace std;
void PrintList(ofstream& outFile, UnsortedType& list);
int main()
{
ifstream inFile; // file containing operations
ofstream outFile; // file containing output
string inFileName; // input file external name
string outFileName; // output file external name
string outputLabel;
string command; // operation to be executed
int number;
ItemType item;
UnsortedType list;
bool found;
int numCommands;
// Prompt for file names, read file names, and prepare files
cout << \"Enter name of input command file; press return.\" << endl;
cin >> inFileName;
inFile.open(inFileName.c_str());
cout << \"Enter name of output file; press return.\" << endl;
cin >> outFileName;
outFile.open(outFileName.c_str());
cout << \"Enter name of test run; press return.\" << endl;
cin >> outputLabel;
outFile << outputLabel << endl;
if (!inFile)
{
cout << \"file not found\" << endl;
exit(2)
}
inFile >> command;
numCommands = 0;
while (command != \"Quit\")
{
if (command == \"PutItem\")
{
inFile >> number;
item.Initialize(number);
list.PutItem(item);
item.Print(outFile);
outFile << \" is in list\" << endl;
}
else if (command == \"DeleteItem\")
{
inFile >> number;
item.Initialize(number);
list.DeleteItem(item);
item.Print(outFile);
outFile << \" is deleted\" << endl;
}
else if (command == \"GetItem\")
{
inFile >> number;
item.Initialize(number);
item = list.GetItem(item, found);
item.Print(outFile);
if (found)
outFile << \" found in list.\" << endl;
else outFile << \" not in list.\" << endl;
}
else if (command == \"GetLength\")
outFile << \"Length is \" << list.GetLength() << endl;
else if (command == \"IsFull\")
if (list.IsFull())
outFile << \"List is full.\" << endl;
else outFile << \"List is not full.\" << endl;
else if (command == \"MakeEmpty\")
list.MakeEmpty();
else if (command == \"PrintList\")
PrintList(outFile, list);
else
cout << command << \" is not a valid command.\" << endl;
numCommands++;
cout << \" Command number \" << numCommands << \" completed.\"
<< endl;
inFile >> command;
};
cout << \"Testing completed.\" << endl;
inFile.close();
outFile.close();
return 0;
}
void PrintList(ofstream& dataFile, UnsortedType& list)
// Pre: list has been initialized.
// dataFile is open for writing.
// Post: Each component in list has been written to dataFile.
// dataFile is still open.
{
int length;
ItemType item;
list.ResetList();
length = list.GetLength();
for .
In C++Add the function min as an abstract function to the classar.pdffantoosh1
In C++:
Add the function min as an abstract function to the classarrayListTypeto return the smallest
element of the list.
Also, write the definition of the function min in the classunorderedArrayListTypeand write a
program to test this function.
arrayListType.h
#ifndef H_arrayListType
#define H_arrayListType
class arrayListType
{
public:
bool isEmpty() const;
//Function to determine whether the list is empty
//Postcondition: Returns true if the list is empty;
// otherwise, returns false.
bool isFull() const;
//Function to determine whether the list is full
//Postcondition: Returns true if the list is full;
// otherwise, returns false.
int listSize() const;
//Function to determine the number of elements in
//the list.
//Postcondition: Returns the value of length.
int maxListSize() const;
//Function to determine the maximum size of the list
//Postcondition: Returns the value of maxSize.
void print() const;
//Function to output the elements of the list
//Postcondition: Elements of the list are output on the
// standard output device.
bool isItemAtEqual(int location, int item) const;
//Function to determine whether item is the same as
//the item in the list at the position specified
//by location.
//Postcondition: Returns true if list[location]
// is the same as item; otherwise,
// returns false.
// If location is out of range, an
// appropriate message is displayed.
virtual void insertAt(int location, int insertItem) = 0;
//Function to insert insertItem in the list at the
//position specified by location.
//Note that this is an abstract function.
//Postcondition: Starting at location, the elements of
// the list are shifted down,
// list[location] = insertItem; length++;
// If the list is full or location is out of
// range, an appropriate message is displayed.
virtual void insertEnd(int insertItem) = 0;
//Function to insert insertItem at the end of
//the list. Note that this is an abstract function.
//Postcondition: list[length] = insertItem; and length++;
// If the list is full, an appropriate
// message is displayed.
void removeAt(int location);
//Function to remove the item from the list at the
//position specified by location
//Postcondition: The list element at list[location] is
// removed and length is decremented by 1.
// If location is out of range, an
// appropriate message is displayed.
void retrieveAt(int location, int& retItem) const;
//Function to retrieve the element from the list at the
//position specified by location
//Postcondition: retItem = list[location]
// If location is out of range, an
// appropriate message is displayed.
virtual void replaceAt(int location, int repItem) = 0;
//Function to replace the elements in the list
//at the position specified by location.
//Note that this is an abstract function.
//Postcondition: list[location] = repItem
// If location is out of range, an
// appropriate message is displayed.
void clearList();
//Function to remove all the elements from the list
//After this operation, the size of t.
helpInstructionsAdd the function max as an abstract function to .pdfalmonardfans
help
Instructions
Add the function max as an abstract function to the class arrayListType to return the largest
element of the list.
Also, write the definition of the function max in the class unorderedArrayListType and write a
program to test this function.
files:
main.cpp:
//Data: 18 42 78 22 42 5 42 57
arrayListType.h:
#ifndef H_arrayListType
#define H_arrayListType
class arrayListType
{
public:
bool isEmpty() const;
//Function to determine whether the list is empty
//Postcondition: Returns true if the list is empty;
// otherwise, returns false.
bool isFull() const;
//Function to determine whether the list is full
//Postcondition: Returns true if the list is full;
// otherwise, returns false.
int listSize() const;
//Function to determine the number of elements in
//the list.
//Postcondition: Returns the value of length.
int maxListSize() const;
//Function to determine the maximum size of the list
//Postcondition: Returns the value of maxSize.
void print() const;
//Function to output the elements of the list
//Postcondition: Elements of the list are output on the
// standard output device.
bool isItemAtEqual(int location, int item) const;
//Function to determine whether item is the same as
//the item in the list at the position specified
//by location.
//Postcondition: Returns true if list[location]
// is the same as item; otherwise,
// returns false.
// If location is out of range, an
// appropriate message is displayed.
virtual void insertAt(int location, int insertItem) = 0;
//Function to insert insertItem in the list at the
//position specified by location.
//Note that this is an abstract function.
//Postcondition: Starting at location, the elements of
// the list are shifted down,
// list[location] = insertItem; length++;
// If the list is full or location is out of
// range, an appropriate message is displayed.
virtual void insertEnd(int insertItem) = 0;
//Function to insert insertItem at the end of
//the list. Note that this is an abstract function.
//Postcondition: list[length] = insertItem; and length++;
// If the list is full, an appropriate
// message is displayed.
void removeAt(int location);
//Function to remove the item from the list at the
//position specified by location
//Postcondition: The list element at list[location] is
// removed and length is decremented by 1.
// If location is out of range, an
// appropriate message is displayed.
void retrieveAt(int location, int& retItem) const;
//Function to retrieve the element from the list at the
//position specified by location
//Postcondition: retItem = list[location]
// If location is out of range, an
// appropriate message is displayed.
virtual void replaceAt(int location, int repItem) = 0;
//Function to replace the elements in the list
//at the position specified by location.
//Note that this is an abstract function.
//Postcondition: list[location] = repItem
// If location is out of range, an
// appropriate message is displayed.
void clearList();
//Function to remove all th.
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfcallawaycorb73779
C++ problem
Part 1: Recursive Print (40 pts)
Please write the recursive List reverse print function, whose iterative version we wrote in class.
Below are the function signatures for the functions you are going to need:
public:
/**Additional Operations*/
void print_reverse();
//Wrapper function that calls the reverse helper function to print a list in reverse
//prints nothing if the List is empty
private:
void reverse(Nodeptr node);
//Helper function for the public printReverse() function.
//Recursively prints the data in a List in reverse.
Why do we need the private helper function here?
Since we are going to be reversing our list node by node, in a recursive fashion, we want to pass
a one node at a time to our reverse function.
However, since our nodes are private, we cannot access them if we call the function inside of
main.
Add these function signatures to your List.h file along with your other function prototypes inside
the class definition.
Make sure that you place the reverse function inside the private portion of your List class
definition and the print_reverse function prototype to the public portion of your List class
definition.
Now, implement these two functions inside of List.h, under your section for additional
operations.
Important: Test each function carefully inside of your ListTest.cpp to make sure that it is
working properly.
Part 2: Adding an Index to Your List Nodes (20 pts)
Next, you will add the following functions to your List.h
/**Accessor Functions*/
int get_index();
//Indicates the index of the Node where the iterator is currently pointing
//Nodes are numbered from 1 to length of the list
//Pre: length != 0
//Pre: !off_end()
...
int List::get_index()
{
//Implement the function here
}
/**Manipulation Procedures*/
void scroll_to_index(int index);
//Moves the iterator to the node whose index is specified by the user
//Pre: length != 0
...
void scroll_to_index(int index)
{
//Implement function here
}
Part 3: Implementing Search as Part of Your List (40 pts)
Now, we are going to add two search functions to our List so that we can search for elements in
our List.
The first of these functions is going to be a simple linear search function.
You will need to add the following function prototype and function definition to your List.h:
/**Additional Operations*/
int linear_search(listitem item);
//Searchs the list, element by element, from the start of the List to the end of the List
//Returns the index of the element, if it is found in the List
//Returns -1 if the element is not in the List
//Pre: length != 0
...
int List::linear_search(listitem item)
{
//Implement the function here
}
You are also going to add a function to perform recursive binary search on your List.
You will need to add the following function prototype and function definition to your List.h:
int binary_search(int low, int high, listitem item);
//Recursively searchs the list by dividing the search space in half
//Returns the index of the element, if it is fo.
(Unordered Sets) As explained in this chapter, a set is a collection.pdfssuserc77a341
(Unordered Sets) As explained in this chapter, a set is a collection of distinct elements of the
same type. Design the class unorderedSetType, derived from the class unorderedArrayListType,
to manipulate sets. Note that you need to redefine only the functions insertAt, insertEnd, and
replaceAt. If the item to be inserted is already in the list, the functions insertAt and insertEnd
output an appropriate message. Similarly, if the item to be replaced is already in the list, the
function replaceAt outputs an appropriate message.Include the set operations of union and
intersection in your class. Also write a program to test your class. (C++)
#ifndef UNORDEREDARRAYLISTTYPE_H
#define UNORDEREDARRAYLISTTYPE_H
#include \"arrayListType.h\"
class unorderedArrayListType : public arrayListType {
public:
void insertAt(int location, int insertItem);
// Function to insert an item at a particular location
// Postcondition: The item has been added to the list and the length has
// been increased by 1.
void insertEnd(int insertItem);
// Function to insert an item at the end of the list
// Postcondition: The item has been added at the end of the list and the
// length has been increased by 1.
void replaceAt(int location, int repItem);
// Function to replace an item in the list.
// Postcondition: repItem overrwrites the item at the specified location
// in the list. The length of the list is unchanged.
int seqSearch(int searchItem) const;
// Function to search the list for searchItem. Note that this is an
// abstract function.
//Postcondition: If the item is found, returns the location in the array
// where the item is found; otherwise, returns -1.
void remove(int removeItem);
// Function to remove an item from the list
// Postcondition: If the item is found in the list, it is removed and the
// length of the list is decreased by 1; if the item is not in the list
// an appropriate message is displayed.
void removeAll(int removeItem);
// Function to remove all occurrences of an item from the list
// Postcondition: If the item is found in the the list, all occurrences are
// removed and the length of the list is decreased accordingly. If the
// item is not in the list an appropriate message is displayed.
unorderedArrayListType(int size = 100);
//Constructor.
};
#endif // UNORDEREDARRAYLISTTYPE_H
#include \"UnorderedArrayListType.h\"
#include
using namespace std;
void unorderedArrayListType::insertAt(int location,
int insertItem) {
if (location < 0 || location >= maxSize)
cout<<\"The position of the item to be inserted is out of range.\"<= maxSize) //list is full
cout << \"Cannot insert in a full list\" << endl;
else {
for (int i = length; i > location; i--)
list[i] = list[i - 1]; //move the elements down
list[location] = insertItem; //insert the item at the specified position
length++; //increment the length
}
} //end insertAt
void unorderedArrayListType::insertEnd(int insertItem) {
if (length >= maxSize) //the list is full
cout << \"Cannot insert in a full list.\.
2.(Sorted list array implementation)This sorted list ADT discussed .pdfarshin9
2.(Sorted list: array implementation)This sorted list ADT discussed in class should be extended
by the addition of two new methods:
//Interface: ArrayListADT
//works for int
public interface ArrayListADT {
public boolean isEmpty(); //Method to determine whether the list is empty.
public boolean isFull(); //Method to determine whether the list is full.
public int listSize(); //Method to return the number of elements in the list.
public int maxListSize(); //Method to return the maximum size of the list.
public void print(); //Method to output the elements of the list.
public boolean isItemAtEqual(int location, int item); //Method to determine whether item is
the same as the item in the list at location.
public void insertAt(int location, int insertItem); //Method to insert insertItem in the list at
the position
public void insertEnd(int insertItem); //Method to insert insertItem at the end of the list.
public void removeAt(int location); //Method to remove the item from the list at location.
public int retrieveAt(int location); //Method to retrieve the element from the list at location.
public void replaceAt(int location, int repItem); //Method to replace the element in the list at
location with repItem.
public void clearList(); //Method to remove all the elements from the list.
public int search(int searchItem); //Method to determine whether searchItem is in the list.
public void remove(int removeItem); //Method to remove an item from the list.
}
//Class: ArrayListClass implements
//Interface: ArrayListADT
public abstract class ArrayListClass implements ArrayListADT {
protected int length; //to store the length of the list
protected int maxSize; //to store the maximum size of the list
protected int[] list; //array to hold the list elements
//Default constructor
public ArrayListClass() {
maxSize = 100;
length = 0;
list = new int[maxSize];
}
//Alternate Constructor
public ArrayListClass(int size) {
if(size <= 0) {
System.err.println(\"The array size must be positive. Creating an array of size 100.\");
maxSize = 100;
}
else
maxSize = size;
length = 0;
list = new int[maxSize];
}
public boolean isEmpty() {
return (length == 0);
}
public boolean isFull() {
return (length == maxSize);
}
public int listSize() {
return length;
}
public int maxListSize() {
return maxSize;
}
public void print() {
for (int i = 0; i < length; i++)
System.out.print(list[i] + \" \");
System.out.println();
}
public boolean isItemAtEqual(int location, int item) {
if (location < 0 || location >= length) {
System.err.println(\"The location of the item to be compared is out of range.\");
return false;
}
return list[location]== item;
}
public void clearList() {
for (int i = 0; i < length; i++)
list[i] = 0;
length = 0;
System.gc(); //invoke the Java garbage collector
}
public void removeAt(int location) {
if (location < 0 || location >= length)
System.err.println(\"The location of the item to be removed is out of range.\");
else {
for(int i = location; i < length - 1; i++)
list[i] .
All code should be in C++Using the UnsortedList class (UnsortedLis.pdfakashenterprises93
All code should be in C++
Using the UnsortedList class (UnsortedList.h file below) write a function sublist which extracts
elements that are smaller than a given item from the given list and forms a new list. The
precondition of the function is: the list has been initialized and is not empty. The postconditions
are: newList contains all the items of the list whose values are less than the given item.
Implement the sublist function as a friend function of the UnsortedList class whose declaration
is:
friend void sublist(const UnsortedList& list,
const ItemType& item,
UnsortedList& newList);
(Hint: The UnsortedList class has private members
ItemType list[MAX_LENGTH];
int length;
and the member functions getLength, resetList, insert, remove, etc.)
//**********************************************************
// SPECIFICATION FILE (UnsortedList.h)
// This file gives the specification of a basic class
// template for unsorted array-based lists.
// The list components are not assumed to be in order by
// value.
//**********************************************************
#ifndef UNSORTEDLIST_H
#define UNSORTEDLIST_H
#include
#include // Needed for the exit function
using namespace std;
const int MAX_LENGTH = 100; // Maximum number of components
template // You may also choose to use
// typedef statement
class UnsortedList
{
public:
// Constructor
UnsortedList();
// Post: Empty list has been created. length has been set to zero.
// Knowledge responsibilities
int getLength() const;
// Post: Returns the length of the list
bool isEmpty() const;
// Post: Returns true if list is empty; false otherwise
bool isFull() const;
// Post: Returns true if list is full; false otherwise
bool isInList(const ItemType& item) const;
// Post: Returns true if item is int the list; false otherwise
int seqSearch(const ItemType& item) const;
// Function to search the list for a given item.
// Post: If item is found, returns the index in the array where
// item is found; otherwise, return -1.
// Action Responsibilities
void resetList();
// Post: The list becomes empty. length has been set to zero.
void insert(const ItemType& item);
// Function to insert item to the end of the list. However, first
// the list is searched to see whether the item to be inserted is
// already in the list.
// Post: list[length] = item and length++. If item is already in
// the list or the list is already full, an appropriate message is
// displayed.
void remove(const ItemType& item);
// Function to remove item from the list.
// Post: If item is found in the list, it is removed from the list
// and length is decremented by one.
// Overloaded [] operator declaration.
// This function returns a reference to the element in the
// array indexed by index.
ItemType& operator[](const int& index);
// Additional operations
void sort();
// Post: list items have been put into ascending order by selection sort
void selectionSort();
// Function to sort the items in the list.
// Post: list items have been put int.
please follow all instructions and answer the inbedded questions- and.pdfIan5L3Allanm
please follow all instructions and answer the inbedded questions, and written in C pls
// Write your name here
// Write the compiler used: Visual studio or gcc
// Reminder that your file name is incredibly important. Please do not change it.
// Reminder that we are compiling on Gradescope using GCC.
// READ BEFORE YOU START:
// You are given a partially completed program that creates a linked list of game
items like you'd see in a folder.
// Each item has this information: item name, game name, type of item, item ID.
// The struct 'itemRecord' holds the information of one item. Variety is an enum.
// A linked list of structs called 'list' is declared to hold the list of items.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the
directions carefully.
// You should not modify any of the given code, the return types, or the
parameters. Otherwise, you risk getting compilation errors.
// You are not allowed to modify main().
// You can use all string library functions.
// You will have to write your functions from scratch by looking at what is
expected to be passed into them in the pre-existing functions
// WRITE COMMENTS FOR IMPORANT STEPS IN YOUR CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_ITEMS 15
#define MAX_NAME_LENGTH 25
typedef enum { Health = 0, Equip, Etc } itemType; // enum type
struct itemRecord { // struct for item details
char itemName[MAX_NAME_LENGTH];
char gameName[MAX_NAME_LENGTH];
itemType variety;
unsigned int itemID;
struct itemRecord* next; // pointer to next node
};
struct itemRecord* list = NULL; // declare linked list
'list'
int count = 0; // the number of items
currently stored in the list (initialized to 0)
// functions already pre-implemented last homework
void flushStdIn();
void executeAction(char);
void save(char* fileName);
void display();
// functions that need implementation: add, sort, delete, load
// Implement your own headers.
int main()
{
char* fileName = "Item_List.txt";
load(fileName); // load list of items from file (if it exists).
Initially there will be no file.
char choice = 'i'; // initialized to a dummy value
do
{
printf("\nEnter your selection:\n");
printf("\t a: add a new item\n");
printf("\t d: display item list\n");
printf("\t r: remove a item from list\n");
printf("\t s: sort item list by ID\n");
printf("\t q: quit\n");
choice = getchar();
flushStdIn();
executeAction(choice);
} while (choice != 'q');
save(fileName); // save list of items to file (overwrites file if it
exists)
return 0;
}
// flush out leftover '\n' characters
void flushStdIn()
{
char c;
do c = getchar();
while (c != '\n' && c != EOF);
}
// ask for details from user for the given selection and perform that action
void executeAction(char c)
{
char itemName_input[MAX_NAME_LENGTH], gameName_input[MAX_NAME_LENGTH];
unsigned int itemId_input, add_result = 0;
char itemtype_input[20];
switch (c)
{
case 'a'.
written in c- please answer the 4 questions and write the functions ba.pdfsravi07
written in c, please answer the 4 questions and write the functions based on the given code.
Thank you
// Write your name here
// Write the compiler used: Visual studio or gcc
// Reminder that your file name is incredibly important. Please do not change it.
// Reminder that we are compiling on Gradescope using GCC.
// READ BEFORE YOU START:
// You are given a partially completed program that creates a linked list of game
items like you'd see in a folder.
// Each item has this information: item name, game name, type of item, item ID.
// The struct 'itemRecord' holds the information of one item. Variety is an enum.
// A linked list of structs called 'list' is declared to hold the list of items.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the
directions carefully.
// You should not modify any of the given code, the return types, or the
parameters. Otherwise, you risk getting compilation errors.
// You are not allowed to modify main().
// You can use all string library functions.
// You will have to write your functions from scratch by looking at what is
expected to be passed into them in the pre-existing functions
// WRITE COMMENTS FOR IMPORANT STEPS IN YOUR CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_ITEMS 15
#define MAX_NAME_LENGTH 25
typedef enum { Health = 0, Equip, Etc } itemType; // enum type
struct itemRecord { // struct for item details
char itemName[MAX_NAME_LENGTH];
char gameName[MAX_NAME_LENGTH];
itemType variety;
unsigned int itemID;
struct itemRecord* next; // pointer to next node
};
struct itemRecord* list = NULL; // declare linked list
'list'
int count = 0; // the number of items
currently stored in the list (initialized to 0)
// functions already pre-implemented last homework
void flushStdIn();
void executeAction(char);
void save(char* fileName);
void display();
// functions that need implementation: add, sort, delete, load
// Implement your own headers.
int main()
{
char* fileName = "Item_List.txt";
load(fileName); // load list of items from file (if it exists).
Initially there will be no file.
char choice = 'i'; // initialized to a dummy value
do
{
printf("\nEnter your selection:\n");
printf("\t a: add a new item\n");
printf("\t d: display item list\n");
printf("\t r: remove a item from list\n");
printf("\t s: sort item list by ID\n");
printf("\t q: quit\n");
choice = getchar();
flushStdIn();
executeAction(choice);
} while (choice != 'q');
save(fileName); // save list of items to file (overwrites file if it
exists)
return 0;
}
// flush out leftover '\n' characters
void flushStdIn()
{
char c;
do c = getchar();
while (c != '\n' && c != EOF);
}
// ask for details from user for the given selection and perform that action
void executeAction(char c)
{
char itemName_input[MAX_NAME_LENGTH], gameName_input[MAX_NAME_LENGTH];
unsigned int itemId_input, add_result = 0;
char itemtype_input[20];
switc.
-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdfganisyedtrd
// Write the compiler used: Visual studio or gcc
// Reminder that your file name is incredibly important. Please do not change it.
// Reminder that we are compiling on Gradescope using GCC.
// READ BEFORE YOU START:
// You are given a partially completed program that creates a linked list of game
items like you'd see in a folder.
// Each item has this information: item name, game name, type of item, item ID.
// The struct 'itemRecord' holds the information of one item. Variety is an enum.
// A linked list of structs called 'list' is declared to hold the list of items.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the
directions carefully.
// You should not modify any of the given code, the return types, or the
parameters. Otherwise, you risk getting compilation errors.
// You are not allowed to modify main().
// You can use all string library functions.
// You will have to write your functions from scratch by looking at what is
expected to be passed into them in the pre-existing functions
// WRITE COMMENTS FOR IMPORANT STEPS IN YOUR CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_ITEMS 15
#define MAX_NAME_LENGTH 25
typedef enum { Health = 0, Equip, Etc } itemType; // enum type
struct itemRecord { // struct for item details
char itemName[MAX_NAME_LENGTH];
char gameName[MAX_NAME_LENGTH];
itemType variety;
unsigned int itemID;
struct itemRecord* next; // pointer to next node
};
struct itemRecord* list = NULL; // declare linked list
'list'
int count = 0; // the number of items
currently stored in the list (initialized to 0)
// functions already pre-implemented last homework
void flushStdIn();
void executeAction(char);
void save(char* fileName);
void display();
// functions that need implementation: add, sort, delete, load
// Implement your own headers.
int main()
{
char* fileName = "Item_List.txt";
load(fileName); // load list of items from file (if it exists).
Initially there will be no file.
char choice = 'i'; // initialized to a dummy value
do
{
printf("\nEnter your selection:\n");
printf("\t a: add a new item\n");
printf("\t d: display item list\n");
printf("\t r: remove a item from list\n");
printf("\t s: sort item list by ID\n");
printf("\t q: quit\n");
choice = getchar();
flushStdIn();
executeAction(choice);
} while (choice != 'q');
save(fileName); // save list of items to file (overwrites file if it
exists)
return 0;
}
// flush out leftover '\n' characters
void flushStdIn()
{
char c;
do c = getchar();
while (c != '\n' && c != EOF);
}
// ask for details from user for the given selection and perform that action
void executeAction(char c)
{
char itemName_input[MAX_NAME_LENGTH], gameName_input[MAX_NAME_LENGTH];
unsigned int itemId_input, add_result = 0;
char itemtype_input[20];
switch (c)
{
case 'a':
// input item record from user
printf("\nEnter item name: ");
fgets(itemName_input, sizeof(itemName_input), s.
Written in C- requires linked lists- Please answer the 4 questions and.pdfsravi07
Written in C, requires linked lists. Please answer the 4 questions and show the output. Thank
you!
// Write your name here
// Write the compiler used: Visual studio or gcc
// Reminder that your file name is incredibly important. Please do not change it.
// Reminder that we are compiling on Gradescope using GCC.
// READ BEFORE YOU START:
// You are given a partially completed program that creates a linked list of game
items like you'd see in a folder.
// Each item has this information: item name, game name, type of item, item ID.
// The struct 'itemRecord' holds the information of one item. Variety is an enum.
// A linked list of structs called 'list' is declared to hold the list of items.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the
directions carefully.
// You should not modify any of the given code, the return types, or the
parameters. Otherwise, you risk getting compilation errors.
// You are not allowed to modify main().
// You can use all string library functions.
// You will have to write your functions from scratch by looking at what is
expected to be passed into them in the pre-existing functions
// WRITE COMMENTS FOR IMPORANT STEPS IN YOUR CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_ITEMS 15
#define MAX_NAME_LENGTH 25
typedef enum { Health = 0, Equip, Etc } itemType; // enum type
struct itemRecord { // struct for item details
char itemName[MAX_NAME_LENGTH];
char gameName[MAX_NAME_LENGTH];
itemType variety;
unsigned int itemID;
struct itemRecord* next; // pointer to next node
};
struct itemRecord* list = NULL; // declare linked list
'list'
int count = 0; // the number of items
currently stored in the list (initialized to 0)
// functions already pre-implemented last homework
void flushStdIn();
void executeAction(char);
void save(char* fileName);
void display();
// functions that need implementation: add, sort, delete, load
// Implement your own headers.
int main()
{
char* fileName = "Item_List.txt";
load(fileName); // load list of items from file (if it exists).
Initially there will be no file.
char choice = 'i'; // initialized to a dummy value
do
{
printf("\nEnter your selection:\n");
printf("\t a: add a new item\n");
printf("\t d: display item list\n");
printf("\t r: remove a item from list\n");
printf("\t s: sort item list by ID\n");
printf("\t q: quit\n");
choice = getchar();
flushStdIn();
executeAction(choice);
} while (choice != 'q');
save(fileName); // save list of items to file (overwrites file if it
exists)
return 0;
}
// flush out leftover '\n' characters
void flushStdIn()
{
char c;
do c = getchar();
while (c != '\n' && c != EOF);
}
// ask for details from user for the given selection and perform that action
void executeAction(char c)
{
char itemName_input[MAX_NAME_LENGTH], gameName_input[MAX_NAME_LENGTH];
unsigned int itemId_input, add_result = 0;
char itemtype_input[20];
switch (c.
Written in C- requires linked lists- Please answer the 4 questions and (1).pdfsravi07
Written in C, requires linked lists. Please answer the 4 questions and show the output. Thank
you!
// Write your name here
// Write the compiler used: Visual studio or gcc
// Reminder that your file name is incredibly important. Please do not change it.
// Reminder that we are compiling on Gradescope using GCC.
// READ BEFORE YOU START:
// You are given a partially completed program that creates a linked list of game
items like you'd see in a folder.
// Each item has this information: item name, game name, type of item, item ID.
// The struct 'itemRecord' holds the information of one item. Variety is an enum.
// A linked list of structs called 'list' is declared to hold the list of items.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the
directions carefully.
// You should not modify any of the given code, the return types, or the
parameters. Otherwise, you risk getting compilation errors.
// You are not allowed to modify main().
// You can use all string library functions.
// You will have to write your functions from scratch by looking at what is
expected to be passed into them in the pre-existing functions
// WRITE COMMENTS FOR IMPORANT STEPS IN YOUR CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_ITEMS 15
#define MAX_NAME_LENGTH 25
typedef enum { Health = 0, Equip, Etc } itemType; // enum type
struct itemRecord { // struct for item details
char itemName[MAX_NAME_LENGTH];
char gameName[MAX_NAME_LENGTH];
itemType variety;
unsigned int itemID;
struct itemRecord* next; // pointer to next node
};
struct itemRecord* list = NULL; // declare linked list
'list'
int count = 0; // the number of items
currently stored in the list (initialized to 0)
// functions already pre-implemented last homework
void flushStdIn();
void executeAction(char);
void save(char* fileName);
void display();
// functions that need implementation: add, sort, delete, load
// Implement your own headers.
int main()
{
char* fileName = "Item_List.txt";
load(fileName); // load list of items from file (if it exists).
Initially there will be no file.
char choice = 'i'; // initialized to a dummy value
do
{
printf("\nEnter your selection:\n");
printf("\t a: add a new item\n");
printf("\t d: display item list\n");
printf("\t r: remove a item from list\n");
printf("\t s: sort item list by ID\n");
printf("\t q: quit\n");
choice = getchar();
flushStdIn();
executeAction(choice);
} while (choice != 'q');
save(fileName); // save list of items to file (overwrites file if it
exists)
return 0;
}
// flush out leftover '\n' characters
void flushStdIn()
{
char c;
do c = getchar();
while (c != '\n' && c != EOF);
}
// ask for details from user for the given selection and perform that action
void executeAction(char c)
{
char itemName_input[MAX_NAME_LENGTH], gameName_input[MAX_NAME_LENGTH];
unsigned int itemId_input, add_result = 0;
char itemtype_input[20];
switch (c.
you will implement some sorting algorithms for arrays and linked lis.pdfclearvisioneyecareno
you will implement some sorting algorithms for arrays and linked lists.
Insertion Sort and Quicksort of an array
Implement the insertion sort and quicksort for an integer array. The functions are defined in the
"sorting.h" header file.
/**
* @brief Insertion sort algorithm
* @param array Array to be sorted. The array is modified in place.
* @param lowindex Lowest index of the array
* @param highindex Highest index of the array
* @param reversed If reversed = true, the array should be sorted in descending order, otherwise
in ascending order
*/
void insertionSort(int array[], int lowindex, int highindex, bool reversed = false);
and
**
* @brief Quick sort algorithm
*
* @param array Array to be sorted. The array is modified in place.
* @param lowindex Lowest index of the array
* @param highindex Highest index of the array
* @param reversed If reversed = true, the array should be sorted in descending order, otherwise
in ascending order
*/
void quickSort(int array[], int lowindex, int highindex, bool reversed = false);
The array should be sorted in place. Compared to the examples in the textbook, those functions
have an additional parameter reversed. If reversed = true, the array should be sorted in
descending order, otherwise in ascending order. You should complete the implementations of
those two functions in the "sorting_basic.cpp" file.
A better quicksort algorithm
Quicksort is a very fast comparison sorting algorithm, especially wheb the array or list gets large.
However, when the arrays/lists are small enough, quicksort may run slower than some of the
(n^2) algorithms. This might not seem important until you note that when sorting a large array
with quicksort, many small sublists must be sorted. While the savings on sorting one small list
with a faster algorithm might be negligible, sorting hundreds of small lists with a faster algorithm
can make a difference in the overall efficiency of the sort. For this part of the assignment, you
will combine quicksort with another sorting algorithm to build a faster sorting algorithm. One
option is to
use quicksort until the array/list gets small enough, and then use insertion sort or another sort to
sort the small arrays/lists
What does "small enough" mean? You can try a percentage of the list (say, 5% or 10%), or an
absolute number (5 elements, 8 elements, 10 elements, 15 elements, 100 elements, etc), or
something else of your choosing. Based on your tests, choose the one that is the most efficient.
You should also tests to ensure that your hybrid quicksort has reasonable performance on all lists
-- most notably, it should be efficient on sorted and inverse sorted lists as well as random lists.
The definition of the hybrid quicksort function is as the following:
/**
* @brief A hybrid of insertion sort and quick sort algorithm. The algorithm is based on the idea
that if the array is short, it is better to use insertion sort.
* It uses quicksort until the list gets small enough, and then uses insertion s.
Dividing a linked list into two sublists of almost equal sizesa. A.pdftesmondday29076
Dividing a linked list into two sublists of almost equal sizes
a. Add the operation divideMid to the class linkedListType as follows:
Consider the following statements:
unorderedLinkedList myList;
unorderedLinkedList subList;
Suppose myList points to the list with elements 34 65 27 89 12 (in this order). The statement:
myList.divideMid(subList); divides myList into two sublists: myList points to the list with the
elements 34 65 27,
and subList points to the sublist with the elements 89 12.
b. Write the definition of the function template to implement the operation divideMid. Also,
write a program to test your function. The header files linkedList.h and unorderedLinkedList.h
are supplied. Your test program should produce output similar to this:
Turn in:
linkedList.h with modifications
Your test program.
(C++)
Required code is below:
#ifndef H_UnorderedLinkedList
#define H_UnorderedLinkedList
#include \"linkedList.h\"
using namespace std;
template
class unorderedLinkedList: public linkedListType
{
public:
bool search(const Type& searchItem) const;
//Function to determine whether searchItem is in the list.
//Postcondition: Returns true if searchItem is in the
// list, otherwise the value false is
// returned.
void insertFirst(const Type& newItem);
//Function to insert newItem at the beginning of the list.
//Postcondition: first points to the new list, newItem is
// inserted at the beginning of the list,
// last points to the last node in the
// list, and count is incremented by 1.
void insertLast(const Type& newItem);
//Function to insert newItem at the end of the list.
//Postcondition: first points to the new list, newItem
// is inserted at the end of the list,
// last points to the last node in the
// list, and count is incremented by 1.
void deleteNode(const Type& deleteItem);
//Function to delete deleteItem from the list.
//Postcondition: If found, the node containing
// deleteItem is deleted from the list.
// first points to the first node, last
// points to the last node of the updated
// list, and count is decremented by 1.
};
template
bool unorderedLinkedList::
search(const Type& searchItem) const
{
nodeType *current; //pointer to traverse the list
bool found = false;
current = this->first; //set current to point to the first
//node in the list
while (current != NULL && !found) //search the list
if (current->info == searchItem) //searchItem is found
found = true;
else
current = current->link; //make current point to
//the next node
return found;
}//end search
template
void unorderedLinkedList::insertFirst(const Type& newItem)
{
nodeType *newNode; //pointer to create the new node
newNode = new nodeType; //create the new node
newNode->info = newItem; //store the new item in the node
newNode->link = this->first; //insert newNode before first
this->first = newNode; //make first point to the
//actual first node
this->count++; //increment count
if (this->last == NULL) //if the list was empty, newNode is also
//the last node in the list
this->l.
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfrajkumarm401
Complete the provided partial C++ Linked List program. Main.cpp is given and Link list header
file is also given. The given testfile listmain.cpp is given for demonstration of unsorted list
functionality. The functions header file is also given. Complete the functions of the header file
linked_list.h below.
=========================================================
// listmain.cpp
#include \"Linked_List.h\"
int main(int argc, char **argv)
{
float f;
Linked_List *theList;
cout << \"Simple List Demonstration\ \";
cout << \"(List implemented as an Array - Do not try this at home)\ \ \";
cout << \"Create a list and add a few tasks to the list\";
theList = new Linked_List(); // Instantiate a list object
theList->Insert(5, 3.1f); // Note: The argument to the funtion should be a float
theList->Insert(1, 5.6f); // A constant real number like 3.1 is interpreted as
theList->Insert(3, 8.3f); // a double unless it is explicitly defined as a float
theList->Insert(2, 7.4f); // by adding an \'f\' to the end of the number.
theList->Insert(4, 2.5f);
// Show what is in the list
theList->PrintList();
// Test the list length function
cout << \"\ List now contains \" << theList->ListLength() << \"items.\ \ \";
// Test delete function
cout << \"Testing delete of last item in list.\ \";
theList->Delete(4);
theList->PrintList();
// Test delete function
cout << \"Testing delete of first item in list.\ \";
theList->Delete(5);
theList->PrintList();
// Test delete function
cout << \"Testing delete of a middle item in list.\ \";
theList->Delete(3);
theList->PrintList();
// Test delete function with a known failure argument
cout << \"Testing failure in delete function.\ \";
if(theList->Delete(4))
cout << \"Oops! Should not have been able to delete.\ \";
else
cout << \"Unable to locate item to delete.\ \";
// Test search (known failure)
cout << \"Testing Search function. Search for key 3\ \";
if(theList->Search(3, &f))
cout << \"Search result: theData = %f\ \", f;
else
cout << \"Search result: Unable to locate item in list\ \";
// Test search (known success)
cout << \"Testing Search function. Search for key 2\ \";
if(theList->Search(2, &f))
cout << \"Search result: theData = \" << f << \"\ \";
else
cout << \"Search result: Unable to locate item in list\ \";
cout << \"\ \ End list demonstration...\";
return 0;
}
=====================================================================
===================
// linked_list.h functions
#include
using namespace std;
// Define a structure to use as the list item
struct ListItem
{
int key;
float theData;
ListItem *next;
};
class Linked_List
{
private:
ListItem *head; // Pointer to head of the list
public:
Linked_List(); // Class constructor
~Linked_List(); // Class destuctor
void ClearList(); // Remove all items from the list
bool Insert(int key, float f);// Add an item to the list
bool Delete(int key); // Delete an item from the list
bool Search(int key, float *retVal); // Search for an item in the list
int ListLength(); // Return numb.
-- Reminder that your file name is incredibly important- Please do not.docxAdamq0DJonese
// Reminder that your file name is incredibly important. Please do not change it.
// Reminder that we are compiling on Gradescope using GCC.
// READ BEFORE YOU START:
// You are given a partially completed program that creates a list of game items
like you'd see in a folder.
// Each item has this information: item's name, game's name, type of item, item ID.
// The struct 'itemRecord' holds information of one item. Variety is an enum.
// An array of structs called 'list' is made to hold the list of items.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the
directions carefully.
// You should not modify any of the given code, the return types, or the
parameters. Otherwise, you risk getting compilation errors.
// You are not allowed to modify main().
// You can use string library functions.
// WRITE COMMENTS FOR IMPORANT STEPS IN YOUR CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma warning(disable: 4996) // for Visual Studio
Only
#define MAX_ITEMS 15
#define MAX_NAME_LENGTH 25
typedef enum { Health = 0, Equip, Etc } itemType; // enum type
struct itemRecord { // struct for item details
char itemName[MAX_NAME_LENGTH];
char gameName[MAX_NAME_LENGTH];
itemType variety;
unsigned int itemID;
};
struct itemRecord list[MAX_ITEMS]; // declare list of items
int count = 0; // the number of items
currently stored in the list (initialized to 0)
// functions already implmented
void flushStdIn();
void executeAction(char);
void save(char* fileName);
void display();
// functions that need implementation:
int add(char* itemName_input,
char* gameName_input,
char* variety_input,
unsigned int idNumber_input); // 10 points
void sort(); // 10 points
int delete(unsigned int idNumber_input); // 10 points
void load(char* fileName); // 10 points
int main()
{
char* fileName = "Item_List.txt";
load(fileName); // load list of items from
file (if it exists). Initially there will be no file.
char choice = 'i'; // initialized to a dummy
value
do
{
printf("\nEnter your selection:\n");
printf("\t a: add a new item\n");
printf("\t d: display item list\n");
printf("\t r: remove an item from list\n");
printf("\t s: sort item list by ID\n");
printf("\t q: quit\n");
choice = getchar();
flushStdIn();
executeAction(choice);
} while (choice != 'q');
save(fileName); // save list of items to file
(overwrites file, if it exists)
return 0;
}
// flush out leftover '\n' characters
void flushStdIn()
{
char c;
do c = getchar();
while (c != '\n' && c != EOF);
}
// ask for details from user for the given selection and perform that action
void executeAction(char c)
{
char itemName_input[MAX_NAME_LENGTH], gameName_input[MAX_NAME_LENGTH];
unsigned int idNumber_input, add_result = 0;
char variety_input[20];
switch (c)
{
case 'a':
// input item record from user
printf("\nEnter item name: ").
Complete a C++ class implementation for a linked-list of sorted (asc.pdfshahidqamar17
Complete a C++ class implementation for a linked-list of sorted (ascending) positive integers.
The class name for this class is LLSortedPosInt and its specification is outlined in the file
LLSortedPosInt.h. The specification is accompained by two other files: (1) a partial
implementation of the class in the file LLSortedPosInt.cpp and (2) a test program called
testLL.cpp. You are to complete the partial implementation of the class by writing code for the
stubbed member functions. You may NOT make any changes to the specification file. You may
develop and test your class implementation either under Visual Studio or linux; however, your
program must be executable under linux, because that is where it will be tested.
Details: Linked lists are useful data structures for storing data records, particularly in situations
where the items are to be kept sorted, the number of records are dynamic (i.e., changing during
the course of the program’s execution) and the maximum number is arbitrary. In this exercise,
you’ll get a chance to complete the implementation of a linked-list specification. In doing so,
you’ll learn not only how to manipulate pointer objects, but also begin to learn how to create a
new and useful data type.
To get started, I have written a simple linked list definition within the header file called
LLSortedPosInt.h. My definition is, of course, not the only way to define a linked list, but it is
suitable for our simple project. Accompanying the definition is a partial implementation in the
source file LLSortedPosInt.cpp. You are to edit this file using the comments in the file and the
instructions below. Altogether, this assignment asks you to implement 13 functions.
To help with testing your functions implementations, I have provided a main program. This main
program is in the source file testLL.cpp. One quick way to repeatedly exercise your function
tests is to write a test file (I called mine testCases.txt) and use input re-direction.
The 13 functions you must add to complete the implementation are as follows:
a. Constructors (4): Classes must have constructors to initialize instances of the objects. The
constructors you will implement for this project are
i. A default constructor
ii. A constructor taking a single int parameter
iii. A constructor which builds a list from an array of integers
iv. A copy constructor
b. Destructor (1): Because the class specification includes a pointer among the attributes, you
will need to implement a destructor to delete (i.e., free or release) any storage allocated in the
constructors or other member functions.
c. Boolean Functions (2): You are to implement two Boolean functions
i. A function isEmpty() which returns true if the associated list contains no data elements,
and returns false otherwise.
ii. A function containsElement(key) which returns true is key is an element in the list and
returns false otherwise.
d. Member Operator Functions (3): When a class has a pointer among its attributes, as
.
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdfEdwardw5nSlaterl
Need Help!! C++
#include<iostream>
#include"linkedlist.h"
using namespace std;
/**
* @brief Destructor to destroy all nodes and release memory
*/
LinkedList::~LinkedList() {
//TODO: Add code here. Make sure memory is released properly.
}
/**
* @brief Purpose: Checks if the list is empty
* @return true if the list is empty, false otherwise
*/
bool LinkedList::isEmpty() const {
// TODO: Add code here
return count == 0;
}
/**
* @brief Get the number of nodes in the list
* @return int The number of nodes in the list
*/
int LinkedList::length() const{
//TODO: Add code here
}
/**
* @brief Convert the list to a string
*
*/
string LinkedList::toString() {
string str = "[";
Node *ptr = front;
if (ptr != nullptr) {
// Head node is not preceded by separator
str += to_string(ptr->val);
ptr = ptr->next;
}
while (ptr != nullptr) {
str += ", " + to_string(ptr->val);
ptr = ptr->next;
}
str += "]";
return str;
}
/**
* @brief Displays the contents of the list
*/
void LinkedList::displayAll() {
cout << toString() << endl;
}
//TODO: Add comments
void LinkedList::addRear(T val) {
// TODO: Add code here
// consider the two cases of whether the list was empty
}
//TODO: Add comments
void LinkedList::addFront(T val) {
// TODO: Add code here
// consider the two cases of whether the list was empty
}
//TODO: Add comments
bool LinkedList::deleteFront(T &OldNum) {
// TODO: Add code here
// consider if the list was empty and return false if the list is empty
// consider the special case of deleting the only node in the list
}
//TODO: Add comments
bool LinkedList::deleteRear(T &OldNum) {
// TODO: Add code here
// consider if the list was empty and return false if the list is empty
// consider the special case of deleting the only node in the list
}
/* --- harder ones for test 2 and 3 -- */
/**
* @brief Delete a node at a given position from the list. The
* node at position pos is deleted and the value of the deleted node is returned in val.
* The valid range of pos is 1 to count. pos = 1 is the first node, and pos = count is the last node.
* @param pos: position of the node to be deleted
* @param val: it is set to the value of the node to be deleted
* @return true: if the node was deleted successfully
* @return false: if the node was not deleted successfully because the position was out of range
*/
bool LinkedList::deleteAt(int pos, T &val) {
//TODO: Add code here
// check if the pos is valid first, then move the ptr to the rigth positon
// consider the special case of deleting the first node and the last node
// Do not forget to set value.
}
/**
* @brief Insert a value at a specified position in the list. The valid pos is in the range of 1 to
count+1.
* The value will be inserted before the node at the specified position. if pos = 1, the value will be
inserted
* at the front of the list. if pos = count+1, the value will be inserted at the rear of the list.
* @param pos: position to insert the value at.
* @param val: value to insert.
* @return true: if the value was inserte.
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...davidwarner122
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Below is a given ArrayList class and Main class in search algorithms. Please modify the existing program so it can time the sequential search and the binary search methods several times each for randomly generated values, and record the results in a table. Do not time individual searches, but groups of them. For example, time 100 searches together or 1,000 searches together. Compare the running times of these two search methods that are obtained during the experiment.
please i need help Im writing a program to test the merge sort alg.pdfezonesolutions
please i need help I\'m writing a program to test the merge sort algorithm for linked lists.
I need to Print the list before being sorted and the list after sorting the elements
here is my code only help in test program the four classes are ok except the test program.
TEST PROGRAM
import java.io.*;
import java.util.*;
public class Ch9_ProgExercise7 {
Scanner input = new Scanner(System.in);
public static void main(String[] args) throws IOException {
OrderedLinkedList list
= new OrderedLinkedList(); //Line 1
IntElement num = new IntElement(); //Line 2
// Prompt the user to enter some integers
System.out.println(\"Enter integers numbers \");
String temp = input.hasnextLine();
String[] split = temp.split(\" \");
for (int i = 0; i < split.length; i++) {
Integer a = Integer.parseInt(split[i]);
// insert the intgers into the list you created above
num.setNum(a);
list.insertNode(num);
}
System.out.println();
// Print the list before being sorted
// call the mergesort method
System.out.println();
// print the list after sorting the elements
}
}
ORDEREDLICKEDLIST CLASS
public class OrderedLinkedList extends LinkedListClass
{
//default constructor
public OrderedLinkedList()
{
super();
}
//copy constructor
public OrderedLinkedList(OrderedLinkedList otherList)
{
super(otherList);
}
public void linkedInsertionSort()
{
LinkedListNode lastInOrder;
LinkedListNode firstOutOfOrder;
LinkedListNode current;
LinkedListNode trailCurrent;
lastInOrder = first;
if(first == null)
System.out.println(\"Cannot sort an empty list\");
else
if(first.link == null)
System.out.println(\"The list is of length 1. \"
+ \"Already in order\");
else
while(lastInOrder.link != null)
{
firstOutOfOrder = lastInOrder.link;
if(firstOutOfOrder.info.compareTo(first.info) < 0)
{
lastInOrder.link = firstOutOfOrder.link;
firstOutOfOrder.link = first;
first = firstOutOfOrder;
}
else
{
trailCurrent = first;
current = first.link;
while(current.info.compareTo(firstOutOfOrder.info) < 0)
{
trailCurrent = current;
current = current.link;
}
if(current != firstOutOfOrder)
{
lastInOrder.link = firstOutOfOrder.link;
firstOutOfOrder.link = current;
trailCurrent.link = firstOutOfOrder;
}
else
lastInOrder = lastInOrder.link;
}
}
}//end linkedInsertionSort
//Method to determine whether searchItem is in
//the list.
//Postcondition: Returns true if searchItem is found
// in the list; otherwise, it returns
// false.
public boolean search(DataElement searchItem)
{
LinkedListNode current; //variable to traverse the list
boolean found;
current = first; //set current to point to the first
//node in the list
found = false; //set found to false
while(current != null && !found ) //search the list
if(current.info.compareTo(searchItem) >= 0)
found = true;
else
current = current.link; //make current point to
//the next node
if(found)
found = current.info.equals(searchItem);
return found;
}
//Method to insert insertItem in the list
//Postcondition: first points to the new list,
// newItem is inserted at the proper place
//.
In this homework- you will write a program modify program you wrote in.pdfEvanpZjSandersony
In this homework, you will write a program modify program you wrote in Homework3.
2) Modify the MyList class that you wrote for Programming challenge 1 so the type parameter T
should accept any type that implements the Comparable interface. Test the class in a program
that creates one instance of MyList to store Integers, and another instance to store Strings. Input
two numbers from the user and insert them into the first instance of Modified MyList.
Input name and City and insert the two strings into the second instance of modified MyList class.
Then display the contents of the the two instances.
here is the program to modify
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// part 1 code.
// creating a Number list
MyList<Number> intList = new MyList<>();
// adding the numbers mentioned in the question
intList.add(2);
intList.add(5);
intList.add(-13);
intList.add(11);
intList.add(12);
// creating a Double list, adding double values to it
MyList<Double> doubleList = new MyList<>();
doubleList.add(27.3);
doubleList.add(5.7);
doubleList.add(-23.9);
doubleList.add(1.11);
doubleList.add(5.12);
System.out.println("PART 1");
// printing largest and smallest of both lists
System.out.println("The Integer largest: \n" + intList.largest());
System.out.println("The Integer smallest: \n" + intList.smallest());
System.out.println("The Double largest: \n" + doubleList.largest());
System.out.println("The Double smallest: \n" + doubleList.smallest());
}
}
//MyList class, which is defined outside Generics1 class BUT still within Generics1.java file.
class MyList<T extends Number> {
// defining an array list as storage
ArrayList<T> list;
// constructor initializing list
public MyList() {
// initializing array list
list = new ArrayList<>();
}
// method to add a value to the list
public void add(T value) {
list.add(value);
}
// method to return the largest element on the list
public T largest() {
// assuming list is not empty, taking first value as largest
T max = list.get(0);
for (int i = 1; i < list.size(); i++) {
// comparing element at i with max using doubleValue() of Number class
if (list.get(i).doubleValue() > max.doubleValue()) {
max = list.get(i);
}
}
return max;
}
// method to return the smallest element on the list
public T smallest() {
// assuming list is not empty, taking first value as smallest
T min = list.get(0);
for (int i = 1; i < list.size(); i++) {
// comparing element at i with min using doubleValue() of Number class
if (list.get(i).doubleValue() < min.doubleValue()) {
min = list.get(i);
}
}
return min;
}
// returns the elemnt at a given position
public T get(int index) {
return list.get(index);
}
}
Here is the sample input/outPut
TestCase1:
PART 2
Please enter a number:
30
Please another number:
20
Please enter your name:
John
Please enter your City:
Los Angeles
First number is 30
Second number is 20
Name is: John
City is: Los Angeles
TestCase2:
PART 2
Please enter a number:
.
--INSTRUCTION- --It helps to first create if-then-else structure to fi.pdfAdrianEBJKingr
//INSTRUCTION:
//It helps to first create if-then-else structure to fill in later.
//- Make sure PURPOSE and PARAMETER comments are given in detail
// Add sufficient comments to your code body to describe what it does.
// - Make sure all if-then-else are commented describing which case it is
// - Make sure all local variables are described fully with their purposes
//Complete the TODO parts.
// ====================================================
//Complier: g++
//File type: linkedList.cpp implementation file
//=====================================================
#include<iostream>
#include"linkedlist.h"
using namespace std;
//cunstructor that initializes an empty list
LinkedList::LinkedList() {
front = nullptr ;
rear = nullptr ;
count = 0;
}
/**
* @brief Destructor to destroy all nodes and release memory
*/
LinkedList::~LinkedList() {
Node *p, *q;
p = front;
while (p != nullptr ) {
q = p->next;
delete p;
p = q;
}
}
/**
* @brief Purpose: Checks if the list is empty
* @return true if the list is empty, false otherwise
*/
bool LinkedList::isEmpty() const {
// TODO: Add code here
return count == 0;
}
/**
* @brief Get the number of nodes in the list
* @return int The number of nodes in the list
*/
int LinkedList::length() const {
return count;
}
/**
* @brief Convert the list to a string
*
*/
string LinkedList::toString() {
string str = "[";
Node *ptr = front;
if (ptr != nullptr ) {
// Head node is not preceded by separator
str += to_string(ptr->val);
ptr = ptr->next;
}
while (ptr != nullptr ) {
str += ", " + to_string(ptr->val);
ptr = ptr->next;
}
str += "]";
return str;
}
/**
* @brief Displays the contents of the list
*/
void LinkedList::displayAll() {
cout << toString() << endl;
}
//Add a node to the end of the list
void LinkedList::addRear(T val) {
Node *p = new Node;
p->val = val;
p->next = nullptr ;
if (isEmpty()) {
front = p;
}
else {
rear->next = p;
}
rear = p;
count++;
// consider the two cases of whether the list was empty
}
//Add a node to the front of the list
void LinkedList::addFront(T val) {
Node *p = new Node;
p->val = val;
p->next = front;
if (isEmpty()) {
rear = p;
}
front = p;
count++;
// consider the two cases of whether the list was empty
}
//Delete the first node of the list
bool LinkedList::deleteFront(T &OldNum) {
if (isEmpty()) {
return false ;
}
Node *p = front;
OldNum = p->val;
front = front->next;
if (front == nullptr ) {
rear = nullptr ;
}
delete p;
count--;
return true ;
// consider if the list was empty and return false if the list is empty
// consider the special case of deleting the only node in the list
}
//Delete the last node of the list
bool LinkedList::deleteRear(T &OldNum) {
if (isEmpty()) {
return false ;
}
Node *p = rear;
OldNum = p->val;
if (front == rear) {
front = rear = nullptr ;
}
else {
Node *q = front;
while (q->next != rear) {
q = q->next;
}
rear = q;
q->next = nullptr ;
}
delete p;
count--;
return true ;
// consider if the list was empty and return false if the list is empty
// consider the specia.
In C pls -- Write your name here -- Write the compiler used- Visual st.docxBlake0FxCampbelld
In C pls
// Write your name here
// Write the compiler used: Visual studio or gcc
// Reminder that your file name is incredibly important. Please do not change it.
// Reminder that we are compiling on Gradescope using GCC.
// READ BEFORE YOU START:
// You are given a partially completed program that creates a list of game items
like you'd see in a folder.
// Each item has this information: item's name, game's name, type of item, item ID.
// The struct 'itemRecord' holds information of one item. Variety is an enum.
// An array of structs called 'list' is made to hold the list of items.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the
directions carefully.
// You should not modify any of the given code, the return types, or the
parameters. Otherwise, you risk getting compilation errors.
// You are not allowed to modify main().
// You can use string library functions.
// WRITE COMMENTS FOR IMPORANT STEPS IN YOUR CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma warning(disable: 4996) // for Visual Studio
Only
#define MAX_ITEMS 15
#define MAX_NAME_LENGTH 25
typedef enum { Health = 0, Equip, Etc } itemType; // enum type
struct itemRecord { // struct for item details
char itemName[MAX_NAME_LENGTH];
char gameName[MAX_NAME_LENGTH];
itemType variety;
unsigned int itemID;
};
struct itemRecord list[MAX_ITEMS]; // declare list of items
int count = 0; // the number of items
currently stored in the list (initialized to 0)
// functions already implmented
void flushStdIn();
void executeAction(char);
void save(char* fileName);
void display();
// functions that need implementation:
int add(char* itemName_input,
char* gameName_input,
char* variety_input,
unsigned int idNumber_input); // 10 points
void sort(); // 10 points
int delete(unsigned int idNumber_input); // 10 points
void load(char* fileName); // 10 points
int main()
{
char* fileName = "Item_List.txt";
load(fileName); // load list of items from
file (if it exists). Initially there will be no file.
char choice = 'i'; // initialized to a dummy
value
do
{
printf("\nEnter your selection:\n");
printf("\t a: add a new item\n");
printf("\t d: display item list\n");
printf("\t r: remove an item from list\n");
printf("\t s: sort item list by ID\n");
printf("\t q: quit\n");
choice = getchar();
flushStdIn();
executeAction(choice);
} while (choice != 'q');
save(fileName); // save list of items to file
(overwrites file, if it exists)
return 0;
}
// flush out leftover '\n' characters
void flushStdIn()
{
char c;
do c = getchar();
while (c != '\n' && c != EOF);
}
// ask for details from user for the given selection and perform that action
void executeAction(char c)
{
char itemName_input[MAX_NAME_LENGTH], gameName_input[MAX_NAME_LENGTH];
unsigned int idNumber_input, add_result = 0;
char variety_input[20];
swi.
Please help solve this in C++ So the program is working fin.pdfankit11134
Please help solve this in C++. So the program is working fine but when submitting it, it gives me a
code -11, and I believe the problem is that after inserting the numbers it removes them one by one
until the last in the list, and when it tries to remove the last number in the list that is when it
counters the problem. Below is the full code but you just need to change something in the
SortedNumberList.h file under the bool remove function.
4.18 LAB: Sorted number list implementation with linked lists Step 1: Inspect the Node.h file
Inspect the class declaration for a doubly-linked list node in Node.h. Access Node.h by clicking on
the orange arrow next to main.cpp at the top of the coding window. The Node class has three
member variables: - a double data value, - a pointer to the next node, and - a pointer to the
previous node. Each member variable is protected. So code outside of the class must use the
provided getter and setter member functions to get or set a member variable. Node.h is read only,
since no changes are required. Step 2: Implement the Insert() member function A class for a
sorted, doubly-linked list is declared in SortedNumberList.h. Implement the SortedNumberList
class's Insert() member function. The function must create a new node with the parameter value,
then insert the node into the proper sorted position in the linked list. Ex: Suppose a
SortedNumberList's current list is 2347.2586, then Insert(33.5) is called. A new node with data
value 33.5 is created and inserted between 23 and 47.25, thus preserving the list's sorted order
and yielding: 2335.547.2586Step 3: Test in develop mode Code in main() takes a space-
separated list of numbers and inserts each into a SortedNumberList. The list is displayed after
each insertion. Ex: If input is 77154263.5 then output is: List after inserting 77 : 77 List after
inserting 15 : 1577 List after inserting -42 : -421577 List after inserting 63.5: -421563.577 Try
various program inputs, ensuring that each outputs a sorted list. Step 4: Implement the Remove()
member function Implement the SortedNumberList class's Remove(0 member function. The
function takes a parameter for the number to be removed from the list. If the number does not
exist in the list, the list is not changed and false is returned. Otherwise, the first instance of the
number is removed from the list and true is returned. Uncomment the commented-out part in
main() that reads a second input line and removes numbers from the list. Test in develop mode to
ensure that insertion and removal both work properly, then submit code for grading. Ex: If input is
841972841961 then output is: List after inserting 84: 84 List after inserting 72 : 7284 List after
inserting 19: 1972 84 List after inserting 61: 1961 : 72 8 List after removing 19: 6172 84 List after
removing 84: 6172Current file: main.cpp - // Insert each value and show the sorted List's contents
after each insertion sortedNumberList list; for (auto term : terms) { doubl.
JAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdfsuresh640714
JAVA help
Need bolded lines fixed for it to compile. Thank you!
public class PersonSort
{
// Test file. Format is \"STRING int int int\"
static final String PERSON_FILE = \".\\\\src\\\\Persons.txt\";
public static void main(String[] args) throws FileNotFoundException
{
// Create new ArrayList and populate from test file
ArrayList list1 = new ArrayList();
populate(list1);
// Create new array with same people
ArrayList list2 = new ArrayList(list1);
insertionSort(list1);
// Print result of sort
System.out.println(\"INSERTION SORT\");
// *** foreach Person p in list1
{
System.out.println(p.toString());
}
selectionSort(list2);
System.out.println();
System.out.println(\"SELECTION SORT\");
// *** foreach Person p in list2
{
System.out.println(p.toString());
}
}
/*
* populate - this method reads the Persons.txt file and creates an array list
*
*/
public static ArrayList populate(ArrayList list)
throws IOException
{
// Scan in the file
File people = new File(PERSON_FILE);
Scanner ppl = new Scanner(people);
// While we have a next line, create a new Person and add it to the list
while (ppl.hasNextLine())
{
String name = ppl.next();
int month = ppl.nextInt();
int day = ppl.nextInt();
int year = ppl.nextInt();
list.add(new Person(name, month, day, year));
}
ppl.close();
return list;
}
/**
*
* Sorts an ArrayList based on the insertion sort algorithm. Modified code based
* on insertion sort from Sort.java in Lesson3SourceCode.
*
*/
// *** change double[] to ArrayList
public static void insertionSort (double[] list)
{
// Temporary variable for the next item to be inserted
// *** change double to Person
double valueToInsert;
int insertPos = 0;
// Iterate through the array taking each array element in turn
// as the next one to be inserted in its correct position.
// This element is placed in its correct position in the array of
// previously sorted elements contained in the lower array indices.
for (int i = 1; i < list.size(); i++)
{
// Hold the next element to be inserted,
// until we find the correct spot
valueToInsert = list.get(i);
insertPos = i;
// Find the correct place to insert this element
// in the lower array indices of already sorted elements
while ((insertPos > 0) && (list.get(insertPos - 1).compareTo(valueToInsert) > 0))
{
// Move elements up the array
// and insert position down
list.set(insertPos, list.get(insertPos - 1));
insertPos--;
}
// We are at the correct position, so insert the element
list.set(insertPos, valueToInsert);
}
}
/**
*
* Sorts an ArrayList based on the selection sort algorithm. Modified code based
* on selection sort from Sort.java in Lesson3SourceCode.
*
*/
// *** change double[] to ArrayList
public static void selectionSort (double[] list)
{
for (int i = 0; i < list.size(); i++)
{
// Find the minimum in the ArrayList through [i..list.length-1]
// *** change double to Person
double currentMin = list[i];
int currentMinIndex = i;
for (int j = i + 1; j < myList.size(); j++)
{
if (currentMin.compareTo(list.get(j)) > 0)
{
curr.
Please complete the assignment listed below.Define and explain, us.docxajoy21
Please complete the assignment listed below.
Define and explain, using at least five sentence or on-task bullet notes for each. Each answer earns up to five points. For each answer, please make five different substantive points, earning one point each.
Transnational corporation
Gentrification
Renewable resources
Desertification
Photochemical smog
Biodiversity
Barriers to migration
Hierarchical diffusion
Militant fundamentalism
Urbanization
Eastern European cities
Hazardous waste
The Endangered Species Act
Subsidence
Water Quality
Deforestation
Wetlands
Central place theory
Soil degradation
Hydraulic fracturing (fracking)
Wind power
Oil sands
Models of urban form
Hinterland
Agglomeration economies
.
Please cite sources for each question. Do not use the same sources f.docxajoy21
Please cite sources for each question. Do not use the same sources for each question. Minimum of 2 resources and 300 words.
Briefly contrast the views of Locke and Rousseau on how children develop.
a) What do ethologists, such as Lorenz, mean by imprinting on a parent-figure?
b) What observations led Bowlby to suggest that imprinting occurs in human infants? That is, what parallels between human infants and other species did he point to?
"For children to learn, we must praise their correct responses and correct their mistakes." Would Montessori agree? Explain.
What did Werner mean by "microgenesis" and "microgenetic mobility?" Give examples. Discuss some valuable aspects of these concepts.
Piaget's critics charge that he made development appear too slow. Discuss this criticism with respect to either: a) object permanence, b) conservation training, or c) Kamii's teaching methods. Then, describe the Piagetian approach.
Compare conventional and postconventional morality in Kohlberg's theory.
.
More Related Content
Similar to #ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx
written in c- please answer the 4 questions and write the functions ba.pdfsravi07
written in c, please answer the 4 questions and write the functions based on the given code.
Thank you
// Write your name here
// Write the compiler used: Visual studio or gcc
// Reminder that your file name is incredibly important. Please do not change it.
// Reminder that we are compiling on Gradescope using GCC.
// READ BEFORE YOU START:
// You are given a partially completed program that creates a linked list of game
items like you'd see in a folder.
// Each item has this information: item name, game name, type of item, item ID.
// The struct 'itemRecord' holds the information of one item. Variety is an enum.
// A linked list of structs called 'list' is declared to hold the list of items.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the
directions carefully.
// You should not modify any of the given code, the return types, or the
parameters. Otherwise, you risk getting compilation errors.
// You are not allowed to modify main().
// You can use all string library functions.
// You will have to write your functions from scratch by looking at what is
expected to be passed into them in the pre-existing functions
// WRITE COMMENTS FOR IMPORANT STEPS IN YOUR CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_ITEMS 15
#define MAX_NAME_LENGTH 25
typedef enum { Health = 0, Equip, Etc } itemType; // enum type
struct itemRecord { // struct for item details
char itemName[MAX_NAME_LENGTH];
char gameName[MAX_NAME_LENGTH];
itemType variety;
unsigned int itemID;
struct itemRecord* next; // pointer to next node
};
struct itemRecord* list = NULL; // declare linked list
'list'
int count = 0; // the number of items
currently stored in the list (initialized to 0)
// functions already pre-implemented last homework
void flushStdIn();
void executeAction(char);
void save(char* fileName);
void display();
// functions that need implementation: add, sort, delete, load
// Implement your own headers.
int main()
{
char* fileName = "Item_List.txt";
load(fileName); // load list of items from file (if it exists).
Initially there will be no file.
char choice = 'i'; // initialized to a dummy value
do
{
printf("\nEnter your selection:\n");
printf("\t a: add a new item\n");
printf("\t d: display item list\n");
printf("\t r: remove a item from list\n");
printf("\t s: sort item list by ID\n");
printf("\t q: quit\n");
choice = getchar();
flushStdIn();
executeAction(choice);
} while (choice != 'q');
save(fileName); // save list of items to file (overwrites file if it
exists)
return 0;
}
// flush out leftover '\n' characters
void flushStdIn()
{
char c;
do c = getchar();
while (c != '\n' && c != EOF);
}
// ask for details from user for the given selection and perform that action
void executeAction(char c)
{
char itemName_input[MAX_NAME_LENGTH], gameName_input[MAX_NAME_LENGTH];
unsigned int itemId_input, add_result = 0;
char itemtype_input[20];
switc.
-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdfganisyedtrd
// Write the compiler used: Visual studio or gcc
// Reminder that your file name is incredibly important. Please do not change it.
// Reminder that we are compiling on Gradescope using GCC.
// READ BEFORE YOU START:
// You are given a partially completed program that creates a linked list of game
items like you'd see in a folder.
// Each item has this information: item name, game name, type of item, item ID.
// The struct 'itemRecord' holds the information of one item. Variety is an enum.
// A linked list of structs called 'list' is declared to hold the list of items.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the
directions carefully.
// You should not modify any of the given code, the return types, or the
parameters. Otherwise, you risk getting compilation errors.
// You are not allowed to modify main().
// You can use all string library functions.
// You will have to write your functions from scratch by looking at what is
expected to be passed into them in the pre-existing functions
// WRITE COMMENTS FOR IMPORANT STEPS IN YOUR CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_ITEMS 15
#define MAX_NAME_LENGTH 25
typedef enum { Health = 0, Equip, Etc } itemType; // enum type
struct itemRecord { // struct for item details
char itemName[MAX_NAME_LENGTH];
char gameName[MAX_NAME_LENGTH];
itemType variety;
unsigned int itemID;
struct itemRecord* next; // pointer to next node
};
struct itemRecord* list = NULL; // declare linked list
'list'
int count = 0; // the number of items
currently stored in the list (initialized to 0)
// functions already pre-implemented last homework
void flushStdIn();
void executeAction(char);
void save(char* fileName);
void display();
// functions that need implementation: add, sort, delete, load
// Implement your own headers.
int main()
{
char* fileName = "Item_List.txt";
load(fileName); // load list of items from file (if it exists).
Initially there will be no file.
char choice = 'i'; // initialized to a dummy value
do
{
printf("\nEnter your selection:\n");
printf("\t a: add a new item\n");
printf("\t d: display item list\n");
printf("\t r: remove a item from list\n");
printf("\t s: sort item list by ID\n");
printf("\t q: quit\n");
choice = getchar();
flushStdIn();
executeAction(choice);
} while (choice != 'q');
save(fileName); // save list of items to file (overwrites file if it
exists)
return 0;
}
// flush out leftover '\n' characters
void flushStdIn()
{
char c;
do c = getchar();
while (c != '\n' && c != EOF);
}
// ask for details from user for the given selection and perform that action
void executeAction(char c)
{
char itemName_input[MAX_NAME_LENGTH], gameName_input[MAX_NAME_LENGTH];
unsigned int itemId_input, add_result = 0;
char itemtype_input[20];
switch (c)
{
case 'a':
// input item record from user
printf("\nEnter item name: ");
fgets(itemName_input, sizeof(itemName_input), s.
Written in C- requires linked lists- Please answer the 4 questions and.pdfsravi07
Written in C, requires linked lists. Please answer the 4 questions and show the output. Thank
you!
// Write your name here
// Write the compiler used: Visual studio or gcc
// Reminder that your file name is incredibly important. Please do not change it.
// Reminder that we are compiling on Gradescope using GCC.
// READ BEFORE YOU START:
// You are given a partially completed program that creates a linked list of game
items like you'd see in a folder.
// Each item has this information: item name, game name, type of item, item ID.
// The struct 'itemRecord' holds the information of one item. Variety is an enum.
// A linked list of structs called 'list' is declared to hold the list of items.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the
directions carefully.
// You should not modify any of the given code, the return types, or the
parameters. Otherwise, you risk getting compilation errors.
// You are not allowed to modify main().
// You can use all string library functions.
// You will have to write your functions from scratch by looking at what is
expected to be passed into them in the pre-existing functions
// WRITE COMMENTS FOR IMPORANT STEPS IN YOUR CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_ITEMS 15
#define MAX_NAME_LENGTH 25
typedef enum { Health = 0, Equip, Etc } itemType; // enum type
struct itemRecord { // struct for item details
char itemName[MAX_NAME_LENGTH];
char gameName[MAX_NAME_LENGTH];
itemType variety;
unsigned int itemID;
struct itemRecord* next; // pointer to next node
};
struct itemRecord* list = NULL; // declare linked list
'list'
int count = 0; // the number of items
currently stored in the list (initialized to 0)
// functions already pre-implemented last homework
void flushStdIn();
void executeAction(char);
void save(char* fileName);
void display();
// functions that need implementation: add, sort, delete, load
// Implement your own headers.
int main()
{
char* fileName = "Item_List.txt";
load(fileName); // load list of items from file (if it exists).
Initially there will be no file.
char choice = 'i'; // initialized to a dummy value
do
{
printf("\nEnter your selection:\n");
printf("\t a: add a new item\n");
printf("\t d: display item list\n");
printf("\t r: remove a item from list\n");
printf("\t s: sort item list by ID\n");
printf("\t q: quit\n");
choice = getchar();
flushStdIn();
executeAction(choice);
} while (choice != 'q');
save(fileName); // save list of items to file (overwrites file if it
exists)
return 0;
}
// flush out leftover '\n' characters
void flushStdIn()
{
char c;
do c = getchar();
while (c != '\n' && c != EOF);
}
// ask for details from user for the given selection and perform that action
void executeAction(char c)
{
char itemName_input[MAX_NAME_LENGTH], gameName_input[MAX_NAME_LENGTH];
unsigned int itemId_input, add_result = 0;
char itemtype_input[20];
switch (c.
Written in C- requires linked lists- Please answer the 4 questions and (1).pdfsravi07
Written in C, requires linked lists. Please answer the 4 questions and show the output. Thank
you!
// Write your name here
// Write the compiler used: Visual studio or gcc
// Reminder that your file name is incredibly important. Please do not change it.
// Reminder that we are compiling on Gradescope using GCC.
// READ BEFORE YOU START:
// You are given a partially completed program that creates a linked list of game
items like you'd see in a folder.
// Each item has this information: item name, game name, type of item, item ID.
// The struct 'itemRecord' holds the information of one item. Variety is an enum.
// A linked list of structs called 'list' is declared to hold the list of items.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the
directions carefully.
// You should not modify any of the given code, the return types, or the
parameters. Otherwise, you risk getting compilation errors.
// You are not allowed to modify main().
// You can use all string library functions.
// You will have to write your functions from scratch by looking at what is
expected to be passed into them in the pre-existing functions
// WRITE COMMENTS FOR IMPORANT STEPS IN YOUR CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_ITEMS 15
#define MAX_NAME_LENGTH 25
typedef enum { Health = 0, Equip, Etc } itemType; // enum type
struct itemRecord { // struct for item details
char itemName[MAX_NAME_LENGTH];
char gameName[MAX_NAME_LENGTH];
itemType variety;
unsigned int itemID;
struct itemRecord* next; // pointer to next node
};
struct itemRecord* list = NULL; // declare linked list
'list'
int count = 0; // the number of items
currently stored in the list (initialized to 0)
// functions already pre-implemented last homework
void flushStdIn();
void executeAction(char);
void save(char* fileName);
void display();
// functions that need implementation: add, sort, delete, load
// Implement your own headers.
int main()
{
char* fileName = "Item_List.txt";
load(fileName); // load list of items from file (if it exists).
Initially there will be no file.
char choice = 'i'; // initialized to a dummy value
do
{
printf("\nEnter your selection:\n");
printf("\t a: add a new item\n");
printf("\t d: display item list\n");
printf("\t r: remove a item from list\n");
printf("\t s: sort item list by ID\n");
printf("\t q: quit\n");
choice = getchar();
flushStdIn();
executeAction(choice);
} while (choice != 'q');
save(fileName); // save list of items to file (overwrites file if it
exists)
return 0;
}
// flush out leftover '\n' characters
void flushStdIn()
{
char c;
do c = getchar();
while (c != '\n' && c != EOF);
}
// ask for details from user for the given selection and perform that action
void executeAction(char c)
{
char itemName_input[MAX_NAME_LENGTH], gameName_input[MAX_NAME_LENGTH];
unsigned int itemId_input, add_result = 0;
char itemtype_input[20];
switch (c.
you will implement some sorting algorithms for arrays and linked lis.pdfclearvisioneyecareno
you will implement some sorting algorithms for arrays and linked lists.
Insertion Sort and Quicksort of an array
Implement the insertion sort and quicksort for an integer array. The functions are defined in the
"sorting.h" header file.
/**
* @brief Insertion sort algorithm
* @param array Array to be sorted. The array is modified in place.
* @param lowindex Lowest index of the array
* @param highindex Highest index of the array
* @param reversed If reversed = true, the array should be sorted in descending order, otherwise
in ascending order
*/
void insertionSort(int array[], int lowindex, int highindex, bool reversed = false);
and
**
* @brief Quick sort algorithm
*
* @param array Array to be sorted. The array is modified in place.
* @param lowindex Lowest index of the array
* @param highindex Highest index of the array
* @param reversed If reversed = true, the array should be sorted in descending order, otherwise
in ascending order
*/
void quickSort(int array[], int lowindex, int highindex, bool reversed = false);
The array should be sorted in place. Compared to the examples in the textbook, those functions
have an additional parameter reversed. If reversed = true, the array should be sorted in
descending order, otherwise in ascending order. You should complete the implementations of
those two functions in the "sorting_basic.cpp" file.
A better quicksort algorithm
Quicksort is a very fast comparison sorting algorithm, especially wheb the array or list gets large.
However, when the arrays/lists are small enough, quicksort may run slower than some of the
(n^2) algorithms. This might not seem important until you note that when sorting a large array
with quicksort, many small sublists must be sorted. While the savings on sorting one small list
with a faster algorithm might be negligible, sorting hundreds of small lists with a faster algorithm
can make a difference in the overall efficiency of the sort. For this part of the assignment, you
will combine quicksort with another sorting algorithm to build a faster sorting algorithm. One
option is to
use quicksort until the array/list gets small enough, and then use insertion sort or another sort to
sort the small arrays/lists
What does "small enough" mean? You can try a percentage of the list (say, 5% or 10%), or an
absolute number (5 elements, 8 elements, 10 elements, 15 elements, 100 elements, etc), or
something else of your choosing. Based on your tests, choose the one that is the most efficient.
You should also tests to ensure that your hybrid quicksort has reasonable performance on all lists
-- most notably, it should be efficient on sorted and inverse sorted lists as well as random lists.
The definition of the hybrid quicksort function is as the following:
/**
* @brief A hybrid of insertion sort and quick sort algorithm. The algorithm is based on the idea
that if the array is short, it is better to use insertion sort.
* It uses quicksort until the list gets small enough, and then uses insertion s.
Dividing a linked list into two sublists of almost equal sizesa. A.pdftesmondday29076
Dividing a linked list into two sublists of almost equal sizes
a. Add the operation divideMid to the class linkedListType as follows:
Consider the following statements:
unorderedLinkedList myList;
unorderedLinkedList subList;
Suppose myList points to the list with elements 34 65 27 89 12 (in this order). The statement:
myList.divideMid(subList); divides myList into two sublists: myList points to the list with the
elements 34 65 27,
and subList points to the sublist with the elements 89 12.
b. Write the definition of the function template to implement the operation divideMid. Also,
write a program to test your function. The header files linkedList.h and unorderedLinkedList.h
are supplied. Your test program should produce output similar to this:
Turn in:
linkedList.h with modifications
Your test program.
(C++)
Required code is below:
#ifndef H_UnorderedLinkedList
#define H_UnorderedLinkedList
#include \"linkedList.h\"
using namespace std;
template
class unorderedLinkedList: public linkedListType
{
public:
bool search(const Type& searchItem) const;
//Function to determine whether searchItem is in the list.
//Postcondition: Returns true if searchItem is in the
// list, otherwise the value false is
// returned.
void insertFirst(const Type& newItem);
//Function to insert newItem at the beginning of the list.
//Postcondition: first points to the new list, newItem is
// inserted at the beginning of the list,
// last points to the last node in the
// list, and count is incremented by 1.
void insertLast(const Type& newItem);
//Function to insert newItem at the end of the list.
//Postcondition: first points to the new list, newItem
// is inserted at the end of the list,
// last points to the last node in the
// list, and count is incremented by 1.
void deleteNode(const Type& deleteItem);
//Function to delete deleteItem from the list.
//Postcondition: If found, the node containing
// deleteItem is deleted from the list.
// first points to the first node, last
// points to the last node of the updated
// list, and count is decremented by 1.
};
template
bool unorderedLinkedList::
search(const Type& searchItem) const
{
nodeType *current; //pointer to traverse the list
bool found = false;
current = this->first; //set current to point to the first
//node in the list
while (current != NULL && !found) //search the list
if (current->info == searchItem) //searchItem is found
found = true;
else
current = current->link; //make current point to
//the next node
return found;
}//end search
template
void unorderedLinkedList::insertFirst(const Type& newItem)
{
nodeType *newNode; //pointer to create the new node
newNode = new nodeType; //create the new node
newNode->info = newItem; //store the new item in the node
newNode->link = this->first; //insert newNode before first
this->first = newNode; //make first point to the
//actual first node
this->count++; //increment count
if (this->last == NULL) //if the list was empty, newNode is also
//the last node in the list
this->l.
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfrajkumarm401
Complete the provided partial C++ Linked List program. Main.cpp is given and Link list header
file is also given. The given testfile listmain.cpp is given for demonstration of unsorted list
functionality. The functions header file is also given. Complete the functions of the header file
linked_list.h below.
=========================================================
// listmain.cpp
#include \"Linked_List.h\"
int main(int argc, char **argv)
{
float f;
Linked_List *theList;
cout << \"Simple List Demonstration\ \";
cout << \"(List implemented as an Array - Do not try this at home)\ \ \";
cout << \"Create a list and add a few tasks to the list\";
theList = new Linked_List(); // Instantiate a list object
theList->Insert(5, 3.1f); // Note: The argument to the funtion should be a float
theList->Insert(1, 5.6f); // A constant real number like 3.1 is interpreted as
theList->Insert(3, 8.3f); // a double unless it is explicitly defined as a float
theList->Insert(2, 7.4f); // by adding an \'f\' to the end of the number.
theList->Insert(4, 2.5f);
// Show what is in the list
theList->PrintList();
// Test the list length function
cout << \"\ List now contains \" << theList->ListLength() << \"items.\ \ \";
// Test delete function
cout << \"Testing delete of last item in list.\ \";
theList->Delete(4);
theList->PrintList();
// Test delete function
cout << \"Testing delete of first item in list.\ \";
theList->Delete(5);
theList->PrintList();
// Test delete function
cout << \"Testing delete of a middle item in list.\ \";
theList->Delete(3);
theList->PrintList();
// Test delete function with a known failure argument
cout << \"Testing failure in delete function.\ \";
if(theList->Delete(4))
cout << \"Oops! Should not have been able to delete.\ \";
else
cout << \"Unable to locate item to delete.\ \";
// Test search (known failure)
cout << \"Testing Search function. Search for key 3\ \";
if(theList->Search(3, &f))
cout << \"Search result: theData = %f\ \", f;
else
cout << \"Search result: Unable to locate item in list\ \";
// Test search (known success)
cout << \"Testing Search function. Search for key 2\ \";
if(theList->Search(2, &f))
cout << \"Search result: theData = \" << f << \"\ \";
else
cout << \"Search result: Unable to locate item in list\ \";
cout << \"\ \ End list demonstration...\";
return 0;
}
=====================================================================
===================
// linked_list.h functions
#include
using namespace std;
// Define a structure to use as the list item
struct ListItem
{
int key;
float theData;
ListItem *next;
};
class Linked_List
{
private:
ListItem *head; // Pointer to head of the list
public:
Linked_List(); // Class constructor
~Linked_List(); // Class destuctor
void ClearList(); // Remove all items from the list
bool Insert(int key, float f);// Add an item to the list
bool Delete(int key); // Delete an item from the list
bool Search(int key, float *retVal); // Search for an item in the list
int ListLength(); // Return numb.
-- Reminder that your file name is incredibly important- Please do not.docxAdamq0DJonese
// Reminder that your file name is incredibly important. Please do not change it.
// Reminder that we are compiling on Gradescope using GCC.
// READ BEFORE YOU START:
// You are given a partially completed program that creates a list of game items
like you'd see in a folder.
// Each item has this information: item's name, game's name, type of item, item ID.
// The struct 'itemRecord' holds information of one item. Variety is an enum.
// An array of structs called 'list' is made to hold the list of items.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the
directions carefully.
// You should not modify any of the given code, the return types, or the
parameters. Otherwise, you risk getting compilation errors.
// You are not allowed to modify main().
// You can use string library functions.
// WRITE COMMENTS FOR IMPORANT STEPS IN YOUR CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma warning(disable: 4996) // for Visual Studio
Only
#define MAX_ITEMS 15
#define MAX_NAME_LENGTH 25
typedef enum { Health = 0, Equip, Etc } itemType; // enum type
struct itemRecord { // struct for item details
char itemName[MAX_NAME_LENGTH];
char gameName[MAX_NAME_LENGTH];
itemType variety;
unsigned int itemID;
};
struct itemRecord list[MAX_ITEMS]; // declare list of items
int count = 0; // the number of items
currently stored in the list (initialized to 0)
// functions already implmented
void flushStdIn();
void executeAction(char);
void save(char* fileName);
void display();
// functions that need implementation:
int add(char* itemName_input,
char* gameName_input,
char* variety_input,
unsigned int idNumber_input); // 10 points
void sort(); // 10 points
int delete(unsigned int idNumber_input); // 10 points
void load(char* fileName); // 10 points
int main()
{
char* fileName = "Item_List.txt";
load(fileName); // load list of items from
file (if it exists). Initially there will be no file.
char choice = 'i'; // initialized to a dummy
value
do
{
printf("\nEnter your selection:\n");
printf("\t a: add a new item\n");
printf("\t d: display item list\n");
printf("\t r: remove an item from list\n");
printf("\t s: sort item list by ID\n");
printf("\t q: quit\n");
choice = getchar();
flushStdIn();
executeAction(choice);
} while (choice != 'q');
save(fileName); // save list of items to file
(overwrites file, if it exists)
return 0;
}
// flush out leftover '\n' characters
void flushStdIn()
{
char c;
do c = getchar();
while (c != '\n' && c != EOF);
}
// ask for details from user for the given selection and perform that action
void executeAction(char c)
{
char itemName_input[MAX_NAME_LENGTH], gameName_input[MAX_NAME_LENGTH];
unsigned int idNumber_input, add_result = 0;
char variety_input[20];
switch (c)
{
case 'a':
// input item record from user
printf("\nEnter item name: ").
Complete a C++ class implementation for a linked-list of sorted (asc.pdfshahidqamar17
Complete a C++ class implementation for a linked-list of sorted (ascending) positive integers.
The class name for this class is LLSortedPosInt and its specification is outlined in the file
LLSortedPosInt.h. The specification is accompained by two other files: (1) a partial
implementation of the class in the file LLSortedPosInt.cpp and (2) a test program called
testLL.cpp. You are to complete the partial implementation of the class by writing code for the
stubbed member functions. You may NOT make any changes to the specification file. You may
develop and test your class implementation either under Visual Studio or linux; however, your
program must be executable under linux, because that is where it will be tested.
Details: Linked lists are useful data structures for storing data records, particularly in situations
where the items are to be kept sorted, the number of records are dynamic (i.e., changing during
the course of the program’s execution) and the maximum number is arbitrary. In this exercise,
you’ll get a chance to complete the implementation of a linked-list specification. In doing so,
you’ll learn not only how to manipulate pointer objects, but also begin to learn how to create a
new and useful data type.
To get started, I have written a simple linked list definition within the header file called
LLSortedPosInt.h. My definition is, of course, not the only way to define a linked list, but it is
suitable for our simple project. Accompanying the definition is a partial implementation in the
source file LLSortedPosInt.cpp. You are to edit this file using the comments in the file and the
instructions below. Altogether, this assignment asks you to implement 13 functions.
To help with testing your functions implementations, I have provided a main program. This main
program is in the source file testLL.cpp. One quick way to repeatedly exercise your function
tests is to write a test file (I called mine testCases.txt) and use input re-direction.
The 13 functions you must add to complete the implementation are as follows:
a. Constructors (4): Classes must have constructors to initialize instances of the objects. The
constructors you will implement for this project are
i. A default constructor
ii. A constructor taking a single int parameter
iii. A constructor which builds a list from an array of integers
iv. A copy constructor
b. Destructor (1): Because the class specification includes a pointer among the attributes, you
will need to implement a destructor to delete (i.e., free or release) any storage allocated in the
constructors or other member functions.
c. Boolean Functions (2): You are to implement two Boolean functions
i. A function isEmpty() which returns true if the associated list contains no data elements,
and returns false otherwise.
ii. A function containsElement(key) which returns true is key is an element in the list and
returns false otherwise.
d. Member Operator Functions (3): When a class has a pointer among its attributes, as
.
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdfEdwardw5nSlaterl
Need Help!! C++
#include<iostream>
#include"linkedlist.h"
using namespace std;
/**
* @brief Destructor to destroy all nodes and release memory
*/
LinkedList::~LinkedList() {
//TODO: Add code here. Make sure memory is released properly.
}
/**
* @brief Purpose: Checks if the list is empty
* @return true if the list is empty, false otherwise
*/
bool LinkedList::isEmpty() const {
// TODO: Add code here
return count == 0;
}
/**
* @brief Get the number of nodes in the list
* @return int The number of nodes in the list
*/
int LinkedList::length() const{
//TODO: Add code here
}
/**
* @brief Convert the list to a string
*
*/
string LinkedList::toString() {
string str = "[";
Node *ptr = front;
if (ptr != nullptr) {
// Head node is not preceded by separator
str += to_string(ptr->val);
ptr = ptr->next;
}
while (ptr != nullptr) {
str += ", " + to_string(ptr->val);
ptr = ptr->next;
}
str += "]";
return str;
}
/**
* @brief Displays the contents of the list
*/
void LinkedList::displayAll() {
cout << toString() << endl;
}
//TODO: Add comments
void LinkedList::addRear(T val) {
// TODO: Add code here
// consider the two cases of whether the list was empty
}
//TODO: Add comments
void LinkedList::addFront(T val) {
// TODO: Add code here
// consider the two cases of whether the list was empty
}
//TODO: Add comments
bool LinkedList::deleteFront(T &OldNum) {
// TODO: Add code here
// consider if the list was empty and return false if the list is empty
// consider the special case of deleting the only node in the list
}
//TODO: Add comments
bool LinkedList::deleteRear(T &OldNum) {
// TODO: Add code here
// consider if the list was empty and return false if the list is empty
// consider the special case of deleting the only node in the list
}
/* --- harder ones for test 2 and 3 -- */
/**
* @brief Delete a node at a given position from the list. The
* node at position pos is deleted and the value of the deleted node is returned in val.
* The valid range of pos is 1 to count. pos = 1 is the first node, and pos = count is the last node.
* @param pos: position of the node to be deleted
* @param val: it is set to the value of the node to be deleted
* @return true: if the node was deleted successfully
* @return false: if the node was not deleted successfully because the position was out of range
*/
bool LinkedList::deleteAt(int pos, T &val) {
//TODO: Add code here
// check if the pos is valid first, then move the ptr to the rigth positon
// consider the special case of deleting the first node and the last node
// Do not forget to set value.
}
/**
* @brief Insert a value at a specified position in the list. The valid pos is in the range of 1 to
count+1.
* The value will be inserted before the node at the specified position. if pos = 1, the value will be
inserted
* at the front of the list. if pos = count+1, the value will be inserted at the rear of the list.
* @param pos: position to insert the value at.
* @param val: value to insert.
* @return true: if the value was inserte.
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...davidwarner122
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Below is a given ArrayList class and Main class in search algorithms. Please modify the existing program so it can time the sequential search and the binary search methods several times each for randomly generated values, and record the results in a table. Do not time individual searches, but groups of them. For example, time 100 searches together or 1,000 searches together. Compare the running times of these two search methods that are obtained during the experiment.
please i need help Im writing a program to test the merge sort alg.pdfezonesolutions
please i need help I\'m writing a program to test the merge sort algorithm for linked lists.
I need to Print the list before being sorted and the list after sorting the elements
here is my code only help in test program the four classes are ok except the test program.
TEST PROGRAM
import java.io.*;
import java.util.*;
public class Ch9_ProgExercise7 {
Scanner input = new Scanner(System.in);
public static void main(String[] args) throws IOException {
OrderedLinkedList list
= new OrderedLinkedList(); //Line 1
IntElement num = new IntElement(); //Line 2
// Prompt the user to enter some integers
System.out.println(\"Enter integers numbers \");
String temp = input.hasnextLine();
String[] split = temp.split(\" \");
for (int i = 0; i < split.length; i++) {
Integer a = Integer.parseInt(split[i]);
// insert the intgers into the list you created above
num.setNum(a);
list.insertNode(num);
}
System.out.println();
// Print the list before being sorted
// call the mergesort method
System.out.println();
// print the list after sorting the elements
}
}
ORDEREDLICKEDLIST CLASS
public class OrderedLinkedList extends LinkedListClass
{
//default constructor
public OrderedLinkedList()
{
super();
}
//copy constructor
public OrderedLinkedList(OrderedLinkedList otherList)
{
super(otherList);
}
public void linkedInsertionSort()
{
LinkedListNode lastInOrder;
LinkedListNode firstOutOfOrder;
LinkedListNode current;
LinkedListNode trailCurrent;
lastInOrder = first;
if(first == null)
System.out.println(\"Cannot sort an empty list\");
else
if(first.link == null)
System.out.println(\"The list is of length 1. \"
+ \"Already in order\");
else
while(lastInOrder.link != null)
{
firstOutOfOrder = lastInOrder.link;
if(firstOutOfOrder.info.compareTo(first.info) < 0)
{
lastInOrder.link = firstOutOfOrder.link;
firstOutOfOrder.link = first;
first = firstOutOfOrder;
}
else
{
trailCurrent = first;
current = first.link;
while(current.info.compareTo(firstOutOfOrder.info) < 0)
{
trailCurrent = current;
current = current.link;
}
if(current != firstOutOfOrder)
{
lastInOrder.link = firstOutOfOrder.link;
firstOutOfOrder.link = current;
trailCurrent.link = firstOutOfOrder;
}
else
lastInOrder = lastInOrder.link;
}
}
}//end linkedInsertionSort
//Method to determine whether searchItem is in
//the list.
//Postcondition: Returns true if searchItem is found
// in the list; otherwise, it returns
// false.
public boolean search(DataElement searchItem)
{
LinkedListNode current; //variable to traverse the list
boolean found;
current = first; //set current to point to the first
//node in the list
found = false; //set found to false
while(current != null && !found ) //search the list
if(current.info.compareTo(searchItem) >= 0)
found = true;
else
current = current.link; //make current point to
//the next node
if(found)
found = current.info.equals(searchItem);
return found;
}
//Method to insert insertItem in the list
//Postcondition: first points to the new list,
// newItem is inserted at the proper place
//.
In this homework- you will write a program modify program you wrote in.pdfEvanpZjSandersony
In this homework, you will write a program modify program you wrote in Homework3.
2) Modify the MyList class that you wrote for Programming challenge 1 so the type parameter T
should accept any type that implements the Comparable interface. Test the class in a program
that creates one instance of MyList to store Integers, and another instance to store Strings. Input
two numbers from the user and insert them into the first instance of Modified MyList.
Input name and City and insert the two strings into the second instance of modified MyList class.
Then display the contents of the the two instances.
here is the program to modify
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// part 1 code.
// creating a Number list
MyList<Number> intList = new MyList<>();
// adding the numbers mentioned in the question
intList.add(2);
intList.add(5);
intList.add(-13);
intList.add(11);
intList.add(12);
// creating a Double list, adding double values to it
MyList<Double> doubleList = new MyList<>();
doubleList.add(27.3);
doubleList.add(5.7);
doubleList.add(-23.9);
doubleList.add(1.11);
doubleList.add(5.12);
System.out.println("PART 1");
// printing largest and smallest of both lists
System.out.println("The Integer largest: \n" + intList.largest());
System.out.println("The Integer smallest: \n" + intList.smallest());
System.out.println("The Double largest: \n" + doubleList.largest());
System.out.println("The Double smallest: \n" + doubleList.smallest());
}
}
//MyList class, which is defined outside Generics1 class BUT still within Generics1.java file.
class MyList<T extends Number> {
// defining an array list as storage
ArrayList<T> list;
// constructor initializing list
public MyList() {
// initializing array list
list = new ArrayList<>();
}
// method to add a value to the list
public void add(T value) {
list.add(value);
}
// method to return the largest element on the list
public T largest() {
// assuming list is not empty, taking first value as largest
T max = list.get(0);
for (int i = 1; i < list.size(); i++) {
// comparing element at i with max using doubleValue() of Number class
if (list.get(i).doubleValue() > max.doubleValue()) {
max = list.get(i);
}
}
return max;
}
// method to return the smallest element on the list
public T smallest() {
// assuming list is not empty, taking first value as smallest
T min = list.get(0);
for (int i = 1; i < list.size(); i++) {
// comparing element at i with min using doubleValue() of Number class
if (list.get(i).doubleValue() < min.doubleValue()) {
min = list.get(i);
}
}
return min;
}
// returns the elemnt at a given position
public T get(int index) {
return list.get(index);
}
}
Here is the sample input/outPut
TestCase1:
PART 2
Please enter a number:
30
Please another number:
20
Please enter your name:
John
Please enter your City:
Los Angeles
First number is 30
Second number is 20
Name is: John
City is: Los Angeles
TestCase2:
PART 2
Please enter a number:
.
--INSTRUCTION- --It helps to first create if-then-else structure to fi.pdfAdrianEBJKingr
//INSTRUCTION:
//It helps to first create if-then-else structure to fill in later.
//- Make sure PURPOSE and PARAMETER comments are given in detail
// Add sufficient comments to your code body to describe what it does.
// - Make sure all if-then-else are commented describing which case it is
// - Make sure all local variables are described fully with their purposes
//Complete the TODO parts.
// ====================================================
//Complier: g++
//File type: linkedList.cpp implementation file
//=====================================================
#include<iostream>
#include"linkedlist.h"
using namespace std;
//cunstructor that initializes an empty list
LinkedList::LinkedList() {
front = nullptr ;
rear = nullptr ;
count = 0;
}
/**
* @brief Destructor to destroy all nodes and release memory
*/
LinkedList::~LinkedList() {
Node *p, *q;
p = front;
while (p != nullptr ) {
q = p->next;
delete p;
p = q;
}
}
/**
* @brief Purpose: Checks if the list is empty
* @return true if the list is empty, false otherwise
*/
bool LinkedList::isEmpty() const {
// TODO: Add code here
return count == 0;
}
/**
* @brief Get the number of nodes in the list
* @return int The number of nodes in the list
*/
int LinkedList::length() const {
return count;
}
/**
* @brief Convert the list to a string
*
*/
string LinkedList::toString() {
string str = "[";
Node *ptr = front;
if (ptr != nullptr ) {
// Head node is not preceded by separator
str += to_string(ptr->val);
ptr = ptr->next;
}
while (ptr != nullptr ) {
str += ", " + to_string(ptr->val);
ptr = ptr->next;
}
str += "]";
return str;
}
/**
* @brief Displays the contents of the list
*/
void LinkedList::displayAll() {
cout << toString() << endl;
}
//Add a node to the end of the list
void LinkedList::addRear(T val) {
Node *p = new Node;
p->val = val;
p->next = nullptr ;
if (isEmpty()) {
front = p;
}
else {
rear->next = p;
}
rear = p;
count++;
// consider the two cases of whether the list was empty
}
//Add a node to the front of the list
void LinkedList::addFront(T val) {
Node *p = new Node;
p->val = val;
p->next = front;
if (isEmpty()) {
rear = p;
}
front = p;
count++;
// consider the two cases of whether the list was empty
}
//Delete the first node of the list
bool LinkedList::deleteFront(T &OldNum) {
if (isEmpty()) {
return false ;
}
Node *p = front;
OldNum = p->val;
front = front->next;
if (front == nullptr ) {
rear = nullptr ;
}
delete p;
count--;
return true ;
// consider if the list was empty and return false if the list is empty
// consider the special case of deleting the only node in the list
}
//Delete the last node of the list
bool LinkedList::deleteRear(T &OldNum) {
if (isEmpty()) {
return false ;
}
Node *p = rear;
OldNum = p->val;
if (front == rear) {
front = rear = nullptr ;
}
else {
Node *q = front;
while (q->next != rear) {
q = q->next;
}
rear = q;
q->next = nullptr ;
}
delete p;
count--;
return true ;
// consider if the list was empty and return false if the list is empty
// consider the specia.
In C pls -- Write your name here -- Write the compiler used- Visual st.docxBlake0FxCampbelld
In C pls
// Write your name here
// Write the compiler used: Visual studio or gcc
// Reminder that your file name is incredibly important. Please do not change it.
// Reminder that we are compiling on Gradescope using GCC.
// READ BEFORE YOU START:
// You are given a partially completed program that creates a list of game items
like you'd see in a folder.
// Each item has this information: item's name, game's name, type of item, item ID.
// The struct 'itemRecord' holds information of one item. Variety is an enum.
// An array of structs called 'list' is made to hold the list of items.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the
directions carefully.
// You should not modify any of the given code, the return types, or the
parameters. Otherwise, you risk getting compilation errors.
// You are not allowed to modify main().
// You can use string library functions.
// WRITE COMMENTS FOR IMPORANT STEPS IN YOUR CODE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma warning(disable: 4996) // for Visual Studio
Only
#define MAX_ITEMS 15
#define MAX_NAME_LENGTH 25
typedef enum { Health = 0, Equip, Etc } itemType; // enum type
struct itemRecord { // struct for item details
char itemName[MAX_NAME_LENGTH];
char gameName[MAX_NAME_LENGTH];
itemType variety;
unsigned int itemID;
};
struct itemRecord list[MAX_ITEMS]; // declare list of items
int count = 0; // the number of items
currently stored in the list (initialized to 0)
// functions already implmented
void flushStdIn();
void executeAction(char);
void save(char* fileName);
void display();
// functions that need implementation:
int add(char* itemName_input,
char* gameName_input,
char* variety_input,
unsigned int idNumber_input); // 10 points
void sort(); // 10 points
int delete(unsigned int idNumber_input); // 10 points
void load(char* fileName); // 10 points
int main()
{
char* fileName = "Item_List.txt";
load(fileName); // load list of items from
file (if it exists). Initially there will be no file.
char choice = 'i'; // initialized to a dummy
value
do
{
printf("\nEnter your selection:\n");
printf("\t a: add a new item\n");
printf("\t d: display item list\n");
printf("\t r: remove an item from list\n");
printf("\t s: sort item list by ID\n");
printf("\t q: quit\n");
choice = getchar();
flushStdIn();
executeAction(choice);
} while (choice != 'q');
save(fileName); // save list of items to file
(overwrites file, if it exists)
return 0;
}
// flush out leftover '\n' characters
void flushStdIn()
{
char c;
do c = getchar();
while (c != '\n' && c != EOF);
}
// ask for details from user for the given selection and perform that action
void executeAction(char c)
{
char itemName_input[MAX_NAME_LENGTH], gameName_input[MAX_NAME_LENGTH];
unsigned int idNumber_input, add_result = 0;
char variety_input[20];
swi.
Please help solve this in C++ So the program is working fin.pdfankit11134
Please help solve this in C++. So the program is working fine but when submitting it, it gives me a
code -11, and I believe the problem is that after inserting the numbers it removes them one by one
until the last in the list, and when it tries to remove the last number in the list that is when it
counters the problem. Below is the full code but you just need to change something in the
SortedNumberList.h file under the bool remove function.
4.18 LAB: Sorted number list implementation with linked lists Step 1: Inspect the Node.h file
Inspect the class declaration for a doubly-linked list node in Node.h. Access Node.h by clicking on
the orange arrow next to main.cpp at the top of the coding window. The Node class has three
member variables: - a double data value, - a pointer to the next node, and - a pointer to the
previous node. Each member variable is protected. So code outside of the class must use the
provided getter and setter member functions to get or set a member variable. Node.h is read only,
since no changes are required. Step 2: Implement the Insert() member function A class for a
sorted, doubly-linked list is declared in SortedNumberList.h. Implement the SortedNumberList
class's Insert() member function. The function must create a new node with the parameter value,
then insert the node into the proper sorted position in the linked list. Ex: Suppose a
SortedNumberList's current list is 2347.2586, then Insert(33.5) is called. A new node with data
value 33.5 is created and inserted between 23 and 47.25, thus preserving the list's sorted order
and yielding: 2335.547.2586Step 3: Test in develop mode Code in main() takes a space-
separated list of numbers and inserts each into a SortedNumberList. The list is displayed after
each insertion. Ex: If input is 77154263.5 then output is: List after inserting 77 : 77 List after
inserting 15 : 1577 List after inserting -42 : -421577 List after inserting 63.5: -421563.577 Try
various program inputs, ensuring that each outputs a sorted list. Step 4: Implement the Remove()
member function Implement the SortedNumberList class's Remove(0 member function. The
function takes a parameter for the number to be removed from the list. If the number does not
exist in the list, the list is not changed and false is returned. Otherwise, the first instance of the
number is removed from the list and true is returned. Uncomment the commented-out part in
main() that reads a second input line and removes numbers from the list. Test in develop mode to
ensure that insertion and removal both work properly, then submit code for grading. Ex: If input is
841972841961 then output is: List after inserting 84: 84 List after inserting 72 : 7284 List after
inserting 19: 1972 84 List after inserting 61: 1961 : 72 8 List after removing 19: 6172 84 List after
removing 84: 6172Current file: main.cpp - // Insert each value and show the sorted List's contents
after each insertion sortedNumberList list; for (auto term : terms) { doubl.
JAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdfsuresh640714
JAVA help
Need bolded lines fixed for it to compile. Thank you!
public class PersonSort
{
// Test file. Format is \"STRING int int int\"
static final String PERSON_FILE = \".\\\\src\\\\Persons.txt\";
public static void main(String[] args) throws FileNotFoundException
{
// Create new ArrayList and populate from test file
ArrayList list1 = new ArrayList();
populate(list1);
// Create new array with same people
ArrayList list2 = new ArrayList(list1);
insertionSort(list1);
// Print result of sort
System.out.println(\"INSERTION SORT\");
// *** foreach Person p in list1
{
System.out.println(p.toString());
}
selectionSort(list2);
System.out.println();
System.out.println(\"SELECTION SORT\");
// *** foreach Person p in list2
{
System.out.println(p.toString());
}
}
/*
* populate - this method reads the Persons.txt file and creates an array list
*
*/
public static ArrayList populate(ArrayList list)
throws IOException
{
// Scan in the file
File people = new File(PERSON_FILE);
Scanner ppl = new Scanner(people);
// While we have a next line, create a new Person and add it to the list
while (ppl.hasNextLine())
{
String name = ppl.next();
int month = ppl.nextInt();
int day = ppl.nextInt();
int year = ppl.nextInt();
list.add(new Person(name, month, day, year));
}
ppl.close();
return list;
}
/**
*
* Sorts an ArrayList based on the insertion sort algorithm. Modified code based
* on insertion sort from Sort.java in Lesson3SourceCode.
*
*/
// *** change double[] to ArrayList
public static void insertionSort (double[] list)
{
// Temporary variable for the next item to be inserted
// *** change double to Person
double valueToInsert;
int insertPos = 0;
// Iterate through the array taking each array element in turn
// as the next one to be inserted in its correct position.
// This element is placed in its correct position in the array of
// previously sorted elements contained in the lower array indices.
for (int i = 1; i < list.size(); i++)
{
// Hold the next element to be inserted,
// until we find the correct spot
valueToInsert = list.get(i);
insertPos = i;
// Find the correct place to insert this element
// in the lower array indices of already sorted elements
while ((insertPos > 0) && (list.get(insertPos - 1).compareTo(valueToInsert) > 0))
{
// Move elements up the array
// and insert position down
list.set(insertPos, list.get(insertPos - 1));
insertPos--;
}
// We are at the correct position, so insert the element
list.set(insertPos, valueToInsert);
}
}
/**
*
* Sorts an ArrayList based on the selection sort algorithm. Modified code based
* on selection sort from Sort.java in Lesson3SourceCode.
*
*/
// *** change double[] to ArrayList
public static void selectionSort (double[] list)
{
for (int i = 0; i < list.size(); i++)
{
// Find the minimum in the ArrayList through [i..list.length-1]
// *** change double to Person
double currentMin = list[i];
int currentMinIndex = i;
for (int j = i + 1; j < myList.size(); j++)
{
if (currentMin.compareTo(list.get(j)) > 0)
{
curr.
Similar to #ifndef MYLIST_H_ #define MYLIST_H_#includeiostream #include.docx (20)
Please complete the assignment listed below.Define and explain, us.docxajoy21
Please complete the assignment listed below.
Define and explain, using at least five sentence or on-task bullet notes for each. Each answer earns up to five points. For each answer, please make five different substantive points, earning one point each.
Transnational corporation
Gentrification
Renewable resources
Desertification
Photochemical smog
Biodiversity
Barriers to migration
Hierarchical diffusion
Militant fundamentalism
Urbanization
Eastern European cities
Hazardous waste
The Endangered Species Act
Subsidence
Water Quality
Deforestation
Wetlands
Central place theory
Soil degradation
Hydraulic fracturing (fracking)
Wind power
Oil sands
Models of urban form
Hinterland
Agglomeration economies
.
Please cite sources for each question. Do not use the same sources f.docxajoy21
Please cite sources for each question. Do not use the same sources for each question. Minimum of 2 resources and 300 words.
Briefly contrast the views of Locke and Rousseau on how children develop.
a) What do ethologists, such as Lorenz, mean by imprinting on a parent-figure?
b) What observations led Bowlby to suggest that imprinting occurs in human infants? That is, what parallels between human infants and other species did he point to?
"For children to learn, we must praise their correct responses and correct their mistakes." Would Montessori agree? Explain.
What did Werner mean by "microgenesis" and "microgenetic mobility?" Give examples. Discuss some valuable aspects of these concepts.
Piaget's critics charge that he made development appear too slow. Discuss this criticism with respect to either: a) object permanence, b) conservation training, or c) Kamii's teaching methods. Then, describe the Piagetian approach.
Compare conventional and postconventional morality in Kohlberg's theory.
.
Please choose one of the following questions to answer for this week.docxajoy21
Please choose one of the following questions to answer for this week's assignment. When you respond to your fellow classmates this week, please choose someone who answered a different question than your own. This will help you familiarize yourself with more of the material. Remember, you need to post at least three responses to receive full credit for this assignment.
1. The French revolutionaries claimed that they were inspired by the Enlightenment
philosophes
. Would the
philosophes
we studied back in Week 2 have approved of how the Revolution started? What about how it developed through the 1790s?
2. In his
Reflections on the Revolutions in France,
British member of Parliament Edmund Burke predicted the Terror. Was this a lucky guess on his part or were the seeds of of the Terror part of the Revolution from the beginning? Why?
3. The French Revolution had a profound impact on the world, not just within the borders of France. Why were some nations willing to accept its gains-at least, partially-while others resisted them? Which country do you think was the most unwilling to accept the new ideas of
liberte,
e
galite,
and
fraternite
? Other than France, which was most willing to embrace the Revolutionary ideals? Why?
4. Although no historian doubts the importance of the reign of Napoleon in European (and even world) history, they do argue over the interpretation of these events. For example, they are torn on the role Napoleon played in the Revolution. Some argue that he continued the spirit of the Revolution, despite creating an Empire. Others believe he murdered it. Some include Napoleon's reign as a stage of the actual Revolution, while others consider it its own separate event. What do you think? Do you think Napoleon continued and spread the Revolution? Or do you think he destroyed its ideals when creating his empire? Do you think his reign should qualify as a separate historical event from the Revolution? Or was it simply another stage in a long process?
.
Please check the attachment for my paper.Please add citations to a.docxajoy21
Please check the attachment for my paper.
Please add citations to all paragraphs.
Also, please check the paper for plagiarism and please add two more pages on (Social Media & In person Communication) to make it fit the essay so far.
And please use 5 more sources in the paper. (1 Article, 1 Book, 1 Encyclopedia, 1 Newspaper and 1 magazine).
Finally, please correct all the grammar mistakes in the first 3 pages.
And please get rid of the first person used. (I,we etc...)
.
Please answer to this discussion post. No less than 150 words. Refer.docxajoy21
Please answer to this discussion post. No less than 150 words. Reference and APA style needed. Please no plagiarism. Similarity is <20%. Thanks
The most interesting thing about this chapter is that it helps people and scholars to develop skills to influence strategy in nowadays changing healthcare environment. The topic also contributes an extensive range of themes in strategies and politics, offering more complete contextual that can be in other policies textbook in the market (Mason, Leavitt, & Chaffee, 2013). The topics also entail up-to-date updates concerning conflict organization, health economics, politicization, use of media as well as working with societies for change. Reviewed copy take account of new supplement with coverage of advanced reasonably priced care act. According to this perceptions and strategies, every individual will be equipped and ready to play a leadership role under four spheres where nurses are governmentally efficient, the workstation, government, specialized organization as well as the community (American Nurses Association, 2010). The topic has helped me to know more of nursing and healthcare policies and politics.
In thus, have understood that the concept of nursing policies influences can be defined as a nursing ability to have active, effective on decision making as well as affairs connected to health care by use of power, support, and strategy capability, and establishing or strengthening images. The nursing policy and politics within a healthcare connect to my clinical practices because as a nurse, I should view myself as a professional with the ability and being responsible for influencing recent and forthcoming health care conveyance system. But to attain this, there must be the presence of policies that define and assimilate suitable standards for healthcare delivery as well as addressing essential conditions for that care to happen.
References
American Nurses Association. (2010).
Nursing's social policy statement: The essence of the profession
. Nursesbooks. org.
Mason, D. J., Leavitt, J. K., & Chaffee, M. W. (2013).
Policy and Politics in Nursing and Healthcare-Revised Reprint
. Elsevier Health Sciences.
.
Please attach Non-nursing theorist summaries.
Jigsaw/Executive Summary Grading Criteria
Albert Bandura: Self-Efficacy
Points Possible
Your Points
Summary Paper
Introduction/Conclusion
2
History/Origins of Theory
3
Major Precepts of Theory
Current Application(s) of Theory
Mechanics
Grammar/form/spelling/punctuation/ Logical flow/readability/APA format
3
Citations and references
2
Total Points
10
.
Please answer the question .There is no work count. PLEASE NUMBER .docxajoy21
Please answer the question .There is no work count. PLEASE NUMBER THE ANSWERS.
1-How does the value of individual freedom effect the ethics of our American society differently than the value of family and religious loyalty?
What are some other values of contemporary American society?
How are they in conflict with the values of the 1950's?
Is one set of values superior to another?
Why?
2-Islam means, at its root, surrender.
How does Islamic belief and practice reflect the importance of surrendering to Allah?
3-What do you think about this focus on prayer?
What is the standard of prayer in Judaism?
What about in Christianity?
What about in your own life?
Are you humbled and challenged by the knowledge that Muslims stop 5 times to pray?
4-Do you think the call to prayer is a call to obedience or a reminder for devotion?
5-Please answer this question and discuss the implications, probe for assumptions, draw out evidence and clarify perspectives.
What was the influence of Islam on the arts and sciences in its Golden Age, which is when Europe was experiencing the Medieval Period, sometimes called the Dark Ages?
6a- You mention the art form of mosaic (you called it "geometric pieces") and I want to draw the class' attention to the idea of unity in diversity within this art form.
First, the main theological point of Islam is that Allah is one.
As the Muslim scientists and artists searched to make discoveries in their given fields of study, they were constantly looking for the unity of Allah in the diversity of the creation.
The artist brought out that unity in mosaic and in textiles.
The mosaic is a pattern that is derived by putting thousands of small colored stones together to make one design.
The individual pieces of stone lose their importance within the whole, but without each piece the whole would not be complete.
So their concept of God came through in their art.
6b-How else did the Muslims bring out unity in diversity?
7a-Because they were prohibited from figures in art, the Muslims developed other art forms and calligraphy is one of those art forms.
They believed that the words of the Qur'an were beautiful (to hear and for life) so they started to write them in a beautiful way and thus calligraphy developed.
Art is one of those things that cannot be totally squelched.
If you contain an artist in one area, their emotion will burst forth in another area.
7b What do you think about the Muslims' use of calligraphy?
The Muslim religion started very rapidly.
8--Class, Based on the information about Muhammad and the early spread of Islam, what do you think was the most important factor in the amazing way that Islam grew so quickly?
.
Please answer the following questions. Please cite your references..docxajoy21
Please answer the following questions. Please cite your references.
According to Section I readings, Democracy: what it is and what it is not? (15 points) (See attached PDF)
Is the U.S. a democratic country? Has your view/opinion changed or unchanged now comparing to your answer at the beginning of the class? (15 points)
What does democracy mean to you personally? What will you do/participate/take action to ensure/protect your definition of democracy? (15 points)
Has the United States been a positive or negative influence on global democracy? (15 points)
Identify yourself as either a municipal, state or federal lawmaker, discuss your action/plan for democracy in the United States and her role as it pertains to the spread of democracy and democratic values throughout the world in the 21
st
Century. (40 points)
.
Please answer the following questions.1. 1. Are you or.docxajoy21
Please answer the following questions.
1.
1.
Are you or your immediate supervisor involved with staffing decisions?
If so, describe how staffing forecasts are prepared.
2.
2.
Does your organization use a flexible or a static budget?
Explain and provide examples.
Note: I work at a hospital as a psychiatric technician
.
Please answer the following question with 200-300 words.Q. Discu.docxajoy21
Please answer the following question with 200-300 words.
Q. Discuss why Hurston's assertions in "Characteristics of Negro Expression" would have been frowned upon by middle and upper class blacks.
Source:
Zora Neale Hurston -
"Characteristics of Negro Expression"
Please don't forget to include at least one quote from the passage.
.
Please answer the following question Why do you think the US ha.docxajoy21
Please answer the following question:
Why do you think the US has such a high homicide rate compared to other Western countries? What would you do to change that?
The paper needs to be 3-4 pages long, 12 point font, Times New Roman, and double spaced. The paper needs to be in
APA format. All sources must be cited.
Due on April 7, 2017 @ 12:30pm.
Anything after 12:30pm will not be accepted.
.
Please answer the following questions. Define tunneling in the V.docxajoy21
Please answer the following questions.
Define tunneling in the VPN environment and explain the difference between voluntary and compulsory tunnels.
How does the VPN technology provides security to a corporate network? You may also choose to compare two or more VPN technologies.
Consider the VPN technologies studied in this session, including IPSec in the Tunnel mode, L2TP over IPsec, PPTP and SSL/TLS VPN. Which one would you choose for your company? Can you discuss its advantages and its weakness or drawbacks? Do you know some products that are based on that technology?
Discuss the specific techniques for securing the remote client and the remote access server and the common concerns of each.
.
Please answer the following questions1. How can you stimulate the.docxajoy21
Please answer the following questions:
1. How can you stimulate the brain development of an infant?
2. How do parents cope with the growing autonomy of toddlers and what should be done about temper tantrums?
3. How do children in these stages of development change the life style of their parents?
Observation:
Have a conversation with the parent of a toddler. What are the differences of dealing with an infant and a toddler?
.
Please answer the following questions very deeply and presicely .docxajoy21
Please answer the following questions very deeply and presicely :
"Ziff"
!)
As Ziff define artwork, what do you think would consider as an artwork, and who do you think is capable of deciding if the work is art or not?
"Danto"
2) Why do you think Danto compares Socrates and Hamlet in the beginning? Do you feel as if it was an imitation of nature? How would you describe the word "art" with these two philosophers?
* The answer should be (4-8 sentences)
.
Please answer the following questions in an informal 1 ½ - 2-page es.docxajoy21
Please answer the following questions in an informal 1 ½ - 2-page essay:
Describe Hubert’s characterization of white society in New York City during the Harlem Renaissance.
What does this essay reveal about black culture in Harlem?
Why does Hubert describe the Harlem Renaissance as “the golden age for Negro writers, artists, and musicians?”
Black writer Alain Locke used the term “New Negro” to describe individuals such as Hubert. What did that mean?
Please conclude your essay with at least one question for discussion. Choose a question that you think will both enlighten and enliven your discussion section.
.
Please answer the following questions in a response of 150 to 200 wo.docxajoy21
Please answer the following questions in a response of 150 to 200 words each, and submit your responses in a Word attachment no later than Sunday of this week at 11:59 p.m. EST.
Discuss the reasons for the Iranian hostage crisis in 1979, and how that has impacted US-Iranian relations since.
Examine the motives of both the United States and the Soviet Union during the Cold War. Provide at least two examples in which these motives led to potential conflict between the two superpowers and/or their proxies (smaller nations in their respective spheres of influence).
Evaluate the assumption that the East European revolutions of 1989-90 that led to the breakup of the Warsaw Pact were a direct cause for the collapse of the Soviet Union. To what extent did these events influence the latter? Could the USSR have relinquished control of Eastern Europe yet remained intact?
.
Please answer these questions regarding the (TILA) Truth in Lending .docxajoy21
Please answer these questions regarding the (TILA) Truth in Lending Act.
1-Did the legislation or regulation solve the problem(s)? How?
2-Who were the major stakeholders?
The answers need to be complete, through and supported by evidence.
The length should as much as needed to answer the questions but not less than three quarters of a page for each question.
.
Please answer the following question pertaining to psychology. Inc.docxajoy21
Please answer the following question pertaining to psychology.
Include references/cites
at least 175 words each question.
1. 12
Despite much effort, a definition of personality has been elusive. Why do you think this is the case? How does this influence the relationship between personality theory and personality assessment?
13
What are the differences in test construction between the Minnesota Multiphasic Personality Inventory (MMPI) and the NEO Personality Inventory? Which do you think is more valid? Explain your responses.
16
How are assessments used in the workplace? How can assessments be misused in the workplace?
Analyze the relationship between the major theories of personality and assessments of personality.
Evaluate the strengths and weaknesses of personality assessment methods.
Describe the application of psychological assessments in the workplace.
.
Please answer the following questions in a response of 250 to 300 .docxajoy21
Please answer the following questions in a response of
250 to 300 words each
, and submit your responses in a Word attachment no later than Sunday of this week at 11:59 p.m. EST.
Identify the causes, key battles, and outcome of World War II in both Europe and the Pacific.
Identify the causes of the Cold War, and explain whether you think the Cold War was inevitable or not following World War II. How did the conflict between communist and non-communist powers manifest in China and Korea?
Pollard, E., Rosenberg, C., & Tignor, R. (2015). Worlds Together Worlds Apart. From 1000 CE to the Present (1st ed., Vol. 2). New York, NY: W.W. Norton & Company.
.
Please answer the three questions completly. I have attached the que.docxajoy21
Please answer the three questions completly. I have attached the questions in excel where they need to be answered.
1)
XYZ Company had three defined benefit plans with the following information:
12 Points
Plan 1
Plan 2
Plan 3
Expected Payment over next year
3,500,000
3,500,000
3,500,000
Fair Value of Plan Assets
5,000,000
6,000,000
3,000,000
Projected Benefit Obligation
7,000,000
5,500,000
4,500,000
Record the over/(under) funded status of each plan. Then determine the balance sheet presentation based on the over/(under) funded status. (Input an amount in each yellow cell. If zero, input zero.)
Plan 1
Plan 2
Plan 3
Over/ (Under) Funded Status
Noncurrent Asset
Current Liability**
Noncurrent Liability
** Think about the expected payment over the next year compared to the Plan Assets available.
2)
XYZ Company received the following information from its actuary team for the
10 points
year pertaining to one of its defined benefit plans:
Service Cost
120,000
Interest on Projected Benefit Obligation
55,000
Expected Return on Plan Assets
30,000
Amortization of Prior Service Cost
15,000
Amortization of Actuarial Gain
10,000
Calculate the Pension Expense for the year (show all items included in the calculation):
3)
At the end of year, XYZ Corporation had the following pension related information in addition to the above information:
12 points
12/31/X1
12/31/X2
Fair Value of Plan Assets
405,000
505,000
Projected Benefit Obligation
1,065,000
1,035,000
Funded Status
(660,000)
(530,000)
Record the Necessary Journal Entries:
Entry to record Service Cost, Interest Cost and Return on Plan Assets:
Account Name:
Debit
Credit
Amortization of Prior Service Cost and/or Actuarial Losses:
Account Name:
Debit
Credit
Amortization of Actuarial Gains:
Account Name:
Debit
Credit
4)
a) Identify a US Company that offers a Defined Benefit Plan and review the 10K information for 2016 of the identified company and provide a brief analysis based on footnotes related to the plan.
3 points
b) Include screenshots to report the Funded Status and Pension Expense information for the selected plan.
1 Points
c) Record the associated journal entries based on the screenshots for that company.
12 points
Entry to record Service Cost, Interest Cost and Return on Plan Assets:
Account Name:
Debit
Credit
Amortization of Prior Serv.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
1. #ifndef MYLIST_H_
#define MYLIST_H_
#include<iostream>
#include<cctype>
using namespace std;
//PROJECT 2 STUDENT FILE
//template class that simulates an ordered list of common
elements
//It is assumed that the list will either be empty or completely
full
template <class type>
class myList
{
protected:
int length; //the number of elements in the list
type *items; //dynamic array to store the elements
public:
~myList();
//destructor for memory cleanup
//Postcondition: Deallocates the memory occupied by the
items array
myList();
//default constructor
//Postcondition: creates items array of size 0 and sets size
to zero
myList(int n, type t);
//assignment constructor
//Postcondition: creates items array of size n. Each
element in the list
//is assigned the value of type t, sets length to n
myList(int n, type *anArray);
2. //assignment constructor
//Postcondition: copies contents of anArray parameter into
items array
//sets length to n
myList(const myList & otherList);
//copy constructor
//Postcondition: makes a deep copy of the parameter
otherList to
//the calling list
void print(ostream& outStream);
//prints the elements of the list using outStream
//Postcondition: The elements of the list are printed to the
//output stream each separated by a comma. The last
element
//printed should not have a comma after it
void append(const type& theItem);
//assigns the parameter theItem to the end of the list
//Postcondition: the parameter theItem is the last element
in the list
bool isIn(const type& theItem);
//determines if an element is currently in the list
//Postcondition: Returns true if the parameter theItem is in
the list,
//otherwise returns false
bool insert(const type& theItem, int location);
//inserts an element into the list
//Postcondition: inserts the parameter theItem into the list
at position
//determined by the parameter location and then returns
true, if the location
//is greater than the length of the list + 2, then the function
returns false
3. //LOCATION MEANS COUNTING FROM 1, SO
LOCATION 1 MEANS INDEX POSITION 0, ETC..
void sort(char ch);
//Assuming the list contains numbers, characters, or
strings this functions
//sorts the elements in the list, where type is either
'A','a'
//for ascending, or 'D','d' for descending
//Choose any sorting algorithm of your choice
//Postcondition: sorts the elements in the list
//OVERLOADED OPERATORS
myList& operator=(const myList& rhs);
//overloading of the assignment operator to allow for
list to list assignment
myList& operator+=(const type& t);
//overloading of the addition_equal operator that adds
the parameter t
//to the end of the list
myList& operator+=(const myList& rhs);
//overloading of the addition_equal operator that adds
another list
//to the end of the list
/*
FOR 10% EXTRA CREDIT ON THIS PROJECT GRADE,
OVERLOAD THE FOLLOWING OPERATORS
AS NON-MEMBER FUNCTIONS
(1) << (insertion)
(2) + (addition) that adds one element to a list
(3) + (addition) that adds two lists
HINT: to overload both addition operators as stated above
4. use the member
functions +=
KEEP IN MIND THAT THE SYNTAX GETS TRICKY
WHEN WRITING NON-MEMBER FUNCTIONS
FOR TEMPLATE CLASSES
See example prototypes below
*/
//friend ostream& operator<< (ostream& outStream, const
myList<type>& theList){}
//friend myList& operator+ (myList<type> &lhs, const
type& t){}
//friend myList& operator+ (myList<type> &lhs, const
myList<type>& rhs){}
};
template <class type>
myList<type>::~myList()
{
delete [] items;
}
template <class type>
myList<type>::myList()
{
length=0;
items=new type;
items = nullptr;
}
#endif /* MYLIST_H_ */
Create a template class that implements a dynamic array based
list of common elements from above code
Source Files:
myList.hpp (which is the code above)
testmyList.cpp (the name of the test program to be created)
Since you will be writing a “template class”, it is easiest to
implement the class in the header file myList.hpp
5. Therefore, you will not need a myList.cpp implementation file.
Just do all of your implementation of the class myList in
the header file myList.hpp.
To compile the header file myList.hpp issue the command: g++
-c myList.hpp
You should be in charge of creating your own test program.
Call it testmyList.cpp
Solution
#ifndef MYLIST_H_
#define MYLIST_H_
#include<iostream.h>
//PROJECT 2 STUDENT FILE
//template class that simulates an ordered list of common
elements
//It is assumed that the list will either be empty or completely
full
template <class type>
class myList
{
protected:
int length; //the number of elements in the list
type *items; //dynamic array to store the elements
6. public:
~myList()
{
delete items;
//destructor for memory cleanup
//Postcondition: Deallocates the memory occupied by the
items array
}
myList()
{
items=0;
//default constructor
//Postcondition: creates items array of size 0 and sets size to
zero
}
myList(int n, type t)
{
length=n;
items=new <t>items[n];
//assignment constructor
//Postcondition: creates items array of size n. Each element
in the list
//is assigned the value of type t, sets length to n
}
myList(int n, type *anArray)
7. {
for(int i=0;i<n;i++)
{
items[i]=anArray[i];
}
//assignment constructor
//Postcondition: copies contents of anArray parameter into
items array
//sets length to n
}
myList(const myList & otherList)
{
items=otherList.items;
//copy constructor
//Postcondition: makes a deep copy of the parameter
otherList to
//the calling list
}
void print(ostream& outStream)
{
outStream<<items;
//prints the elements of the list using outStream
//Postcondition: The elements of the list are printed to the
//output stream each separated by a comma. The last element
//printed should not have a comma after it
8. }
void append(const type& theItem)
{
//assigns the parameter theItem to the end of the list
//Postcondition: the parameter theItem is the last element in
the list
}
bool isIn(const type& theItem)
{
//determines if an element is currently in the list
//Postcondition: Returns true if the parameter theItem is in
the list,
//otherwise returns false
}
bool insert(const type& theItem, int location)
{
//inserts an element into the list
//Postcondition: inserts the parameter theItem into the list at
position
//determined by the parameter location and then returns true,
if the location
//is greater than the length of the list + 2, then the function
returns false
//LOCATION MEANS COUNTING FROM 1, SO
LOCATION 1 MEANS INDEX POSITION 0,
9. }
void sort(char ch)
{
switch(ch)
{
case 'd':
case 'D':
type *n;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(type[i]<type[j])
{
n=type[i];
type[i]=type[j];
type[j]=n;
}
}
}
break;
case 'a':
case 'A':
type *n;
for(int i=0;i<n;i++)
10. {
for(int j=i+1;j<n;j++)
{
if(type[i]>type[j])
{
n=type[i];
type[i]=type[j];
type[j]=n;
}
}
}
break;
}
//Assuming the list contains numbers, characters, or strings
this functions
//sorts the elements in the list, where type is either 'A','a'
//for ascending, or 'D','d' for descending
//Choose any sorting algorithm of your choice
//Postcondition: sorts the elements in the list
}
//OVERLOADED OPERATORS
myList& operator=(const myList& rhs)
{
//overloading of the assignment operator to allow for list to
list assignment
11. }
myList& operator+=(const type& t)
{
//overloading of the addition_equal operator that adds the
parameter t
//to the end of the list
}
myList& operator+=(const myList& rhs)
{
//overloading of the addition_equal operator that adds
another list
//to the end of the list
}
};