In: Operations Management
It is about C++linked list code. my assignment is making 1 function, in below circumstance,(some functions are suggested for easier procedure of making function.)
void push_Stack (struct linked_list* list, struct linked_node* node) //*This is the function to make and below is the explanation that should be written in given code.
This function inserts a node in stack manner. If the type of list is not stack, print the error message “Function push_Stack: The list type is not a stack” The new node will be always inserted to tail of the list which means the tail of the list should be changed after a new node is inserted.
Given code is written below,(There is a function to fill in last moment in this code)
linked_list.h: This is the header file of linkLQS.c that declares all the functions and values that are going to be used in linkLQS.c. You do not have to touch this function.
-----------------------------------------------------------------------
(Below code is about linked_list.h)
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
struct linked_node{
int value;
struct linked_node* next;
struct linked_node* prev;
};
struct linked_list{
int type_of_list; // normal = 0, stack = 1
struct linked_node* head;
struct linked_node* tail;
int number_of_nodes;
};
--------------------------------------------------------
#include "linked_list.h"
#include "string.h"
extern int list_exist;
struct linked_list* create_list (int number_of_nodes, int
list_type)
{
int a[number_of_nodes];
int i, j;
int bFound;
if (number_of_nodes < 1)
{
printf("Function create_list: the
number of nodes is not specified correctly\n");
return NULL;
}
if(list_exist == 1)
{
printf("Function create_list: a
list already exists\nRestart a Program\n");
exit(0);
}
if(list_type != 0 && list_type != 1)
{
printf("Function create_list: the
list type is wrong\n");
exit(0);
}
struct linked_list * new_list = (struct
linked_list*)malloc(sizeof(struct linked_list));
new_list->head = NULL;
new_list->tail = NULL;
new_list->number_of_nodes = 0;
new_list->type_of_list = list_type;
//now put nodes into the list with random
numbers.
srand((unsigned int)time(NULL));
if(list_type == 0)
{
for ( i = 0; i <
number_of_nodes; ++i )
{
while ( 1
)
{
a[i] = rand() % number_of_nodes + 1;
bFound = 0;
for ( j = 0; j < i; ++j )
{
if ( a[j] == a[i] )
{
bFound =
1;
break;
}
}
if ( !bFound )
break;
}
struct
linked_node* new_node = create_node(a[i]);
insert_node(new_list, new_node);
}
}
else if(list_type == 1)
{
for ( i = 0; i <
number_of_nodes; ++i )
{
while ( 1
)
{
a[i] = rand() % number_of_nodes + 1;
bFound = 0;
for ( j = 0; j < i; ++j )
{
if ( a[j] == a[i] )
{
bFound =
1;
break;
}
}
if ( !bFound )
break;
}
struct
linked_node* new_node = create_node(a[i]);
push_Stack(new_list, new_node);
}
}
list_exist = 1;
printf("List is created!\n");
return new_list;
}
struct linked_node* create_node (int node_value)//This
functon is the example for reference of the assignment
function
{
struct linked_node* node = (struct
linked_node*)malloc(sizeof(struct linked_node));
node->value = node_value;
node->next = NULL;
node->prev = NULL;
return node;
}
void insert_node(struct linked_list* list, struct
linked_node* node)//This functon is the example for reference of
the assignment function
{
node->next = NULL;
node->prev = NULL;
if(list->head == NULL)
//if head is NULL, tail is also NULL.
{
list->head = node;
list->tail = node;
list_exist = 1;
}
else if(list->head == list->tail)
{
node->next =
list->head;
list->head->prev =
node;
list->head = node;
}
else if(list->head != list->tail)
{
node->next =
list->head;
list->head->prev =
node;
list->head = node;
}
(list->number_of_nodes)++;
}
void push_Stack(struct linked_list* list, struct
linked_node* node)//The function to be written!!
{
~~~~~~~~~~~~~~~~ //your code starts from
here
}
In: Computer Science
1. A 33 year old female who is 32 weeks pregnant comes in to the clinic for prenatal care. The nurse notices fingertip bruising around the client’s neck and on her abdomen. She is accompanied by her boyfriend into the examining room.
2. Describe what the nurse can do to create an environment of trauma informed care on admission for a patient who has overdosed on Tylenol prior to admission.
3. The patient on the mental health unit is pacing in the hallways, yelling out, “shut up,” and begins punching and kicking into the air. As the nurse how should you respond?
In: Nursing
What are some patents Tesla holds? Or are they sharing patent information?
In: Operations Management
Complete the corresponding assembly language fragments by selecting the correct instruction, register, or value: (Choices in bold)
a) Consider the following fragment of C code:
if(a == b) {
x += 10;
A[50] = A[50] +x;
}
else {
y += 10;
A[50] = A[50] + y;
}
Assume that variables a, b, x and y are assigned to $s0, $s1, $s2 and $s3 respectively and the base address for array A is in $s4. Only register $t0 is used for storing results temporarily.
bne $s0, ($s0 / $s1 / $s2 / $s3 / $s4 / $t0), else
addi $s2, $s2, 10
lw $t0, (0 / 10 / 50 / 200 / $s1 / $t0) ($s4)
add $t0, $t0, $s2
sw $t0, 200($s4)
j Exit
else: addi $s3, $s3, (0 / 10 / 50 / 200 / $s1 / $t0)
lw $t0, 200($s4)
add $t0, 200($s4)
add $t0, $t0, ($s0 / $s1 / $s2 / $s3 / $s4 / $t0)
(beq / bne / j / add / addi / sll / lw / sw) $t0, 200($s4)
Exit:
b) Consider the following fragment of C code:
while (A[i] == 0) {
A[i] = A[i] + 10;
i += 1;
}
Assume that variable i is assigned to $s0 and the base address for array A is in $s1. A is an array of words. Registers $t0 and $t1 are used for storing results temporarily.
Loop: sll $t0, $s0, (0 / 1 / 2 / 4 / 10)
add $t0, $t0, $s1
lw $t1, 0( ($s0 / $s1 / $t0 / $t1 / $zero) )
bne $t1, $zero, (Loop / Exit)
addi $t1, ($s0 / $s1 / $t0 / $t1 / $zero), 10
sw $t1, 0($t0)
addi ($s0 / $s1 / $t0 / $t1 / $zero), $s0, 1
j Loop
Exit;
In: Computer Science
A titrimetric method for the determination of calcium in
limestone was tested by analysis of a NIST
containing 30.15% CaO. The mean result of four analyses was 30.26%
CaO, with standard deviation of 0.085%.
By pooling data from several analyses, it was found that s =
0.094% CaO.
a) Do the data indicate the presence of a systematic error at the
95% confidence level?
b) Would the data indicate the presence of a systematic error at
95% confidence level if no pooled value for s
had been available?
Show calculations for part a and b.
In: Chemistry
Brike Company, which manufactures one product - robes, has enough idle capacity available to accept a special order of 10,000 robes at $9 a robe. A predicted income statement for the year, without this special order is as follows: |
||||
Sales revenue |
$12.50 |
$1,250,000 |
||
Manufacturing costs: |
||||
Variable |
6.25 |
625,000 |
||
Fixed |
1.75 |
175,000 |
||
8.00 |
800,000 |
|||
Gross profit |
4.50 |
450,000 |
||
Marketing costs: |
||||
Variable |
1.80 |
180,000 |
||
Fixed |
1.45 |
145,000 |
||
3.25 |
325,000 |
|||
Operating profit |
$ 1.25 |
$ 125,000 |
||
If the order is accepted, variable marketing costs on the special order would be reduced by 25 percent because all of the robes would be packed and shipped in one lot. However, if the offer is accepted, management estimates that it will lose the sale of 2,000 robes at regular prices. What is the net gain or loss from the special order? |
In: Accounting
Consider the following page reference string:
0, 1, 2, 3, 1, 0, 4, 5, 1, 0, 1, 2, 6, 5, 2, 1, 0, 1, 2, 5
How many page faults would occur for the following replacement algorithms, assuming one, three, five, and seven frames? Remember that all frames are initially empty, so your first unique pages will cost one fault each.
In: Computer Science
Contrast the medical model of psychological disorders with the biopsychosocial approach to disordered behavior. How does this relate to Community Psychology?
In: Psychology
Do you think different types of life traumas -- for example, loss of a job, death of a spouse, divorce, or a major health problem -- would prompt a person to refocus on different previous developmental solutions? Please describe solutions that you believe a person in middle adulthood would use to cope with traumas, and factors that might influence how well or how poorly the person copes.
In: Psychology
In: Psychology
3.1. Explain the concepts "Procedures" and "Modularity" as related to programming.
3.2. Explain each of the class members that belong to object orientated programming.
In: Computer Science
Would you allow yourself to be connected to Nozick’s “Experience Machine” for the rest of your life? Why or why not? What do you believe this thought-experiment shows us about what we find important in life?
In: Psychology
(history) The U.S. in the Caribbean Please answer the following short-answer questions. Your answers should be paragraph-length (between 100 to 200 words)
1) How did the United States obtain control of the Panama Canal? What were the characteristics of the construction of the Canal under the U.S., when did the Canal open and what is its significance?
2) How would you characterize the relationship between the U.S. and so-called “Banana Republics”?
In: Biology
1. Two particles having charges of 0.570 nC and 20.5 nC are separated by a distance of 1.20 m .
a) At what point along the line connecting the two charges is the net electric field due to the two charges equal to zero?(Express your answer in meters.)
b)Where would the net electric field be zero if one of the charges were negative?(Enter your answer as a distance in meters from the charge initially equal to 0.570 nC .)
c)Is this point between the charges? Yes or No
2. A charged paint is spread in a very thin uniform layer over the surface of a plastic sphere of diameter 19.0 cm , giving it a charge of -13.0 μC .
a) Find the electric field just inside the paint layer. (Express your answer in newtons per coulomb.)
b) Find the electric field just outside the paint layer. (Express your answer in newtons per coulomb.
c) Find the electric field 6.50 cm outside the surface of the paint layer. (Express your answer in newtons per coulomb.)
In: Physics