In: Statistics and Probability
In: Statistics and Probability
Hogwarts has 4 houses (Gryffindor, Hufflepuff, Ravenclaw, Slytherin). We can represent them by their first letters G H R S. Each house has exactly 20 students. If I choose 4 students randomly, what is the probability that I have one from each house?
In: Statistics and Probability
In: Psychology
From a random sample of 100 male students at Hope College, 16 were left-handed. Using the theory-based inference applet, determine a 99% confidence interval for the proportion of all male students at Hope College that are left -handed. Round your answers to 4 decimal places, e.g. "0.7523.
In: Math
Please add the following method as a part of the UnorderedList class definition:
•print_list:
the method prints the elements of the
list using the same format as a Python list
(square brackets and commas as separators).
In the main function of the modified UnorderedList.py, please test the new method to demonstrate that it works as expected.
Please leave comments in the code to show what is done
UnorderList.py file
# Implementation of an Unordered List ADT as a linked list. The list
# is accessed through a reference to the first element, head.
# Adopted from Section 3.9 of the textbook.
from Node import Node
class UnorderedList:
'''
List is empty upon creation and the head reference is None
'''
def __init__(self):
self.head = None
'''
Returns True if list is empty, False otherwise
'''
def is_empty(self):
return self.head == None
'''
Add an element to head of the list
'''
def add(self, item):
# Create a node using item as its data
temp = Node(item)
# make the next reference of the new node refer to the head
# of the list
temp.set_next(self.head)
# modify the list head so that it references the new node
self.head = temp
'''
Returns the size of the list
'''
def size(self):
# start at the head of the list
current = self.head
count = 0
# Traverse the list one element at a time. We know
# we reached the end when the next reference is None
while current != None:
count = count + 1
current = current.get_next()
return count
'''
Search for an item in the list. Returns True if found, False otherise.
'''
def search(self,item):
current = self.head
found = False
# As long as the element is not found and we haven't
# reached the end of the list
while current != None and not found:
if current.get_data() == item:
found = True
else:
# go to the next element
current = current.get_next()
return found
'''
Remove the first occurrence of item from the list.
'''
def remove(self, item):
# keep track of current and previous elements
current = self.head
previous = None
found = False
# traverse the list
while current != None and not found:
# if we have a match, stop
if current.get_data() == item:
found = True
# otherwise advance current and next references
else:
previous = current
current = current.get_next()
# the element to be deleted is the head of the list
if found:
if previous == None:
self.head = current.get_next()
# the element to be deleted is not the head
else:
previous.set_next(current.get_next())
def main():
# create a list and add some elements to it
aList = UnorderedList()
print("Adding 3, 5, 8, and 11 to the list.")
aList.add(3)
aList.add(5)
aList.add(8)
# 11 is the head of the list
aList.add(11)
print("List size:", aList.size())
print("Is 5 in the list? ", aList.search(5))
print("Removing 5 from the list.")
aList.remove(5)
print("Is 5 in the list? ", aList.search(5))
print("List size:", aList.size())
print("Removing 3 from the list.")
aList.remove(3)
print("List size:", aList.size())
if __name__ == "__main__":
main()
In: Computer Science
can someone finish and check my code on main. cpp? Its not working for me even though im sure my code make sense is it possible to output each function to show they work. this is supposed to be a vector class library made from allocated memory i have included templated functions in the class file to help create the rest of the functions. Thank you so much
note: i did not include main.cpp because it was empty- im hoping someone can test my vector class functions on int main. thank you
#ifndef VECTOR_H
#define VECTOR_H
#include
#include
#include
using namespace std;
template
T* allocate(int n){
return new T[n];
}
template
void copy_list(T *dest, T* src, int many_to_copy){
for (int i=0; i < many_to_copy; i++){
*dest++ = *src++;//destination pointer points to source pointer
}
*dest= NULL;
dest -=many_to_copy;
src -= many_to_copy;
delete [] src;//deletes src array
src = nullptr;
}
template
void print_list(T* list, int size){
cout<< "Content of list is:\n"<
for(int i = 0; i < size; i++){//loops "size" times
cout<< setw(4)<< *list<
list++; //list array increments
}
list = list-size;
cout<< endl;
}
// adds element to end of list
template
T* push_back(T* list,T entry, int& size){
T* p =list;// ponts to beginning of list
T* pnew = allocate(size+1);
for(int i=0; i
*pnew=*p;
pnew++= p++;
}
*pnew = entry;
size++; // old size gets increased by one
pnew -= size-1;
delete list;
list =nullptr;
return pnew;
}
template
T* pop_back(T* list, int& size){
size--;
T* p = &list;
T* pnew = allocate(size);// listnew points to dynamic array
for(int i=0;i
pnew=p;
pnew++;
p++;
}
pnew-= size-1;
delete list;
list = nullptr;
return pnew;
}
template
T* reallocate(T* arr, int& currentcapacity, int ncapacity){
T *pointer = allocate(ncapacity);
copy_list(pointer,arr,currentcapacity);
currentcapacity = ncapacity;
return pointer;
}
template
T* add_entry(T* list, const T& new_entry, int& size, int& capacity){
list = push_back(list,new_entry,size);
if(size == capacity) {
cout<<"Increasing capacity "<
list = reallocate(list,capacity,capacity*2);
}
return list;
}
template
T* search_entry(T* list, const T& find_me, int size) {
for(int i=0;i
if(*list == find_me) {
return list;
}
list++;
}
if(*list != find_me) {
cout<<"Not found!"<
list-=size;
print_list(list,size);
list = nullptr;
return list;
}
}
template
T* remove_entry(T* list, const T& delete_me, int& size, int& capacity) {
T * pointernew = search_entry(list,delete_me,size);
list = pop_back( list, pointernew, size);
if(size/4 == capacity) {
cout<<"Reducing capacity "<
list = reallocate(list,capacity,capacity/2);
}
return list;
}
class Vector
{
public:
Vector();
Vector(unsigned int size = 100);
// big three:
//big three functions:
Vector(const Vector& to_be_copied) //copy ctor: no return type
{
_how_many = 100;
_capacity= 100;
list =new int [_capacity+1];
}
Vector& operator=(const Vector& rhs) //assignment operator
{
const bool debug = true;
if (debug){
cout<<". . . . ["<list<<"].operator("<
}
if (this == &rhs){
return *this;
}
}
~Vector();
//member access functions:
template
const T operator [](const unsigned int index) const{//
assert(index < length());
return at(index);
}
template
T& operator [](const unsigned int index){
assert(index < length());
return at(index);
}
template
T& at(int index) //returns reference to item at position index
{
assert(index < length());
return list[index];
}
template
const T at(int index) const //returns a const item at position index
{
assert(index < length());
return list[index];
}
template
T& front() const //returns item at position 0.
{
* list-=_how_many-1;
return *list;
}
template
T& back() const //return item at the last position
{
* list+=_how_many;
return *list;
}
//Push and Pop functions:
template
Vector& operator +=(const T& item){} //push_back
template
void push_back(const T& item); //append to the end
template
T pop_back(); //remove last item and return it
//Insert and Erase:
template
void insert(int insert_here, const T& insert_this);//insert at pos
void erase(int erase_index);//erase item at position
template
int index_of(const T& item); //search for item. retur index.
//size and capacity:
void set_size(int size); //enlarge the vector to this size
//2mm
void set(const int* old_list);
void set_capacity(int capacity); //allocate this space
int size() const {return _how_many;} //return _size
int capacity() const {return _capacity;} //return _capacity
bool empty() const; //return true if vector is empty
int check_error() const;
//OUTPUT:
template
friend ostream& operator <<( ostream& outs, const Vector& _a );
template
void print_list(T* list, int size);
private:
int _how_many;//size
int _capacity;//cap
int _error;//errors
int* list;
int vector_len(const int* list) const;
int length() const;//reutrns vectorlength function
template
void v_cpy(T* dest, const T* src) const;
};
#endif // VECTOR_H
//vector.cpp
#include "vector.h"
//CTORS
Vector::Vector(){
_error =0;
list = nullptr;
set(list);
}
Vector::Vector(unsigned int _size){//defaultcotr
_size =100;
list = nullptr;
set(list);
}
Vector::~Vector(){//destructor
const bool debug = false;
if (debug){
cout<<". . . . Vector::~Vecotr being called."<
}
if (list!=nullptr)
delete[] list;
}
template
void Vector::push_back(const T& item){
}
//Insert and Erase:
template
void Vector::insert(int insert_here, const T& insert_this){}//inserts item from list
void Vector::erase(int erase_index){}// erease item from list
template
int Vector::index_of(const T& item){}//search array and return index
void Vector::set_size(int size){_how_many=size;}//returns size
void Vector::set_capacity(int capacity){_capacity= capacity;}
//returns length of list
int Vector::vector_len(const int* list) const{
const bool debug = false;
if (debug) cout<<". . . . Vector::vector_len ("<
int length = 0;
while(*list){
length++;
list++;
}
if (debug) cout<
return length;
}
int Vector::length() const{
return vector_len(list);
}
template
void Vector:: v_cpy(T* dest, const T* src) const{
while (src){
*dest++ = *src++;//destination pointer points to source pointer
}
*dest= NULL;
//dest -=many_to_copy;
//src -= many_to_copy;
delete [] src;//deletes src array
src = nullptr;
}
void Vector::set(const int* old_list){
if (list)
delete[] list;
int len = vector_len(old_list);
//this should be an allocate function.
list = new int [len+1];
v_cpy(list, old_list);
}
In: Computer Science
In: Economics
The following is a list of 12 control plans from this chapter, followed by a list of 10 examples of System Failures or problem situations that have control implications: Match the 10 system failures with a control plan that would best prevent the system failure from occurring.
Because there are 12 control plans, you should have two letters left over. Control Plans
A. Batch sequence check
B. Confirm input acceptance
C. Programmed edit checks
D. Manual agreement of batch totals
E. Online prompting
F. Cumulative sequence check
G. Electronic approvals
H. Document design
I. Procedures for rejected inputs
J. Compare input data with master data
K. Turnaround documents
L. Digital signatures System Failures
1. At Wynne Company, customer orders are received in the mail in the sales department, where clerks enter individual orders into the company’s computer system and then file the completed orders in a filing cabinet. Customers should receive an acknowledgement for each of their orders. When the customer fails to receive an acknowledgement, the customer calls to inquire. Inevitably, the sales clerk will find the customer’s order filed with other customer orders that had been entered into the computer. The “missing” orders are always marked as “ENTERED”.
2. The tellers at Mason Bank have been having difficulty reconciling their cash drawers. All customer transactions such as deposits and withdrawals are entered online at each teller station. At the end of the shift, the computer prints a list of the transactions that have occurred during the shift. The tellers must then review the list to determine that their drawers contain checks, cash, and other documents to support each entry on the list.
3. Data entry clerks at Dora Company use networked PCs to enter batches of documents into the computer. Recently, a number of errors have been found in key numeric fields. The supervisor would like to implement a control to reduce the transcription errors being made by the clerks.
4. At Central Inc., clerks in the accounting offices of the company’s three divisions prepare pre-numbered general ledger voucher documents. Once prepared, the vouchers are given to each office’s data entry clerk, who keys them into an online terminal. The computer records whatever general ledger adjustment was indicated by the voucher. The controller has found that several vouchers were never recorded, and some vouchers were recorded twice.
5. Purchase orders at Hickory Corp. are prepared online by purchasing clerks. Recently, the purchasing manager discovered that many purchase orders are being sent for quantities far greater (i.e., incorrect quantities) than would normally be requested.
6. At Quality Brokers, Inc., a clerk on the trading floor mistakenly entered the dollar amount of a trade into the box on the computer screen reserved for the number of shares to be sold and then transmitted the incorrect trade to the stock exchange’s computer.
7. At Pilot Company, clerks in the cash applications area of the accounts receivable office open mail containing checks from customers. They prepare a remittance advice (RA) containing the customer number, invoice numbers, amount owed, amount paid, and check number. Once prepared, the RAs are sent to a clerk who keys them into the computer. The accounts receivable manager has been complaining that the RA entry process is slow and error-prone.
8. Dancer Company enters shipping notices in batches. Upon entry, the computer performs certain edits to eliminate those notices that have errors. As a result, many actual shipments never get recorded.
9. Jamie the hacker gained access to the computer system of United Bank and entered the data to transfer funds to his bank account in the Cayman Islands.
10. At Lockhart Company., data entry clerks receive a variety of documents from many departments throughout the company. In some cases, unauthorized inputs are keyed and entered into the computer.
In: Accounting
Problem 2 For the same list as above, sort the list in such a way where the first set of numbers are ascending even and the second set of numbers are ascending odd. Your output should look like the following: [ 2, 4, 6, … 1, 3, 5 .. ]. The list is A = [ 6, 9, 0, 4, 2, 8, 0, 0, 8, 5, 2, 1, 3, 20, -1 ]
In: Advanced Math