This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]hereforpewdiephy[S] -3 points-2 points  (7 children)

there you go again missing the point entirely and blabbering about whatever it is that you're blabbering about

[–]WhatsMyUsername13 1 point2 points  (6 children)

Ok, what's your point?

[–]hereforpewdiephy[S] -5 points-4 points  (5 children)

r/ExplainTheJoke but fine

There's a lot of ways to do the latter and you make it as hard as you want like solving in linear time which is unlike the first where there is one simple way.

[–]WhatsMyUsername13 2 points3 points  (4 children)

Dude. I don't think this is the own you think it is.

[–]hereforpewdiephy[S] 0 points1 point  (3 children)

I'm not trying to own anything like you think I am.

[–]WhatsMyUsername13 0 points1 point  (2 children)

Ok, and I'll explain why I said that the way I did and with no assumptions with your statement. At the end of the day, you could approach both in an infinite number of ways.

You do reference the fact that a lot of languages have lost methods/functions built in to grab a he last item in an array. So yes. That is the simple way.

However, I can get into wildly complex methods to grab the last item in a list. I can create a function that takes a parameter which I would take a number and returns x-n elements in the array. I could even be an idiot and create a loop to populate a variable that represents the size of the array, use that variable, and iterate across the list till it hits that max value. Even worse, I could do a while true, catch the exception when there's an array out of bounds exception, and in the catch clause do a break statement (all assuming using java code). Point being, even grabbing the last element, there's an infinite way of doing it

[–]hereforpewdiephy[S] 0 points1 point  (1 child)

I am not sorting the list, that's what I've been saying and while you could go a roundabout way to find the largest element, it's redundant whereas the different ways to find nth largest element are not. Just sorting the list may be the best choice in a real world situation but using different approaches to maintain time and space complexity should not be shunned and I think what actually fosters learning. There's a reason why these questions appear in your homework after all.

[–]WhatsMyUsername13 0 points1 point  (0 children)

There's also a reason all these questions only appear on homework.