/r/computerscience
The hot spot for CS on reddit.
Welcome to /r/ComputerScience!
We're glad you're here.
This subreddit is dedicated to discussion of Computer Science topics including algorithms, computation, theory of languages, theory of programming, some software engineering, AI, cryptography, information theory, and computer architecture.
For more detailed descriptions of these rules, please visit the rules page
/r/computerscience
I'm learning how to use hashmaps. From what I can tell, they're just a disorganized version of an array. What I don't understand is how it's physically possible to search through it in O(1) time complexity. I would expect something like this to be at least O(log n) time, which is what it would be if you binary-searched a sorted array with the hashes. How is it possible to find out if an item exists, let alone how many times it occurs, in any sort of list in consistent time regardless of the list's size?
I will go first, mine is the observer pattern, it is very intuitive and relatable the use cases are obvious.
Use case- If a state of a particular object should get updated, other states that are dependent on it should be updated too.
I am adding wind to my simulation and I dont want to compute brownian motion for each particle so how can I simulate it accuratelishly.
Source --- Scott (who, besides LCF, invented denotational semantics) knew Kleene IRL so he probably knows how to pronounce his name. This is the most egregious mathematician/computer scientist name mispronunciation. Just trailing behind calling Gödel "Gerr-del" and the third one being calling Kernighan "KerniGAN" (it's KerniHAN --- he's not a real mathematician or computer scientist anyways, more of a compsci communicator). If you got more stuff like these, please do tell, I'm looking towards being a more fun guy at the parties I throw with my dollies.
I wanted to know is there an app or a site that could helps stay apace with technology. I use to work in the industry but no longer. That being said I’d like to revitalize that passion and am looking for something akin to Duolingo if it even exist that will have me engaged so I can learn better. Or if that doesn’t exist literature Is fine as well, I’d appreciate any recommendations at the end of the day. Something that talks about hardware components like ram as well as software. And I apologize if this is worded oddly. For some reason the mobile app told me I was violating the sub before finishing two sentences and I had to rephrase everything.
Hi,
I have 16 bits that contain data encoded in Binary Scaling.
The format is "B-4.19"
What are the steps to convert this to a floating point variable?
Happy New Year,
V/r
No matter how hard I tried I can’t get my head around proving a function is Big O of anything. For instance I don’t get where they’re getting G of X from I just get anything at all. Can someone please explain to me and dumb it down as much as possible
An example question would be prove 5n + 3 is O(N) it would be appreciated if you could explain step by step using examples
I read through many articles and watched many youtube videos about C++ problems, many of them complained about this language by had comparision with Rust. People complained more about memory safety, error messages and run time errors.
As my understanding i also faced errors at runtime not in compile time while learning c++ and also those criticism(memory safety, error messages and run time errors) about c++ is compilers or the language itself don't throw proper errors/error messages at compile time.
My Questions are,
Is the compile time errors are the answer for all the mentioned criticism about c++?.
Can C++ developers make compilers throws errors at compile time? or is it really has any problems in the compilers or ISO standards?. I don't really understand this.
I am eager to wait to read all of your opinions about this.
Here:
They claim the only base case of Merge Sort is for an empty array, but I'm pretty sure if i = 1 and j = 2, then m = 1 and we have i=1, m=1 which will be empty array so ok but m=1, j=2 will be array of size 1 again, and it's infinite?
I am trying to wrap my head around cycles in graph. The book CLRS states that a graph cannot even contain positive weight cycles. (Negative weight cycles were already ruled out).
Pg 646 under heading Cycles:
Can a shortest path contain a cycle? As we have just seen, it cannot contain a weight cycle. Nor can it contain a positive-weight cycle, since removing the cycle from the path produces a path with the same source and destination and a lower path weigh.
But then the book purposely include examples that contain cycles! In the case of Bellman-Ford, the book clearly indicates that the graph contains a cycle. So that's fine. But for Dijkstra, I can clearly see a cycle forming in Figure 24.6 on page 659. The cycles forms among s -> y -> z -> s vertices. It's forming a +ve weight cycle. Yet it does, seemingly, calculate correct shortest-distance between vertices.
Did I miss something?
Can a positive weight cycle exist in a graph when computing correct shortest-distance from vertex 'u' to 'v'?
Here in Illinois, my wife and I enjoy participating in the 2024 Library Crawl, traveling across the state to explore different libraries and discover new books. However, I often struggle to find up-to-date Computer Science or Programming books that are relevant to my work.
I’d love to compile a list of the best books on programming and computer architecture to recommend to my local public library. Do you have any suggestions?
In Lecture 5 of MIT's 6.006 Introduction to Algorithms, Professor Ku answers a question as to why the build operation of a hash table (using chaining) is worst case expected linear. Paraphrased as follows:
"Why [do we refer to hash table build operation complexity as] 'expected'? When we build the table, each insert operation requires looking up the key, and if the hashed index is already in use, looking down the chain of elements stored at that index. If I happen to know that all my keys are unique in my input, then I do not need to perform the check and I can get worse case linear [expected] [build] time."
I'm not sure I understand what the 'unexpected' worst case would be. I imagine it is when a check is performed for each insert (e.g., all items stored at the same hashed index). I suppose then the worst case 'unexpected' for n items would be n multiplied by the complexity factor of the 'find' method for the data structure at each index? For example, if the chain structure is a linked list (with find complexity of Theta(n)), the worst case 'unexpected' build time would be Omega(n^2)?
Similarly, I guess that the worst case 'unexpected' find time for a hash table with chaining is simply the worst case find time for the data structure used for chaining?
See the image below for how the course is presenting complexity:
In particular, this question is about the use of (e) (meaning 'expected') for the build operation complexity of a hash table. The course has a lot of special notation and conceptual models, so LMK if anything needs clarification to be answered meaningfully.
I am implementing a complex algorithm. I spend most of the time, or a least a good part of it, fixing bugs. The bugs that take a lot of time are not the kind of bugs where there is some error from the interpreter - those kind of bugs can be quickly fixed because you understand the cause quickly. But the most time consuming bugs to fix are where there is a lot of executed operations, and the program simply give the wrong result at the end. And then you have to narrow it down with setting breakpoints etc. to get to the cause.
How to spend less time fixing those bugs? I don't necessarily mean how to fix them faster but also how to make less bugs like that.
Does anyone have some fancy tips?
Sorry if this doesn't follow rules, I'll remove it if needed. I want to implement an algorithm but i have no idea if it has a name i can call it by (It probably does though, since it is very simple). I want to generate a list of all combinations of n numbers from 1 to x in a particular order. I start with n number variables each assigned their respective default value from 1 to n. Then the algorithm follows 2 rules. starting from the smallest variable, if a variable can increase by 1 without being equal to the next smallest variable or being greater than x, then it does so and all variables smaller than the one being increased is reset to default values, and the algorithm loops. Otherwise, the next smallest variable is asked the same question. if no variable can be increased, then the algorithm ends. What is this called?
Hi! I was wondering if theres any Theoretical Computer Science REU/Summer Research Programs that I could apply to? I've found very few and one of the deadlines already passed :( (I've applied to EPFL, missed ETH Zurich, have CAAR , OSU, ISTA, and DIMACS on my list)
I watched it as a kid in the early 2000’s and rewatched it last night. I know a little bit about computer science but by no means a ton, especially what it was like in the 80’s.
I know movies are not the place to look for sound reason, but the most unbelievable part to me was: this kid who is obviously very knowledgeable of computers and tech in general doesn’t know about back doors?
Is this just movies being movies or we’re back doors not common in the 80’s? Maybe only for people writing programs and such?
where
A = light edges forming the minimum-spanning tree
v is vertice
v.pi is vertice's parent
V is all the vertex.
r (I don't know what this is)
This is from the CLRS book page 634. Why do I want to know this equation? Because I am trying to print the minimum spanning but I can't get the minimum distance. I can visually see that it's not minimum distance.
Any help is appreciated.
This is not a homework. I am a grown man with 7-8 years of professional experience as a Software Engineer. I am just curious.
edit: problem solved. I did indeed misunderstood the what MSTs are. I basically misunderstood the purpose of MSTs. But now I have it right and I luckily stumbled upon it when looking something else:
The Minimum Spanning Tree algorithm is used in weighed networks to find the shortest, most efficient way to connect all
the nodes in a graph: it finds the minimum set of edges that connects all the nodes, without creating any loops or cycles.
Looking to get my grandfather a book that explains VERY basic computer / software concepts.
The text of the book should be large-ish. Does anyone have any recommendations? He wont be coding or anything like that, this is just for a curiosity read
Hi,
I've been interested in distributed computing.
I was looking at signed code which can ensure the identity of the software's author, publish and the code hasn't been altered.
My understanding is signed code ensures that the code you are getting is correct.
Can you ensure that the code you ran is correct?
Is there some way to ensure through maybe some type cryptology to ensure that the output of code is from the code mentioned?
Thanks!
Hi everyone!
I’m a CS graduate from Germany, and I’m curious about how you all stay on top of the ever-changing tech landscape. What resources, news sites, or methods do you use to keep up with current trends, breakthroughs, and innovations in the tech/IT/computer science industry?
Do you have favorite websites, newsletters, YouTube channels, podcasts, or even communities that you recommend? I’d love to hear how you stay informed and inspired!
Thanks in advance for sharing your tips!
I'm trying to optimize the following kernel variables, to favor latency without compromising throughput too much, on a system with an M.2:
- vm.dirty_writeback_centisecs
- vm.dirty_expire_centisecs
- vm.dirty_background_ratio
- vm.dirty_ratio
- vm.vfs_cache_pressure
- ext4 commit frequency
The problem is that each time I run various performance measurement tools I get extremely different results, the variability is huge.
I tried to somehow reduce extreme measurements by using the statistic function "trimean", which does exactly that. But even then every measurement is relatively different.
A recent breakthrough by Hugging Face whereby scaling test-time compute via Llama 3b and an 8b supervisory reward model with 256 iterations outperforms Llama 70b in one try on maths.
Chagpt estimates however that this approach takes 2x the compute as 70b one try.
If that's so what's the advantage?
I see people wanting to apply the same approach to the 70b model for well above SOTA breakthroughs, but that would make it 256 times more computationally expensive, and I'm doubtful the gains would be 256x improvements from current SOTA. Would you feel able to estimate a ceiling in performance gains for the 70b model in this approach?
I don't know if this is the right sub to ask this, but if someone has knowledge of Theory of Computation and Finite Automata could they kindly clarify what do + and - notations here represent? An intuitive guess is that they are initial and final states but I still want to be sure about it.
A little background. I had a fine career in journalism a few years ago. I was an editor and had a good network. However, the business got tougher and tougher with fewer and fewer jobs and less pay. Just a fact of the industry. Last year I chose to go back to school. There are, in my country, many smaller computer science degrees that teach you the basics. While they have historically been great, I felt the field had become more comptetive and I had to take a more fundamental software engineering course. Another reason is I suffer from a debilitating chronic illness and can't see mysef in the stressfull envirenment journalism is and if I need to compete with able body people, I need to get my shit together.
I am now 36 and have learned a lot, but also gotten a lot of bad habits. One really stood in the way of my success in CS.
I had learned to "jump in puddles". Long time in radio made me quick to learn something on a shallow level, conduct and interview, write a script and then SOUND like I knew what I was talking about.
This made me feel I could learn quickly, but I didn't. I learned to sound like I knew what I was talking about.
I have just studied for statstics, spend countless hours on it and I am honestly not sure if I have passed. But looking back I realized that instead of jumping into an ocean I tried to learn by jumping in puddles. Getting a shallow knowledge of everything and then move on. However, in this field you need firm knowledge of certain areas before puddle jumping. I realize that if I had really focused on the subjects and gone in depth with them and then moved on I would have done so much better. In statistics a lot follow the exact same pattern and if I had just gotten really good at step one before moving on to step two, this would have been such a different experience.
At this point I feel that I finally learned the lesson and I hope this reasonates with others struggling. Sometimes it is not about learning, but delearning.
Hi everyone
I am looking for topics for my computer science research. As for my interest in linguistics, I am thinking about applying NLP to a new language. However, All I have done so far is to fine-tune pretrained model for specific tasks. I'm not experienced much with making a tokenizer or a language model for a new language from scratch.
One of my questions so far is how do tokenizers, lemmatizers and translators deal with highly inflectional, morphologically rich languages like German, Greek, Latin, etc.
Can anyone give me an insight or any resources on such tasks on a new language?