Questions
C-Language Modify the existing vector's contents, by erasing 200, then inserting 100 and 102 in the...

C-Language

Modify the existing vector's contents, by erasing 200, then inserting 100 and 102 in the shown locations. Use Vector ADT's erase() and insert() only. Sample output of below program:

100 101 102 103 

----------------------------------------------------------------------------------

#include <stdio.h>
#include <stdlib.h>

// struct and typedef declaration for Vector ADT
typedef struct vector_struct {
   int* elements;
   unsigned int size;
} vector;

// Initialize vector with specified size
void vector_create(vector* v, unsigned int vectorSize) {
   int i;

   if (v == NULL) return;

   v->elements = (int*)malloc(vectorSize * sizeof(int));
   v->size = vectorSize;
   for (i = 0; i < v->size; ++i) {
      v->elements[i] = 0;
   }
}

// Resize the size of the vector
void vector_resize(vector* v, unsigned int vectorSize) {
   int oldSize;
   int i;
   if (v == NULL) return;

   oldSize = v->size;
   v->elements = (int*)realloc(v->elements, vectorSize * sizeof(int));
   v->size = vectorSize;
   for (i = oldSize; i < v->size; ++i) {
      v->elements[i] = 0;
   }
}

// Return pointer to element at specified index
int* vector_at(vector* v, unsigned int index) {
   if (v == NULL || index >= v->size) return NULL;

   return &(v->elements[index]);
}

// Insert new value at specified index
void vector_insert(vector* v, unsigned int index, int value) {
   int i;

   if (v == NULL || index > v->size) return;

   vector_resize(v, v->size + 1);
   for (i = v->size - 1; i > index; --i) {
      v->elements[i] = v->elements[i-1];
   }
   v->elements[index] = value;
}

// Insert new value at end of vector
void vector_push_back(vector* v, int value) {
   vector_insert(v, v->size, value);
}

// Erase (remove) value at specified index
void vector_erase(vector* v, unsigned int index) {
   int i;

   if (v == NULL || index >= v->size) return;

   for (i = index; i < v->size - 1; ++i) {
      v->elements[i] = v->elements[i+1];
   }
   vector_resize(v, v->size - 1);
}

// Return number of elements within vector
int vector_size(vector* v) {
   if (v == NULL) return -1;

   return v->size;
}

void PrintVectors(vector* numberList) {
   int i;

   for (i = 0; i < vector_size(numberList); ++i) {
      printf("%d ", *vector_at(numberList, i));
   }
   printf("\n");
}

int main(void) {
   vector numberList;
   vector_create(&numberList, 0);

   // Populate vector with 101 200 103
   vector_push_back(&numberList, 101);
   vector_push_back(&numberList, 200);
   vector_push_back(&numberList, 103);

   // Erase 200 then insert 100 and 102

   /* Your solution goes here */

   PrintVectors(&numberList);

   return 0;
}

In: Computer Science

1) Consider the reaction: A (aq) ⇌ B (aq) at 253 K where the initial concentration...

1) Consider the reaction:


A (aq) ⇌ B (aq)

at 253 K where the initial concentration of A = 1.00 M and the initial concentration of B = 0.000 M. At equilibrium it is found that the concentration of B = 0.523 M. What is the maximum amount of work that can be done by this system when the concentration of A = 0.859 M?

2) Consider the following reaction at 257 K:

2 A (aq) + 1 B (aq) → 2 C (aq) + 2 D (aq)

An experiment was performed with the following intitial concentrations: [A]i = 1.37 M, [B]i = 2.19 M, [C]i = 0.47 M, [D]i = 0.31 M. The reaction was allowed to proceed until equilibrium was reached at which time it was determined that [A] = 0.57 M. What is ΔGnonstandard at the initial conditions? (I got -14.16kJ but it said i was wrong)

3) Consider the cell described below at 287 K:

Sn | Sn2+ (1.27 M) || Pb2+ (2.49 M) | Pb

Given EoPb2+ + 2 e-→Pb = -0.131 V and EoSn2+ + 2 e-→Sn = -0.143 V. What will the concentration of the Pb2+ solution be when the cell is dead?

4)A concentration cell is built based on the reaction:

2 H+ + 2 e- → H2

The pH in one of the half cells is -0.03743, while the pH in the other is 2.804. If the temperature of the overall cell is 296 K, what is the potential? (Faraday's constant is 96,485 C/mol e-)

In: Chemistry

If V is a linear space and S is a proper subset of V, and we...

If V is a linear space and S is a proper subset of V, and we define a relation on V via v1 ~ v2 iff v1 - v2 are in S, a subspace of V. We are given ~ is an equivalence relation, show that the set of equivalence classes, V/S, is a vector space as well, where the typical element of V/S is v + s, where v is any element of V.

In: Advanced Math

(a).    Check <u,v> =2u1v1+3u2v2+u3v3 is inner product space or not. If yes assume u= (8,0,-8) &...

(a).    Check

<u,v> =2u1v1+3u2v2+u3v3

is inner product space or not.

If yes assume u= (8,0,-8) & v= (8,3,16)

Find

  1. ||u||
  2. ||v||
  3. |<u, v>|2
  4. Unit vector in direction of u and v
  5. Distance (u, v)
  6. Angle between u and v
  7. Orthogonal vectors of u and v.

(b).    Show that

<u,v> =u1v1-2u2v2+u3v3

In: Math

Describe Young's double slit experiment in detail. What is the purpose of the experiment? What kind...

Describe Young's double slit experiment in detail. What is the purpose of the experiment?
What kind of result has been achieved with the experiment?

In: Physics

1. Describe the purpose of diffusion experiment. 2. Describe the purpose of osmosis experiment. 3. Describe...

1. Describe the purpose of diffusion experiment.
2. Describe the purpose of osmosis experiment.
3. Describe the observation/results of the osmosis experiment.

In: Biology

A.) A binomial probability experiment is conducted with the given parameters. Compute the probability of x...

A.) A binomial probability experiment is conducted with the given parameters. Compute the probability of x successes in the n independent trials of the experiment. n=12 p=0.3 x=3
B.) A binomial probability experiment is conducted with the given parameters. Compute the probability of x successes in the n independent trials of the experiment. n=20 p= 0.05 x=12
C.) A binomial probability experiment is conducted with the given parameters. Computers the probability of x successes in the n independent trials of the experiment. n=13 p=0.45 x?4
The probability of x?4 successes is ___?

In: Statistics and Probability

In two different experiments exactly 5 grams of fuel burns (combusts). The first experiment is under...

  1. In two different experiments exactly 5 grams of fuel burns (combusts). The first experiment is under constant pressure conditions, and the second separate experiment is under constant volume conditions.
  1. Which experiment is in a coffee cup calorimeter? And which is in a bomb calorimeter?
  2. One experiment produces 25 kJ of heat and one experiment produces 23 kJ of heat. Which experiment (the constant pressure one or the constant volume one) produces 25 kJ of heat and which produces 23 kJ of heat? Why?

    Please type the answers, don't write them on a paper

In: Chemistry

A double slit experiment is conducted with a red laser with wavelength l = 700 nm....

A double slit experiment is conducted with a red laser with wavelength l = 700 nm. The distance between the slits and the viewing screen is L = 2.00 m. Consider two experiments that have different slit spacings: Experiment A with dA = 2.00 μm and Experiment B with dB = 40.0 μm. For each experiment, calculate the following (be sure to keep at least three significant figures in all your intermediate calculations):

a)

  1. Using Δr = d sinθ , calculate the angle, q1, for the first maximum (constructive interference) above the central maximum. Experiment A and Experiment B

b)

  1. Using the angle you calculated in part a) and y = L tanθ , calculate y1, the location on the screen of the first maximum.Experiment A and Experiment B

In: Physics

A chemist is performing four experiments and each experiment has five results. The results for each...

A chemist is performing four experiments and each experiment has five results. The results for each experiment are given in the following table. An experiment is considered successful if the average of the five test results for a given experiment is between 25 and 32. Using a nested loop, write a script that (Python):

- Compute and display the test results average for each experiment

- Indicate is the experiment was successful or not

1st Results 49.1 15.8 16.9 25.2 33.4
2nd Results 34.8 45.2 27.9 36.8 23.4
3rd Results 26.4 16.8 10.2 15.8 18.9
4th Results 26.9 19.5 42.9 42.5 27.4

Hint : Use lists to store each experiment results and a single list to store the entire table

In: Computer Science