4) Implement the Selection Sort algorithm discussed in class to
sort a list of a certain size. The list is to be
implemented using a dynamic array as well as a singly linked list.
You are required to compare the
performance (sorting time) for the dynamic array and singly-linked
list-based implementations.
You are given the startup codes for the dynamic array and
singly-linked list based implementations. You
are required to implement the Selection Sort function in each of
these codes. The main function is written
for you in such a way that the code will run for different values
of list sizes ranging from 1000 to 20000,
in increments of 1000. The inputs for the maximum value and number
of trials are 5000 and 50 for all
cases. The codes will output the average sorting time (in
milliseconds) for each of value of list size for the
two implementations.
You are then required to tabulate the average sorting times
observed for the two implementations and then
plot the same in Excel. Generate one plot that displays (compares)
the sorting times for both the
implementations. Use the Add Trend Line option in Excel, choose the
Power function option and display
the equations and the R2 values for the two curves. The R2 values
are expected to be closer to 1.0. Make
sure the two equations and the R2 values are clearly visible in
your Excel plot. (Please answer in C++)
Dynamic list implementation code:
#include <iostream>
#include <ctime>
#include <ratio>
#include <chrono>
#include <time.h>
#include <stdlib.h>
using namespace std;
// implementing the dynamic List ADT using array
// operations to be implemented: read, Modify, delete, isEmpty,
insert, countElements
class List{
private:
int *array;
int maxSize; // useful to decide if
resizing (doubling the array size) is needed
int endOfArray;
public:
List(int size){
array = new
int[size];
maxSize =
size;
endOfArray =
-1;
}
void deleteList(){
delete[]
array;
}
bool isEmpty(){
if (endOfArray
== -1)
return true;
return
false;
}
void resize(int s){
int *tempArray =
array;
array = new
int[s];
for (int index =
0; index < min(s, endOfArray+1); index++){
array[index] = tempArray[index];
}
maxSize =
s;
}
void insert(int data){
if (endOfArray
== maxSize-1)
resize(2*maxSize);
array[++endOfArray] = data;
}
void insertAtIndex(int insertIndex,
int data){
// if the user
enters an invalid insertIndex, the element is
// appended to
the array, after the current last element
if (insertIndex
> endOfArray+1)
insertIndex = endOfArray+1;
if (endOfArray
== maxSize-1)
resize(2*maxSize);
for (int index =
endOfArray; index >= insertIndex; index--)
array[index+1] = array[index];
array[insertIndex] = data;
endOfArray++;
}
int read(int index){
return
array[index];
}
void modifyElement(int index, int
data){
array[index] =
data;
}
void deleteElement(int
deleteIndex){
// shift
elements one cell to the left starting from deleteIndex+1 to
endOfArray-1
// i.e., move
element at deleteIndex + 1 to deleteIndex and so on
for (int index =
deleteIndex; index < endOfArray; index++)
array[index] = array[index+1];
endOfArray--;
}
int countList(){
int count =
0;
for (int index =
0; index <= endOfArray; index++)
count++;
return
count;
}
void print(){
for (int index =
0; index <= endOfArray; index++)
cout << array[index] << " ";
cout <<
endl;
}
};
void SelectionSort(List list){
// Implement the selection sorting algorithm here...
}
int main(){
using namespace std::chrono;
srand(time(NULL));
int maxValue;
cout << "Enter the max value: ";
cin >> maxValue;
int numTrials;
cout << "Enter the number of trials: ";
cin >> numTrials;
for (int listSize = 1000; listSize <= 20000; listSize += 1000){
double totalSortingTime = 0;
for (int trials = 1; trials <= numTrials; trials++){
List integerList(1);
for (int i = 0; i < listSize; i++){
int value = 1 + rand() %
maxValue;
integerList.insertAtIndex(i,
value);
}
high_resolution_clock::time_point t1 =
high_resolution_clock::now();
SelectionSort(integerList);
high_resolution_clock::time_point t2 =
high_resolution_clock::now();
duration<double, std::milli> sortingTime_milli =
t2 - t1;
totalSortingTime += sortingTime_milli.count();
integerList.deleteList();
}
cout << "Average sorting time for list size "
<< listSize << " is " <<
(totalSortingTime/numTrials) << " milli seconds " <<
endl;
} // list size loop
system("pause");
return 0;
}
In: Computer Science
USE ORACLE - SQL
My table is below:
drop table workon;
drop table employee;
drop table project;
drop table division;
create table division
(did integer,
dname varchar (25),
managerID integer,
constraint division_did_pk primary key (did) );
create table employee
(empID integer,
name varchar(30),
alary float,
id integer,
constraint employee_empid_pk primary key (empid),
constraint employee_did_fk foreign key (did) references
division(did)
);
create table project
(pid integer,
pname varchar(25),
budget float,
did integer,
onstraint project_pid_pk primary key (pid),
constraint project_did_fk foreign key (did) references
division(did)
);
create table workon
(pid integer,
empID integer,
hours integer,
constraint workon_pk primary key
(pid, empID)
);
/* loading the data into the database */
insert into division
Values (1,'engineering', 2);
insert into division
values (2,'marketing', 1);
insert into division
values (3,'human resource', 3);
insert into division
values (4,'Research and development', 5);
insert into division
values (5,'accounting', 4);
insert into project
values (1, 'DB development', 8000, 2);
insert into project
values (2, 'network development', 6000, 2);
insert into project
values (3, 'Web development', 5000, 3);
insert into project
values (4, 'Wireless development', 5000, 1);
insert into project
values (5, 'security system', 6000, 4);
insert into project
values (6, 'system development', 7000, 1);
insert into employee
values (1,'kevin', 32000,2);
insert into employee
values (2,'joan', 42000,1);
insert into employee
values (3,'brian', 37000,3);
insert into employee
values (4,'larry', 82000,5);
insert into employee
values (5,'harry', 92000,4);
insert into employee
values (6,'peter', 45000,2);
insert into employee
values (7,'peter', 68000,3);
insert into employee
values (8,'smith', 39000,4);
insert into employee
values (9,'chen', 71000,1);
insert into employee
values (10,'kim', 46000,5);
insert into employee
values (11,'smith', 46000,1);
insert into employee
values (12,'joan', 48000,1);
insert into employee
values (13,'kim', 49000,2);
insert into employee
values (14,'austin', 46000,1);
insert into employee
values (15,'sam', 52000,3);
insert into workon
values (3,1,30);
insert into workon
values (2,3,40);
insert into workon
values (5,4,30);
insert into workon
values (6,6,60);
insert into workon
values (4,3,70);
insert into workon
values (2,4,45);
insert into workon
values (5,3,90);
insert into workon
values (3,3,100);
insert into workon
values (6,8,30);
insert into workon
values (4,4,30);
insert into workon
values (5,8,30);
insert into workon
values (6,7,30);
insert into workon
values (6,9,40);
insert into workon
values (5,9,50);
insert into workon
values (4,6,45);
insert into workon
values (2,7,30);
insert into workon
values (2,8,30);
insert into workon
values (2,9,30);
insert into workon
values (1,9,30);
insert into workon
values (1,8,30);
insert into workon
values (1,7,30);
insert into workon
values (1,5,30);
insert into workon
values (1,6,30);
insert into workon
values (2,6,30);
insert into workon
values (2,12,30);
insert into workon
values (3,13,30);
insert into workon
values (4,14,20);
insert into workon
values (4,15,40);
In: Computer Science
Modify listarr.java program by adding the following 2 methods:
public void insertsorted(x); // Inert x in a sorted list.
protected int binsearch(x); // Binary search for x
Assume you have a data file p1.txt with the following contents:
8
4 15 23 12 36 5 36 42
3
5 14 36
and your main program is in p1.java file.
To compile: javac p1.java
To execute: java p1 < any data file name say p1.txt
Your output should be formatted (i.e. using %4d for print) as follow:
Your name:……………………………. Student ID:…………………………
The 8 inserted data are as follow:
4 5 12 15 23 36 36 42
Searching for 3 data in the sorted list.
5: is found!
14: Ooops is not in the list?
36: is found!
Your main method should be as follow:
public static void main(String args[]) {
int j, n, m, k, x;
try{
Scanner inf = new Scanner(System.in);
n = inf.nextInt();// read No. of data to read
// Create a List of type Integer of size n
listarr Lint = new listarr(n);
// Read n element and insert in a sorted listposition randomly in the list
for(j = 1; j <= n; j++){
x = inf.nextInt(); // read element
Lint.insertsorted (x);
}
System.out.printf(“The %d inserted data are as follow:”, n);
System.out.print(Lint.toString());
// read No. of data to search
m = inf.nextInt();
for(j = 1; j <= m; j++){
x = inf.nextInt(); // read data to search
k = Lint.binsearch(x);
if(k??? //complete it
}
inf.close();
} catch (Exception e) {prt("Exception " + e + "\n");}
}// end main method
// listarr.java
// Array implementation of list in JAVA
import java.util.*;
//*************** Class Definition
*********************************
/**
* Implementation of the ADT List using a fixed-length array.
* Exception is thrown:
* if insert operation is attempted when List is full.
* if delete operation is attempted when List is empty.
* if position of insert or delete is out of range.
*/
public class listarr implements list{
// class Variables
protected int capacity, last;
protected T arr[];
listarr(int n){ // List
Constructor
last = 0;
capacity =
n;
//Allocate
Space
arr = (T[]) new
Object[n+1];
prt("\n List size = "
+ n);
}
public boolean
isEmpty(){return (last == 0);}
public int
length(){return last;}
public boolean isFull() {return
(last == capacity);}
public static void prt(String
s){System.out.print(s);}
// insert x at position
p (valid p's 1 <= p <= last+1 && last !=
capacity)
public void insert(T x, int p)
throws invalidinsertion {
prt("\nInsert "
+ x + " at position " + p);
if (isFull() || p < 1 || p >
last + 1)throw new invalidinsertion(p);
// Shift from
position p to right
for (int i =
last ; i >= p ; i--) arr[i+1] = arr[i];
arr[p] = x;
last++;
}
// delete element at
position p (1...last)
public void delete(int p)throws
invaliddeletion {
prt("\nDelete "
+ p + "th element, ");
if ( isEmpty()
|| p < 1 || p > last) throw new invaliddeletion(p);
// Shift from
position p + 1 to left
for (int i = p ;
i < last ; i++) arr[i] = arr[i+1];
last --;
}
public String toString()
{
String s =
"[";
for (int i = 1; i <= last; i++)
s += ", " + arr[i] ;
return s + "]";
}
public static void
main(String args[]) {
int j, p, n, x,
MaxNum = 5;
Random rand =
new Random();
n = rand.nextInt(MaxNum) + 1; // generate n randomly
//
Create a List of type Integer of size n
listarr Lint =
new listarr(n);
//
Generate n element and position randomly and insert in the
list
for(j = 1; j
<= n; j++){
p = rand.nextInt(n); // generate position
x = rand.nextInt(MaxNum * 4); // generate
element
try {
Lint.insert(x,p);
} catch (Exception e) {prt("Exception " + e +
"\n");}
}
prt("\nList: " + Lint.toString() + "\n"); // print list
//
Delete n element from list randomly and print list
for(j = 1; j
<= n; j++){
p = rand.nextInt(n); // generate position to
delete
try {
Lint.delete(p);
prt("\nList: " +
Lint.toString() + "\n");
} catch (Exception e) {prt("Exception " + e +
"\n");}
}
//
Create a List of type String
n =
rand.nextInt(MaxNum) + 1; // generate n
randomly
listarr Lstr =
new listarr(n);
try {
Lstr.insert("Sarah", 1);
Lstr.insert("Jerry", 1);
Lstr.insert("Tom", 2);
} catch (Exception e) {prt("Exception " + e +
"\n");}
prt("\nList: " +
Lstr.toString() + "\n");
}
}// end class listarr
In: Computer Science
Strategic Human Resources – Assignment Sheet 2
Case Study:
In the past, the decision criteria for mergers and acquisitions
were typically based on considerations such as the strategic fit of
the merged organizations, financial criteria, and operational
criteria. Mergers and acquisitions were often conducted without
much regard for the human resource issues that would be faced when
the organizations were joined. As a result, several undesirable
effects on the organizations’ human resources commonly occurred.
Nonetheless, competitive conditions favor mergers and acquisitions
and they remain a frequent occurrence. Examples of mergers among
some of the largest companies include the following: Honeywell and
Allied Signal, British Petroleum and Amoco, Exxon and Mobil,
Lockheed and Martin, Boeing and McDonnell Douglas, SBC and Pacific
Telesis, America Online and Time Warner, Burlington Northern and
Santa Fe, Union Pacific and Southern Pacific, Daimler-Benz and
Chrysler, Ford and Volvo, and Bank of America and Nations
Bank.
Layoffs often accompany mergers or acquisitions, particularly if
the two organizations are from the same industry. In addition to
layoffs related to redundancies, top managers of acquiring firms
may terminate some competent employees because they do not fit in
with the new culture of the merged organization or because their
loyalty to the new management may be suspect. The desire for a good
fit with the cultural objectives of the new organization and
loyalty are understandable. However, the depletion of the stock of
human resources deserves serious consideration, just as with
physical resources. Unfortunately, the way that mergers and
acquisitions have been carried out has often conveyed a lack of
concern for human resources.
A sense of this disregard is revealed in the following
observation:
Post combination integration strategies vary in tactics, some
resemble to “marriage & love’ but in reality, collaborative
mergers are much more hostile in implementing forceful decision and
financial takeovers. Yet, as a cursory scan of virtually any
newspaper or popular business magazine readily reveals, the simple
fact is that the latter are much more common than the former.
The cumulative effects of these developments often cause employee
morale and loyalty to decline, and feelings of betrayal may
develop. Nonetheless, such adverse consequences are not inevitable.
A few companies, such as Cisco Systems, which has made over 50
acquisitions
(https://www.cisco.com/c/en/us/about/corporate-strategy-office/acquisitions/acquisitions-list-years.html),
are very adept in handling the human resource issues associated
with these actions. An example of one of Cisco’s practices is
illustrative. At Cisco Systems, no one from an acquired firm is
laid off without the personal approval of Cisco’s CEO as well as
the CEO of the firm that was acquired.
QUESTIONS:
1. Interview someone who has been through a merger or acquisition.
Find out how they felt as an employee. Determine how they and their
coworkers were affected. Ask about the effects on productivity,
loyalty, and morale. Find out what human resource practices were
used and obtain their evaluations of what was helpful or
harmful.
In: Operations Management
In: Statistics and Probability
QUESTION 1
Advanced Directives:
|
Ensure that the health care provider offers the necessary information about an invasive procedure to allow the patient to make an informed decision |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Allows a competent patient to leave specific directions for medical care if they should become incompetent |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sets laws of "presumed consent" to donate organs |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
None of the above QUESTION 2 How did Webster v. Reproductive Health Services 492 U.S. 490 1989 modify Roe v. Wade
0.5 points QUESTION 3 Presumed consent to donate would allow:
0.5 points QUESTION 4 Which of the following criteria is included in the determination of eligibility to be placed on the list to receive donated organ?
0.5 points QUESTION 5 Eugenics:
0.5 points QUESTION 6 The statement "the well being of the patient should take precedence over the interests of society" and science is most consistent with:
0.5 points QUESTION 7 The Uniform Anatomical Gift Act:
0.5 points QUESTION 8 UNOS governs the distribution of donated organs True False 0.5 points QUESTION 9 The Natural Death Act provides the legal documentation for a person to donate their organs for medical research True False 0.5 points QUESTION 10 Advanced Directives are a type of living will that allows a competent person to leave instructions for treatments they would or would not like to have in the event they cannot make the decision themselves. True False 0.5 points QUESTION 11 In Roe v. Wade the Supreme Court determined that the fetus does NOT have 14th amendment rights. True False 0.5 points QUESTION 12 It is NEVER legal for humans to be used as research subjects. True False 0.5 points QUESTION 13 Socioeconomic status is not a factor used to determine whether or not a person is placed on the organ transplant list. True False 0.5 points QUESTION 14 The statement, " doctors have a duty to protect human life, and therefore should never perform euthanasia" is an argument most consistent with which ethical theory?
0.5 points QUESTION 15 The statement, " If all the women who became pregnant and were not in a financial position to care for the child were forced to have their children society would be overburdened with the responsibility of providing for these children. " is an argument most consistent with which ethical theory?
0.5 points QUESTION 16 Informed Consent is used to:
0.5 points QUESTION 17 Though there are some situations in which some type of harm seems inevitable in the course of treating patients, we are morally bound to choose the course which limits unneeded or futile pain for the patient. This is most consistent with which ethical principle?
0.5 points QUESTION 18 The statement, "the act of lying is wrong in all situations, regardless of the outcome" is most consistent with:
0.5 points QUESTION 19 The statement, "the act of lying is acceptable if the positive outcome of lying in a given situation outweighs the negative outcome" is most consistent with the theory of::
0.5 points QUESTION 20 CRISPR
|
In: Psychology
In: Nursing
Look up the current GNP, Prices, and employment numbers from the government agencies and determinant what stage of the business cycle we are in today and list the types of investments you should be looking for. List the government fiscal and monetary policy that the government should be using in that stage.
In: Economics
a. Sort the list A[ ]={ 20, 13,4, 34, 5, 15, 90, 100, 75, 102, 112, 1} using Insertion Sort and determine the total number of comparisons made (do not count swaps)
b. Sort the list stated in 5a) but using Merge Sort
In: Computer Science
Why might a healthcare professional use an abbreviation that is on the "Do Not Use" List or the Error-Prone List?
What are the possible consequences?
What is one example of misinterpreting an abbreviation?
What can healthcare professionals do to help prevent medication errors?
This is pharmacology. Study guide
In: Nursing