|
Blert the Duck posted:learn algos in python you'll hate life a lil less what's the point of even doing an algo in python
|
# ? Jul 10, 2014 23:24 |
|
|
# ? May 13, 2024 05:23 |
|
USSMICHELLEBACHMAN posted:what's the point of even doing an algo in python python is a language designed to be relatively good at computations!
|
# ? Jul 10, 2014 23:26 |
|
yeah but it's like what's the point of dealing with things like stacks and linked lists when you're using a language that doesnt have pointers
|
# ? Jul 10, 2014 23:28 |
|
USSMICHELLEBACHMAN posted:yeah but it's like what's the point of dealing with things like stacks and linked lists when you're using a language that doesnt have pointers it may not have pointers but you could pull of stack and linked list implementations if you want most languages aim to be versatile i suppose. just because you could do somethign better in C doesnt mean you always have the option to do it in C
|
# ? Jul 10, 2014 23:30 |
|
USSMICHELLEBACHMAN posted:what's the point of even doing an algo in python exactly the same point as doing it in any other language: http://goatkcd.com/722/
|
# ? Jul 10, 2014 23:30 |
|
Valeyard posted:it may not have pointers but you could pull of stack and linked list implementations if you want it's not that it's better in c it's just that if someone told me to make a stack in python i'd use an array i mean it's fine for learning the broad concepts but trying to reason about space efficiency in a language without memeory management or trying to reason about time efficiency in a language where the details of array.pop are entirely unknown to you is impossible. like you can just say 'well let's ignore all the trivial details' which is fine and sitll works and you can learn just fine but it bothered me too much plus implementing all my own data structures in c and then using those structures while i was learning algos was very fun and satisfying DONT THREAD ON ME fucked around with this message at 23:37 on Jul 10, 2014 |
# ? Jul 10, 2014 23:31 |
|
USSMICHELLEBACHMAN posted:it's not that it's better in c it's just that if someone told me to make a stack in python i'd use an array lol at caring about space complexity!!
|
# ? Jul 10, 2014 23:41 |
|
USSMICHELLEBACHMAN posted:it's not that it's better in c it's just that if someone told me to make a stack in python i'd use an array in fact there are lots of interesting data structures that can be implemented on top of arrays. for example, heaps are a type of binary tree that's often implemented using a flat array. a nice sample implementation may be found in the standard heapq library that ships with python.
|
# ? Jul 10, 2014 23:55 |
|
Soricidus posted:that's a sensible design used in many popular libraries, and how i'd do it in c as well. what else would you do? linked lists are a poor naive approach, and anything else is overcomplicated. there's nothing wrong with using an array it just hides a lot of details that are very relevant to you if you're taking a data structures/algo class it's like cheating
|
# ? Jul 11, 2014 00:02 |
|
USSMICHELLEBACHMAN posted:it's not that it's better in c it's just that if someone told me to make a stack in python i'd use an array what defines a data structure are its properties, not its implementation. a stack is a sequential container thing that you can push and pop. a queue has push and popleft. that's it, with a loop and this stuff you can already implement a bunch of graph search algorithms. I'm not saying that the low level pointer C stuff isn't important, it sure is, but it's something kind of independent from the theory.
|
# ? Jul 11, 2014 00:10 |
|
Symbolic Butt posted:what defines a data structure are its properties, not its implementation. a stack is a sequential container thing that you can push and pop. a queue has push and popleft. that's it, with a loop and this stuff you can already implement a bunch of graph search algorithms. wait til you tell him data structures also dont need mutability
|
# ? Jul 11, 2014 00:26 |
|
i was giving someone an interview question where i wanted them to implement a linked list where the forward pointer points two items ahead they decided to use C for it, which I thought was an interesting choice because up until then the interview had been about C#
|
# ? Jul 11, 2014 03:48 |
|
i thought maybe they would pull out some amazing C knowledge or something but no, they fell down at "insert a node" when i was able to take apart their implementation simply by repeatedly asking the questions "what if the list has four elements?" "what if the list has five elements?" "what if the list has four elements?" they constantly broke the other case when fixing it for the current question. i was pretty sad.
|
# ? Jul 11, 2014 03:49 |
|
let me tell you about going from python to C with classes (because nothing else from c++ fits in memory) on my arduino pointers to arrays of pointers to c-strings... the horror...
|
# ? Jul 11, 2014 03:55 |
|
im actually preferring c++ to python and im pretty sure that indicates deep mental illness from what ive read
|
# ? Jul 11, 2014 05:29 |
|
writing a skip list in C++ was fun
|
# ? Jul 11, 2014 06:25 |
|
sorry i meant use python over java/c# if you are learning this stuff on your own and you don't know java/c#. why not use a more readable lang if you're going to use a high level lang? sure java/c# are plenty readable but python is dang close to pseudocode. for learning you'll get less headaches with python i think. learning in c will give you a better understanding of how computer work but you need to learn c before you learn data structs + algos. learn you some pointers and you'll never be confused by why your java obj is getting mutated when it supposed to be a pass by value language!!! e: removed thing more suited to that other programming thread Blert the Duck fucked around with this message at 14:18 on Jul 11, 2014 |
# ? Jul 11, 2014 14:10 |
|
Soricidus posted:that's a sensible design used in many popular libraries, and how i'd do it in c as well. what else would you do? linked lists are a poor naive approach, and anything else is overcomplicated. how are linked lists a poor naive approach for a stack? they literally implement a stack almost trivially, and are the way stacks are generally written in functional PLs (and even python) Pie Colony fucked around with this message at 21:43 on Jul 11, 2014 |
# ? Jul 11, 2014 21:38 |
|
USSMICHELLEBACHMAN posted:it's not that it's better in c it's just that if someone told me to make a stack in python i'd use an array you realize that when people talk about space and time complexity (i'm assuming you mean complexity, not efficiency), they are not talking about individual bytes or seconds but how something performs relative to the input size, right? if by arrays you mean lists, pop() is defined (and even documented) to be an O(1) operation
|
# ? Jul 11, 2014 21:41 |
|
Pie Colony posted:how are linked lists a poor naive approach for a stack? they literally implement a stack almost trivially, and are the way stacks are generally written in functional PLs (and even python) in imperative pls though they're not so great. they have their place, java's linkedhashmap is a fine example, but if you're not adding/removing elements from the middle then vectors tend to be both faster and smaller, which is why java etc use them rather than linked lists for their stacks. in particular I don't think I've ever seen a use of a linked list in python where a regular built-in list (i.e. vector) would not have been a better choice. I'm sure such cases exist but they'll be very situational. Soricidus fucked around with this message at 22:01 on Jul 11, 2014 |
# ? Jul 11, 2014 21:59 |
|
if you're adding and removing elements from the middle then you're not using a stack. Linked lists are the best stack implementation regardless of the language you're working in, you don't get to just say "oh well idk how things are in ~fp land~" to dismiss the point Pie Colony made.
|
# ? Jul 11, 2014 22:08 |
|
FamDav posted:wait til you tell him data structures also dont need mutability :2bongs:
|
# ? Jul 11, 2014 22:17 |
|
AlsoD posted:if you're adding and removing elements from the middle then you're not using a stack. Linked lists are the best stack implementation regardless of the language you're working in, you don't get to just say "oh well idk how things are in ~fp land~" to dismiss the point Pie Colony made. my point, which you don't get to dismiss like that, is: if linked lists are the best stack implementation, why don't java, c++, etc. use them? hint: it's not because you're smarter than the experts who designed their libraries.
|
# ? Jul 11, 2014 22:45 |
|
isn't it because they're not making a pure linked list?
|
# ? Jul 11, 2014 22:50 |
|
Soricidus posted:I didn't say that. I have used fp languages and am familiar with the advantages of linked lists in that context. and I brought up doing poo poo in the middle of the list as an example of when linked lists are appropriate, ie not for stacks. what implementation is significantly better for a pure stack (ie one that only implements push and pop and is never accessed in the middle) than a linked list Arcsech fucked around with this message at 23:20 on Jul 11, 2014 |
# ? Jul 11, 2014 23:16 |
|
AlsoD posted:if you're adding and removing elements from the middle then you're not using a stack. Linked lists are the best stack implementation regardless of the language you're working in, you don't get to just say "oh well idk how things are in ~fp land~" to dismiss the point Pie Colony made. nah they dont have good cache locality
|
# ? Jul 11, 2014 23:21 |
|
Arcsech posted:what implementation is significantly better for a pure stack (ie one that only implements push and pop and is never accessed in the middle) than a linked list i dont think that making your stack implementation 'pure' is a goal when u make a programming language i'm just spitballing here but i'd imagine that there are a lot of things you can do to optimize basic data structures even if you don't expose those details to the user but i am a very bad programmer. possibly the worst
|
# ? Jul 11, 2014 23:26 |
|
Malcolm XML posted:nah they dont have good cache locality never mind that you have to carry around pointers with every data element which you don't have to do with a vector and a pointer to the top of said "stack" then you only have to worry about reallocating a vector if your stack grows too large same goes for queues if you can tolerate a hard cap on the number of items in the queue just loop over the spaces in the vector to save the pointers and keep cache locality on the items in your queue i mean, it's not like your call stack is implemented as a linked list
|
# ? Jul 11, 2014 23:30 |
|
USSMICHELLEBACHMAN posted:i dont think that making your stack implementation 'pure' is a goal when u make a programming language Oh yeah no by pure I meant that you only have to implement those two functions so it should allow you to do more under the hood optimization not less Although I did mean if you don't want to preallocate a shitload of memory for a stack that may be tiny or might be huge. As an embedded developer I'd implement a stack as an array because I have to manage all the memory super tightly anyway but if you're not on a $0.25 uC you tend to use different techniques
|
# ? Jul 11, 2014 23:40 |
|
ComradeCosmobot posted:never mind that you have to carry around pointers with every data element which you don't have to do with a vector and a pointer to the top of said "stack" it actually is though if you have frame pointers
|
# ? Jul 11, 2014 23:53 |
|
Arcsech posted:what implementation is significantly better for a pure stack (ie one that only implements push and pop and is never accessed in the middle) than a linked list are you loving serious. are you so loving clueless that you made this post gently caress
|
# ? Jul 11, 2014 23:56 |
|
Kevin Mitnick P.E. posted:are you loving serious. are you so loving clueless that you made this post as an interloper in the terrible programmer thread the impetus is on you to explain why someone might be a bad programmer and help them out a little in a nice way. this kind of posting is contrary to the spirit of the thread
|
# ? Jul 12, 2014 00:14 |
|
USSMICHELLEBACHMAN posted:as an interloper in the terrible programmer thread the impetus is on you to explain why someone might be a bad programmer and help them out a little in a nice way. this kind of posting is contrary to the spirit of the thread His emotionally-stunted baby is being raised by an iPad. lol
|
# ? Jul 12, 2014 00:16 |
|
why is tori here no one mentioned The City
|
# ? Jul 12, 2014 00:17 |
|
Forums Terrorist posted:why is tori here no one mentioned The City because this thread is the pitts
|
# ? Jul 12, 2014 00:18 |
|
Forums Terrorist posted:why is tori here no one mentioned The City I have to post in every thread. Thanks and god bless.
|
# ? Jul 12, 2014 00:25 |
|
Kevin Mitnick P.E. posted:it actually is though if you have frame pointers and also if your language uses split stacks
|
# ? Jul 12, 2014 00:27 |
|
huh. i got an email from an amazon recruiter wanting to schedule a phone interview for something I applied for a year and a half ago that I'm not very good at i don't really want to leave the state anymore but whatever let's see where it goes
|
# ? Jul 12, 2014 00:45 |
|
pseudorandom name posted:and also if your language uses split stacks
|
# ? Jul 12, 2014 00:47 |
|
|
# ? May 13, 2024 05:23 |
|
Luigi Thirty posted:huh. i got an email from an amazon recruiter wanting to schedule a phone interview for something I applied for a year and a half ago that I'm not very good at you probably don't want to go to amazon anyways
|
# ? Jul 12, 2014 01:15 |