homework-help
Discord ID: 387060078433271808
753 total messages. Viewing 250 per page.
Prev |
Page 3/4
| Next
no it should be null at the last node
```java
// Inserts the specified element at the specified position in this list.
// Shifts the element currently at that position (if any) and any subsequent
// elements to the right (adds one to their indices).
// if(index < 0 or index > this.size), throws IndexOutOfBoundsException.
// E.g, if this list is [dummy]->["A"]->["B"]->["C"] with size = 3.
// add(0,D) will result in [dummy]->["D"]->["A"]->["B"]->["C"].
// Continuing on the previous add() call, add(1,"E") will
// change the existing list to [dummy]->["D"]->["E"]->["A"]->["B"]->["C"].
public void add(int index, Object o) {
ListNode newNode = new ListNode(o);
newNode.next = get(index);
get(index - 1).next = newNode;
this.size++;
}
```
maybe this method is messed up
no wait that one should be okay
```java
//Add the object e to the end of this list.
// it returns true, after e is successfully added.
public boolean add(Object e) {
ListNode newNode = new ListNode(e);
newNode.next = null;
get(this.size - 1).next = newNode;
this.size--;
return true;
}
```
this one might be the one with the problem
why --?
ya lol I just noticed that
that's definitely a mistake
doesn't fix the null pointer exception though
is there a stack trace?
this?
```java
Exception in thread "main" java.lang.NullPointerException
at MyLinkedList$ListNode.access$3(MyLinkedList.java:11)
at MyLinkedList.contains(MyLinkedList.java:59)
at MyLinkedListTester.testContains(MyLinkedListTester.java:119)
at MyLinkedListTester.main(MyLinkedListTester.java:216)
```
this is what I have on the contains method now
```java
// Returns true if this list contains the specified element o.
// More formally, returns true if and only if this list contains at least one element e
// such that (o==null ? e==null : o.equals(e)).
// Note: you have to handle the case where a list node stores null data element.
public boolean contains(Object o) {
for (int i = 0; i < size; i++) {
if (o == null && get(i).data == null) {
return true;
}
else if (Objects.equals(get(i).data, o)) {
return true;
}
}
return false;
}
```
@ThisIsChris Do you know how to fix this stuff?
or know who does?
where do you get the null?
what line
the same line as the if statement
should I paste the entire files in here or would that be too big?
for (int i = 0; i < index && cur != null; ++i)
zip them and email to [email protected]
It's too late for that
since it has to be turned in soon
but thanks
I'll just see what I can get fixed now
try changes to that for loop
okay thanks
what would cause the for look to cause a null pointer exception?
I suspect cur is null
and the recursion
```public ListNode get(int index) throws IndexOutOfBoundsException{
ListNode cur = head;
for (int i = 0; i < index && cur != null; i++) {
if (i == index) {
return get(i);
}
cur = cur.next;
}
return null;
}
```
```return get(i);```
the recursion
oh ya
and what is head
that's definitely messing something up
head is defined earlier
member var?
```java
public MyLinkedList() {
this.head = new ListNode(null); //with a dummy head node
this.size = 0;
}
```
okay that exception is fixed I think
maybe let's see if we can do anything with one more thing
is this linked list or tree node?
linked list
huh I get a null pointer exception from somewhere else, too
```java
------------------testAddLast()----
Exception in thread "main" java.lang.NullPointerException
at MyLinkedList$ListNode.access$2(MyLinkedList.java:11)
at MyLinkedList.add(MyLinkedList.java:205)
at MyLinkedListTester.testAddLast(MyLinkedListTester.java:42)
at MyLinkedListTester.main(MyLinkedListTester.java:214)
```
```java
public static void testAddLast() { //passed
System.out.println("------------------testAddLast()----");
init();
list3.add("A");
System.out.println(list3);
list3.add("B");
System.out.println(list3);
list3.add(null);
System.out.println(list3);
list3.add("C");
System.out.println(list3);
drawLine();
}
```
```java
//Add the object e to the end of this list.
// it returns true, after e is successfully added.
public boolean add(Object e) {
ListNode newNode = new ListNode(e);
newNode.next = null;
get(this.size - 1).next = newNode;
this.size++;
return true;
}
```
any glaring problems here?
that get() could return null
hmmm
any ideas on how to fix that?
after init()
how many nodes in list3
println after init()
4
what is size
should be 4
I see
list3.add("C") will throw
because last node was null
and when you get it... and attempt to set next
the data was null, not the node itself I think
ahh ok
it must be the size then
get(this.size - 1) is returning null
```
ListNode last = get(this.size - 1);
if (last != null) {
last.next = newNode;
++this.size;
return true;
}
return false;
```
thanks
this would only happen adding first node to list I would think
what is this class?
data structures?
or Java class?
Data Structures
I actually have a Java developer certificate but it was a long time ago so I have to relearn everything
Got it same time as I graduated high school
when I took that class we used C
1999 ๐
Java was its own class back then - the OOP class
I had to take a 3 part Java series to get into this class
It was part of my certificate
nice
it's a good line of work
I need help factoring a math problem @here
-x^2 + 5x + 14
(-x - 2)(x - 7)
I have meeting in 3 mins
but that is close
Have you been taught any particular methods for factoring?
Not really all I've learned is the "what adds to give us the middle term and multiplies to give us the third term
Okay, well first try writing out this (-x )(x ), think of a few number that multiply to form 14, and see which of those can be added or subtracted to form 5
In this case, 7*2 is 14, and 7-2 is 5. So, you put the 7 and the 2 in those parentheses and change the signs as needed.
Okay
(-x + 7)(x - 2) would create a negative 14, so, although that would work for the 5x, it wouldn't work for the 14. So the right answer is the one Paradigm Slide gave.
Honestly, this is largely just process of elimination, unless someone knows a better way
So before that wouldnt you write it as
-x^2+7x-2x+14? Factor out the -x, but then what happens to the x attached to the 7 and 2?
-x(-x+7)(x-2)(x+14) ?
It would be written out as -x^2-2x+7x-14
@Warren H so if you have (-x-a)(x-b) for some a,b then a*b = 14 and b-a = 5. The solution from inspection is a = 2 and b=7.
@ThisIsChris i imagined completing the square to be something different. iirc completeing the square is transforming a quadratic into the form (ax+b)^2+c
@YourFundamentalTheorum you're right my bad
If any of you nibbas need help with Econ or Statistics Im your guy.
Or business stuff in general.
@Sam Anderson <@&387091385075105804> role'd
<@&387091385075105804> Is anyone who is good that statistics online?
This isn't homework help, I just need to check the math on something and thought that this would be the best place to ask
I'm okay at stats. What's the question?
26% of the US population are immigrants and their children. A typical successful technology startup has 2.09 cofounders. Based on this data alone, how many of these companies would we expect to be founded or co-founded by immigrants or their children? Is it just 26*2.09?
I'm trying to refute the argument that immigrants are uniquely innovative because around 40% of Fortune 500 companies were founded or co-founded by an immigrant
This is outside my wheelhouse as far as stats go. I can say that the term "immigrants" is far to vague to make assumptions from.
I get what you're trying to do, I just don't think you have enough data right now
I think that kind of depends. First off, successful startup doesn't necessarily mean fortune 500 company. Even if we were to make that assumption, we don't know exactly what percentage of cofounders are immigrants, because those 40% of the companies could all have more than one, or just one immigrant cofounder
An immigrant from Somalia is going to be very different from an immigrant from Canada.
@Nicholas1166 - NY Is it enough to prove that the statistic given in the argument is meaningless?
To be honest friend, I don't know. That's a subjective question. The main issue is that you're extrapolating the startup company cofounder number onto the fortune 500 companies. If fortune 500 companies had, say, only one founder on average, or ten, it would tremendously disrupt your data
Also, like micbwilli said, immigrant is a very broad term. You could also try splitting up immigrants by national origin, which I think would prove a similar point. If that data isn't available, you might be able to find data on immigrant entrepreneurship pre and post 1965, which would also probably be useful
hmmm
I'm trying to phrase it in a way to sound like I'm not necessarily *disproving* it, I'm just using the available data to show that 40% really isn't that amazing
If I could find the average number of co-founders among Fortune 500 companies, that would solve it pretty easily
Maybe I could mitigate this by finding the average number of co-founders in the top 10 Fortune 500 companies?
Because I'm definitely not sitting here and counting up all 500
Number of founders per company is going to be highly variable
Plenty in the fortune 10 will have one founder
Like Sam Walton, Steve Jobs, etc
@Jacob make the sample size argument
the top 500 companies isn't a bad sample size tbh
this is what I have right now
The US has around 350 mil people. Versus the 8 bil on the world. For these purposes lets exclude all Blacks from populations that can do this lol
I'm not sure I follow the logic here
Vc once i finish pooping?
1. Assume for not revealing your power level in this class that the same proportion of all pops have the capability to be tech startups.
ya sure
oh this isn't for class
I'm trying to start writing articles for America First Media
Good idea
I should too
that would be cool if you do
we could review each others' articles
im in vc
okay give me a minute
FUCK
I forgot I lost my earphones
uhhhhhh not sure if I can do this right now
okay I'll just get in for a bit right now
while I'm home
@ophiuchus That's true, but I rephrased it so it's not a specific claim, I'm just saying that it's fairly normal for businesses to have more than one co-founder, so if they're 26% of the population, co-founding 40% of companies isn't amazing
@here ummm Im kind of stumped on this homework question. I really don't know how to respond without revealing my power levels and getting a bad grade because of it.
Drop that class right now!
Actually don't take my advice. I never went to college.
Haha
I wish I could
The prof is black of course ๐
I'm taking a Cultural Studies class right now which deals with a lot of these topics. I personally am fairly open about my beliefs and still get good grades from the liberal professor.
Say that those congressmen built their political careers when demographics were more on their side.
I'm not saying this is going to work every time, but, theoretically, public school professors aren't supposed to downgrade you for political beliefs
Itโll take years to phase in โdiverseโ congressmen.
If any of you are interested, I can upload some of my assignments. I'm pretty hardcore in them.
I hope she wouldn't give a bad grade, but she warned us she would report any in appropriate discussion
I had a similar question to yours last quarter. My argument was that minorities are largely here because the founding stock let them come here, so we don't have any obligation to guarantee them representation.
But, again, I don't know what your school is like
So I'm not necessarily saying you should risk it
That's ballsy to write in college, to be honest
You can always try being really literal, and kind of avoid the question. I don't know what the essence of the assignment is
@Nicholas1166 - NY very ballsy indeed. The teacher is black, and we have a pretty diverse group of thought.
It's for a government class
Do you want to represent your views, or are you full incognito and just want to do the assignment?
I've gotten perfect grades on all my reading notes in my cultural studies class, and this is what I've written about:
> Colonization is not the source of poverty in Africa, and did not make Europeans rich
> Segregation did not make blacks poor
> If we have to ensure minority representation, do we have to ensure white representation?
Last quarter I did a speech on why mass immigration sucks and got a good grade. This quarter I'm doing another one.
I also challenged my professor and argued that there is a biological basis for race, and had the whole class gang up on my. I have audio if anyone is curious.
I think that qualifies for beast mode chief
My school let in so many chinese students that I don't even have to redpill, they're doing it for me
That being said, every campus is different. My school is right wing enough that their won't be too much backlash, and a large part of my social life is IE, so I don't care if students judge me for my beliefs. You might have good reasons to care, and you shoudn't put that at risk just to be a badass.
@Jacob - could you brief me, or give me a good, concise resource on your colonization point so I can use that argument and back it up?
No, you're absolutely right. You need to have a read on your audience
I can post the document if you would like @Aleisโccidentalis
My campus is very left wing
That'd be great!
I largely built on Ryan Faulk's work
thanks so much. I go to an overwhelmingly Liberal university and I need more intellectual ammo for when I cause tension in the classroom
@Aleisโccidentalis Just be careful. I don't want to make it sound like everyone should do it just because I did it. My campus is largely apolitical, and fairly right wing. I don't know if I would have risked all this at a different school.
You've got a unique writing style, really cuts straight to the point. I wonder if those statistics (development, infant mortality, etc.) vary depending on the colonizing nation. For example, I wonder if British colonies, as a collective whole, fared better than Belgian or French ones
Yes, I believe they do, though I don't remember exactly
Absolutely...so far I've been great about masking myself until an appropriate time to strike. Especially if I can put it in a way that sounds appealing to Leftists
oh I do that, too, sometimes
it's good to find common ground with them
It can be a lot of fun to use their own values against them. I like to talk about how immigration harms the third world through brain drain.
I think creating waterproof arguments for our idea is pretty vital, although there's one possible confliction I've noticed within the argument. Overall, I think it's a good piece, I'm just playing devil's advocate here. It would make sense that a colonizing nation would hold onto colonies containing valuable natural resources for longer durations of time. It also makes sense that they would send some of their own natives to create a stable government, loyal to the home nation. These colonies would be held onto most fiercely, and might be the last do decolonize. Since they are so resource rich, they naturally have better GDP outcomes than sparse colonies that were abandoned earlier
I recently brought up how the demand for institutional diversity actually dilutes the identity of minority groups, and how it forces them to live amongst people they don't want to be around, rather than a homogeneous community of their own kind.
@Nicholas1166 - NY Ryan addresses that in his video. I don't remember the exact data, but, as an example, South Africa was pretty barren before it got settled, and it's way more advanced than other African countries.
With regards to that homework question, I'd simply point out that majority black districts have almost exclusively black representatives, so it's not surprising that, when most districts and states are majority white, they'll mostly have white representatives
okay am I just dumb or does anyone else find these instructions kind of confusing
?
<@&435155896780324864>
what does "write the summary of the method interface(signature)" mean?
and what is "the recursive definition or your recursive solution"?
@Jacob
so if your function is
```python
def fibonacci(n):
if n == 0 or n == 1:
return n
else:
return fibonacci(n-1) + fibonacci(n-2)
```
Then 1. the function signature is `fibonacci(n)`. (In Java this probably looks more like `public int fibonacci(int n)`
2. the base case is
```python
if n==0 or n ==1:
return n
```
3. the recursive part is
```python
if not(n==0 or n==1):
return fibonacci(n-1) + fibonacci(n-2)
```
@ThisIsChris Thanks a lot
okay this should be pretty easy
lmao IllegalArgumentException reminds me of that "illegal opinions" meme with Merkel
lol
@Jacob you're welcome
@ThisIsChris I'm doing chain rule in Calculus 1 and would like to know how to do the problem: cot^2(sinx)
@GDoctor
1. set `y = sin(x)`
2. the derivative of `cot^2(y)` is `-1/sin^2(y)`
3. so the derivative of `cot^2(sinx)` with respect to `x` is the derivative of `cot^2(y)`with respect to `x` which is `(-1/sin^2(y)) * (dy/dx)`
4. `dy/dx = cos(x)`
5. the derivative of `cot^2(sinx)` with respect to `x` is
`(-1/sin^2(y)) * (dy/dx)`
`(-1/sin^2(sin(x))) * (cos(x))`
@ThisIsChris Thank you so much.
@GDoctor You're welcome!
Anybody know how to calculate a MONTHLY average from QUARTERLY costs? I have to write a C++ program that does that...
@GDoctor I'm not sure I understand the assignment. Since there's 3 months in a quarter then wouldn't the monthly average of a quarter be the quarterly costs divided by 3?
Anyone know how to transform a multivariate regression so that you can do a t test of B1 + 2B2 = 0 and B1 + B2 = 1? I already got it for B1 = B2
Base regression formula is Y = B0 + B1X1 + B2X2 + error
<@&387091385075105804> ^^^
Can someone take a look at a Java assignment for me?
<@&435155896780324864>
<@&387091385075105804>
I'm supposed to write a get method for a hashtable. It seems way too simple so I'm wondering if I'm missing something.
Are get methods for hashtables really that complex that this warrants an entire assignment?
Or am I overthinking it and this is actually really easy?
@Jacob In the future can you put this stuff into pastebin?
Yes
Jacob, you posted an essay about immigration a while back. I just read it recently and I have some feedback to help you improve your writing. I was thinking we could go through it via audio, or if you prefer, I can write it out.
Yes, I'll find some time
Can anyone explain how to create a cout statement in C++ that'll print a number array each time it's sorted?
@ThisIsChris perhaps?
<@&387091385075105804> ^^^
@GDoctor You want the array printed after sorting or before sorting?
I'm sad that my skills are never needed when I see the AE call. It's never something I have experience with. ๐
@micbwilli what are some of the topics you like?
Biology and Chemistry are mostly what I know.
@ThisIsChris the assignment calls for output after each "pass" through an array during a sort, (any kind of sort can be used).
@GDoctor OK that makes sense! what code do you have so far?
Not much, just the boilerplate #include, main function and the array initialized. I jist wanna know how to get it to print after each pass and not just after sorting is done.
@GDoctor can you paste the code? put it between three back ticks both above and below the code:
```python
x = 3
print(x)
```
#include<iostream>
using namespace std;
int main()
{
const int NUMINTS = 20;
int randomNumbers[NUMINTS] = { 24, 9, 88, 15, 22, 38, 10, 76, 62, 54,
51, 39, 10, 13, 66, 89, 99, 100, 33, 75, };
}
```cpp
#include<iostream>
using namespace std;
int main()
{
const int NUMINTS = 20;
int randomNumbers[NUMINTS] = { 24, 9, 88, 15, 22, 38, 10, 76, 62, 54,
51, 39, 10, 13, 66, 89, 99, 100, 33, 75, };
}
```
Can anyone help with a bit of statistics? Here's the problem: if P(A|B) = 0.7 and P(A'|B') = 0.3, are A and B independent or dependent? I'm not sure if I should use Baye's Theorem or something else to relate the two statements <@&387091385075105804>
@Jakob-NY My first thought here is that P(A'|B') = 0.3 means that P(A|B') = 0.7 since P(A|B') = 1 - P(A'|B')
Oh gotta go dig deep in the textbooks for this
753 total messages. Viewing 250 per page.
Prev |
Page 3/4
| Next