Earlier quoted context omitted.
They're the sort of thing I use on a daily^H^H^H^H^Hfrequent basis. The questions are not asking trivia questions or looking for knowledge, they're asking questions whose answers can be figured out.
How do you "figure out" what a B-tree is? That's a trivia question.
The software development final exam: Algorithms and Data Structures
191–200 of 208 posts
Re: The software development final exam: Algorithms and Data Structures
#192Earlier quoted context omitted.
How do you "figure out" what a B-tree is? That's a trivia question.
My school didn't teach B-trees, though they did teach 2-4 trees. I've never really been in a situation where I've needed to use a B-tree; and, I was an accomplished competition programmer in college. That said, I looked up on the internet what they were and it was pretty easy to follow.
Re: The software development final exam: Algorithms and Data Structures
#193Earlier quoted context omitted.
That's a great textbook summary, now for applications: You got an array of your friends, an array of people who upvoted this post and an array of people who replied to this post. Filter all your friends who upvoted and replied to this post. Now, before you write the code, how fast/slow will it run? for 1,000 friends? 1,000,000? will the runtime grow extremely fast? why? Here's a Redis command that intersects two keys…
I'll give this a shot. The code I would write would take longer the more friends you have. Basically, it would grow linearly with the size of all the sets and the number of intersections found. Something like O(n * M) in the worst case. But I don't get why later you say that n is the size of the smallest set. So I don't see how you can beat that. I guess you could sort the lists, but that take O(n log n) over M lists…
For each element in all sets: Insert element into hash table. If it does not exist, use key = element, value = 1. If it exists, increment counter. This is O(1)
When done over all sets, it's O(N)
Walk hash table, the only elements that are in the intersection are those with value = number of sets. This is O(N)
O(N) + O(N) = O(N). This only works if there are no duplicates within a single set. It transforms set intersection into a counting problem over the universe of elements.
You can optimize it as well. You never need to deal with elements that don't exist in the hash table after the first set is processed, as they can never be in the intersection. This does not change the asymptotic complexity, except it means the hashtable will never resize after the first set. So it's advantageous to choose the smallest set to process first if you can do so easily. If you use dynamic perfect hashing or something similar, you can also guarantee all operations after the first set will be O(1), rather than amortized O(1).
Re: The software development final exam: Algorithms and Data Structures
#194Earlier quoted context omitted.
I'll give this a shot. The code I would write would take longer the more friends you have. Basically, it would grow linearly with the size of all the sets and the number of intersections found. Something like O(n * M) in the worst case. But I don't get why later you say that n is the size of the smallest set. So I don't see how you can beat that. I guess you could sort the lists, but that take O(n log n) over M lists…
With extra memory, and if you don't care about ordering, multiple set intersection can be made O(N) where N = size of each set added together, assuming no duplicates in any single set (which should be true, but it depends on how loosely you are using the word set) You only have to walk each element exactly once, and all other operations are (amortized) O(1) For each element in all sets: Insert element into hash table…
Re: The software development final exam: Algorithms and Data Structures
#195I have a CS degree from a respectable CS department. I got straight A's in my major and never crammed for a CS test. I am sure I could have answered these questions in 1997. Today, I can answer the first two questions. I think I can get partial credit on the third. I believe I knew the fourth once. I don't even remember what bipartite means [see edit below]. And that's with having implemented a topological sort withi…
Frankly, asking the question either way is what I would call prejudicial. What is a scenario in which bipartite graphs occur, and why not ask how that would be dealt with?
Re: The software development final exam: Algorithms and Data Structures
#196Earlier quoted context omitted.
My school didn't teach B-trees, though they did teach 2-4 trees. I've never really been in a situation where I've needed to use a B-tree; and, I was an accomplished competition programmer in college. That said, I looked up on the internet what they were and it was pretty easy to follow.
It would be very cool if there was a programming contest problem that required efficient disk access.
Re: The software development final exam: Algorithms and Data Structures
#197Earlier quoted context omitted.
I'll give this a shot. The code I would write would take longer the more friends you have. Basically, it would grow linearly with the size of all the sets and the number of intersections found. Something like O(n * M) in the worst case. But I don't get why later you say that n is the size of the smallest set. So I don't see how you can beat that. I guess you could sort the lists, but that take O(n log n) over M lists…
With extra memory, and if you don't care about ordering, multiple set intersection can be made O(N) where N = size of each set added together, assuming no duplicates in any single set (which should be true, but it depends on how loosely you are using the word set) You only have to walk each element exactly once, and all other operations are (amortized) O(1) For each element in all sets: Insert element into hash table…
As a side note, I think that tasks like "implement a data structure with following operations and calculate computational complexity for each operation" are much better for exam than trivia questions like "Name the heap operations used by heapsort and the asymptotic running time of each.", with all due respect to @cperciva.
Re: The software development final exam: Algorithms and Data Structures
#198Earlier quoted context omitted.
> Call me a snob if you will, but I don't want to work with mediocre programmers > I want people with passion for our field, and those people can't avoid gaining the kind of knowledge that Colin's test asks about. Claiming to own the definition of passion is not snobbish but conceited. Perhaps I consider programmers mediocre if they lack design experience and cannot show me how to setup custom guides in illustrator.…
Your post is largely a straw man and contains snark that certainly does not raise the level of this conversation. I'm talking about passion for programming . I'm not "claiming to own the definition of passion," I'm saying that passion for programming manifests in knowing the answers to questions like Colin's. It simply does.
Calling people that don't agree with you mediocre or apologists of mediocrity is just rude.
Re: The software development final exam: Algorithms and Data Structures
#199Earlier quoted context omitted.
I really wish the OP had linked to the explanation for the exams: http://www.daemonology.net/blog/2012-10-08-software-developm... The author believes this test is very basic, and to follow your auto mechanic metaphor it would be like asking anyone from a Midas Muffler employee to Kiichiro Toyoda the difference between disc and drum brakes. (Not that I agree with the author - to me, "basic knowledge" would be "What is…
I really wish the OP had linked to the explanation for the exams I did...
Your explanation is linked in the top of the test, but based on many of the comments here I don't think many people read it. It helped me put the test into perspective.
Re: The software development final exam: Algorithms and Data Structures
#200Earlier quoted context omitted.
Frankly, asking the question either way is what I would call prejudicial. What is a scenario in which bipartite graphs occur, and why not ask how that would be dealt with?
Any n-dimensional grid (sometimes called a "Manhattan space") is a bipartite graph. You may find it useful that no odd-length cycles can exist in such a graph.