|
| |||||||
| http://www.narutomania.com/forums/New Month, New Problems |
| For these forums to remain up we need $480 within 7 days. Please donate HERE br> br> We need this amount no matter what to keep this website up. Thank you for your support. |
![]() |
| | Thread Tools |
29-02-2008, 05:20 AM
| #1101 |
| Akatsuki |
void List::insert(int index, const ListItemType& newItem) throw(ListIndexOutOfRangeException, ListException) { int newLength = getLength() + 1; if ( (index < 1) || (index > newLength) ) throw ListIndexOutOfRangeException( "ListIndexOutOfRangeException: insert index out of range"); else { try { ListNode *newPtr = new ListNode; size = newLength; newPtr->item = newItem; ListNode *prev = find(index); newPtr->next = prev->next; prev->next = newPtr; } catch (bad_alloc e) { throw ListException( "ListException: memory allocation failed on insert"); } } } This is my insert function, which is add function. So Would my main look like this? let say I have a class call arrayList. arrayList anArrayList; anArraylist.insert(1); anArraylist.insert(2); ?
__________________ ![]() ![]() thanks to Tom, ~Mrge and Simonarturo, EE Last edited by Ice(v)an; 29-02-2008 at 06:29 AM. |
| |
29-02-2008, 10:27 PM
| #1102 |
| Donator |
Right on the main, you should just insert a bunch of things, and then maybe retrieve them. For the class though, it looks like you are using a linked list, whereas the teacher wants an array. So your class should have something like Code: MyType myArray[]; int currentSize; int maxsize; Code: myArray = new MyType[50]; currentSize = 0; maxSize = 50; Code: if (currentSize == maxSize) {
maxSize = maxSize * 2;
MyType newArray[] = new MyType[maxSize];
memcpy(newArray, myArray, currentSize * sizeof(MyType));
delete myArray;
myArray = newArray;
}
myArray[currentSize] = newValue;
currentSize++;
|
| |
03-03-2008, 04:20 AM
| #1103 |
| Elite Jounin Join Date: Apr 2007 Location: Pm me your address for fun times
Posts: 6,423
My Mood:
Rep Power: 27 ![]() ![]() ![]() ![]() |
Okay um. Did anyone ever read Canturbery Tales? If Yes, plz help. In the tale of the wife of bath, what element of the narrator's personality does Chaucer emphasize? And, Why is the narrator of the WIfe of Bath's tale an odd and even ironic choice to deliver? PLZ SOMEONE TELL ME THEY READ THIS
__________________ Weeeeee <3 |
| |
03-03-2008, 09:16 PM
| #1104 |
| Raitei Join Date: Nov 2004 Location: Noway
Posts: 1,417
My Mood:
Rep Power: 21 ![]() ![]() |
This is really not a homework question, but i think this is the place it has to be posted. I am wondering if there is any good and informative website about mathematics, university-level and preferably about economics. This piece of shit economics book i have skips parts of a calculation and leaves you wondering "How the fuck did they factorize that into that" or "Why is it like that". To be frank i could take this shit in High School because i thought that at university they would finally teach you why things are the way they are, we werent allowed to ask why the answer is the right answer etc, but nothing has changed
__________________ All I am about to do is strike you 8 times okay? |
| |
04-03-2008, 03:18 AM
| #1105 | |
| the Brown Join Date: Apr 2007 Location: Never separate me from these stars...
Posts: 11,138
My Mood:
Rep Power: 59 ![]() | Quote:
As for the secound question, try to look at how the narrorator is in comparison to the rest of the setting, characters, and plot. Why does he stand out? Is there any part of his proffession or life that is on in conjuction with the rest of the story? Here's also a good resource that'll probably help you. "What Man Artow?" The Narrator as Writer and Pilgrim
__________________ | |
| |
05-03-2008, 02:35 AM
| #1106 |
| Chuunin |
Give an example of functions f and g for which fg is differentiable at 0, but f'(0) and g'(0) do not exist.
__________________ |
| |
05-03-2008, 03:12 PM
| #1107 |
| Medical-nin Join Date: Sep 2004 Location: In my chair...
Posts: 938
My Mood:
Rep Power: 21 ![]() ![]() |
Can someone help me out with this question. I get lost within the substitutions: Solve dy/dx -2xe^x = y by letting y=ue^x
__________________ |
| |
06-03-2008, 02:58 AM
| #1108 | ||
| Administrator | Quote:
Quote:
Let y = u * ex where u = -2x and du = -2 * dx Applying the product rule: y = u * ex dy = u * ex * dx + ex * du Substituting... dy = u * ex * dx + ex * du dy = -2x * ex * dx + ex * -2 * dx dy = -2x * ex * dx + -2 * ex * dx dy/dx = -2 * ex * (x + 1) I'm pretty tired right now, so you'd best check that :\
__________________ | ||
| |
06-03-2008, 03:15 AM
| #1109 | |
| Genin | Quote:
let y = u e^x y' = u' e^x + u e^x (product rule) y' = e^x( u' + u) Let's substitute y and y' back in the original equation: dy/dx -2xe^x = y e^x(u'+u) - 2xe^x = u e^x e^x(u'+u-2x) = ue^x we can divide by e^x since it's never equal to zero u'+u-2x=u u'=2x u=x^2+C back to the equation of y: y=(x^2+C) e^x | |
| |
06-03-2008, 03:25 AM
| #1110 |
| Chuunin | f(x) * g(x), sorry for bad typing
__________________ |
| |
06-03-2008, 03:49 AM
| #1111 | ||
| Genin | Quote:
Quote:
![]() | ||
| |
06-03-2008, 05:51 AM
| #1112 |
| Administrator |
You may well be right. I thought it was just asking for the derivative. It makes more sense if it's the question you answered. I'm almost asleep at my keyboard >_<
__________________ |
| |
09-03-2008, 07:15 PM
| #1113 |
| Raitei Join Date: Nov 2004 Location: Noway
Posts: 1,417
My Mood:
Rep Power: 21 ![]() ![]() |
Given F(x)= x^2 We can derivate it (spelling?) by adding a value to x, h and finding f(x+h) and diving by h. F(x+h)= x^2+2xh+h^2 [F(x+h)-F(x)]/h = ((2x+h)h)/h = 2x+h If we let h->0 => F'(x)= 2x Now i can do this for cubic and quadratic equations etc but i have no clue what to do when F(x)= (x)^1/3 i know that the end result is F'(x)= [1/3](x)^(-2/3)
__________________ All I am about to do is strike you 8 times okay? |
| |
09-03-2008, 09:19 PM
| #1114 | |
| Genin | Quote:
It's the same idea. I'll do (x^1/2)' first because I think it will be easier to understand how to do (x^1/3)' afterwards. f(x) = x^1/2 so f(x+h)=(x+h)^1/2 (f(x+h)-f(x))/h = ((x+h)^1/2-x^1/2) / h if you take the limit of this coefficient as h->0, you get f'(x). Unfortunately, you can't do that right now since h is in the denominator. So, what to do? The idea is to get rid of the h in the denominator. But, how can you do that? You see that we have h in the numerator, so it would be nice if we can get something of the form h*(something)/h in order to cancel the h's. Can we do that? There is a nice property of multiplication that says anything multiplied by one is equal to the same thing. We can apply this idea here and multiply the numerator and denominator with the same number in order to get h in the numerator. This is our goal, so let's think about it for a moment. (x+h)^1/2-x^1/2 We want to get h out of the square root. If it was only (x+h)^1/2, we could square it and get what we want, but alas we can't do that because of the x^1/2. What we can do though is multiplying the numerator and the denominator by the conjugate which is (x+h)^(1/2)+x^1/2 ((x+h)^1/2-x^1/2)*((x+h)^(1/2)+x^1/2) = (x+h)-x = h Why is that?? basically it is applying the equation (a^2-b^2) = (a-b)(a+b). Our a-b here is (x+h)^1/2-x^1/2. You should understand this in order to be able to solve (x^1/3)'. Finishing off the derivative of x^1/2: ((x+h)^1/2-x^1/2) / h * (((x+h)^1/2+x^1/2)/((x+h)^1/2+x^1/2) = h/h((x+h)^1/2+x^1/2). You see that h in the numerator cancels with the h in the denominator and we get 1/((x+h)^1/2+x^1/2). If you take the limit of this as h->0 you get 1/(2*x^1/2) Having said that, how to find the derivative of x^1/3? It is finding the limit of ((x+h)^1/3-x^1/3)/h as h->0 Same idea. We want to get the h out of the cubic root this time. How to do this? Using the formula (a^3-b^3) = (a-b)(a^2+ab+b^2) and taking (x+h)^1/3-x^1/3 as a-b you should be able to answer the question. | |
| |
13-03-2008, 02:17 AM
| #1115 |
| Niju Shōtai Join Date: Jan 2007 Location: New York,Brooklyn
Posts: 5,000
My Mood:
Rep Power: 16 ![]() |
I need help with my physics hw, solving it will be great but telling me which equations to use would be ok too. Two small metallic spheres, each with a mass of 0.200 g, are suspended as pendulums by light strings from a common point. They are given the same electric charge, and the two come to equilibrium when each string is at an angle of 8 degrees with the vertical. The Coulomb constant is 8.98755 x 10^9N x m^2/C^2, and the acceleration of gravity is 9.81m/s^2. If each string is 36.0 cm long, what is the magnitude of the charge on each sphere? Answer in units of C. |
| |
13-03-2008, 05:53 AM
| #1116 | |
| Genin | Quote:
Now all you have to do is draw the free body diagram to one of the charged masses. There are three forces that act on each charged mass: 1. force caused by gravity oriented downward (mg). 2. tension from the string (you have to decompose this force to two forces, one on the horizontal (axis) and the other on the vertical axis). 3. the repulsive force from the other charge: f=Kq^2/r^2. Given the length of the string and the angle between the string and the vertical axis you should be able to find r. Actually sin 8 = (r/2)/36 You should be able to finish it off, I suppose. | |
| |
18-03-2008, 08:42 PM
| #1117 |
| Akatsuki |
Can someone help me do this? Implement a recursive backtracking approach to solve the following problem: A penny starts at position (0,0) on a piece of graph paper. We move it repeatedly. Each move is a distance of sqrt(5) and places the penny at a position (m,n), where m and n are in the set {0,1,2,3}. How is it possible to move the penny 14 times in this way without visiting the same location twice? My professor likes recursive problems...
__________________ ![]() ![]() thanks to Tom, ~Mrge and Simonarturo, EE |
| |
19-03-2008, 05:01 AM
| #1118 | |
| Donator | Quote:
Well basically, that move distance means that all moves must be like chess knight moves: 2 spaces in one direction and 1 in another. So the question is how to make 14 such moves in that 4x4 grid? To do this recursively, we have to write a function that answers the question when given the first N moves and does so by trying out different possible moves for the N+1th move and calling itself to continue. Thus your function should be something like Code: bool findSolution(vector<pair<int, int>> movesSoFar,
vector<pair<int, int>>& solution)
Otherwise, it should then calculate given the last position in movesSoFar, all the positions you could do a knight's move to and remove all the ones that appear earlier in movesSoFar. Then for each new position create a new vector with the new move in it and call findSolution on the new vector, if it returns false try the next move, if it returns true return the solution. | |
| |
19-03-2008, 09:27 PM
| #1119 |
| Chuunin |
a) Prove that if f and g are convex and f is increasing then f o g is convex (Hint: use f( tx + (1-t) y ) < tf(x)+(1-t) f(y) c) Suppose that f and g are twice differentiable. Give another proof of the result of part a) by considering second derivatives. much thanks to anyone who can these questions
__________________ |
| |
23-03-2008, 03:33 AM
| #1120 |
| Akatsuki |
How do I make each move square root of five distance
__________________ ![]() ![]() thanks to Tom, ~Mrge and Simonarturo, EE |
| |