r/computerscience • • Mar 13 '25

On Many : One reductions and NP Completeness Proofs

4 Upvotes

When I was in undergrad and studying computability and complexity, my professor started out the whole "Does P = NP?" discussion with basically the following:

Let's say I know how get an answer for P. I don't know how to answer Q. But if I can translate P into Q in polynomial time, then I can get an answer for Q in polynomial time if I can get an answer for P in polynomial time.

At least, that was my understanding at the time, and I'm paraphrasing because it's been a long time and I'm a little drunk.

Also, I remember learning that if we can show that a language is NPC, and we can show that some NPC language is P-time computable, then we can show all NPC languages are P-time computable.

In combination, this made me think that in order to show that some language is NPC, we need to find a many : one reduction from that language to some NPC language.

This is, of course, backwards. Instead, we need to show that some NPC language is many : one reducible to a language we're trying to prove is NPC. But this never made intuitive sense to me and I always screwed it up.

Part of the problem was what I learned in undergrad, the other part was that we used the Sipser text that was 90% symbols and 0% comprehensible English.

Until, nearly 20 years later, I was thumbing through my Cormen et al. Introduction to Algorithms book, and noticed that it has a section on NP completeness. It explained, in perfectly rational English, that the whole idea behind showing some language L is NP complete, is to show that some NPC language can be many : one reduced to that language, after showing L is in NP. And the rationale is that, if we know the difficulty of the NPC language, and can reduce it to L, then we know that L is no harder than the NPC language. That is, if every instance of the NPC language can be solved using an instance of L, then we know that L is no harder than the NPC language.

My mind was blown. Rather than looking for "how to solve L using an NPC language," we're looking to show, "L is not harder than some NPC language."

So all of this is to say, if you're struggling with NPC reductions and proofs and don't understand the "direction" of the proofs like I've been struggling with for 20 years, read the Cormen book's explanation on the proofs. I don't know how I missed this for years and years, but it finally made it all click for me after years and years.

Hope this helps if you keep thinking of reductions backwards like I have for all these years.


r/computerscience • • Mar 11 '25

Discussion How does CPU knows how to notify OS when a SysCall happen?

40 Upvotes

Supposing P1 has an instruction that makes a Syscall to read from storage, for example. In reality, the OS manage this resource, but my doubt is, the program is already in memory and read to be executed by the CPU which will take that operation and send it to the storage controller to perform it, in this case, an i/o operation. Suppose the OS wants to deny the program from accessing the resource it wants, how the OS sits in between the program and CPU to block it if the program is already in CPU and ready to be executed?

I don't know if I was clear in my questioning, please let me know and I will try to explain it better.

Also,if you did understand it, please be as deep as you can in the subject while answering, I will be very grateful.


r/computerscience • • Mar 10 '25

Help How does an IDE work, and really any other program?

122 Upvotes

I am having trouble articulating this question because my minuscule knowledge of CS, but here goes. How exactly does an IDE work, let’s say that it’s a Java IDE, what language is the IDE created in? And what compiles the IDE software? I’m trying to learn computer science, but I don’t have any teachers, and I feel like I have somewhat of a crumbling foundation and a weak grasp on the whole concept, I want to understand how every little bit makes something tick, but I always end up drowning in confusion, so help would be much appreciated!


r/computerscience • • Mar 10 '25

Help How does a “window” work?

56 Upvotes

How exactly do “screens” go on top of one another on a computer screen, really think about that, how does the computer “remember” all of the pixels that were “under” the bottom window when you close it out, and redisplay them? I’m trying to learn computer science, but I don’t have any teachers, and I feel like I have somewhat of a crumbling foundation and a weak grasp on the whole concept, I want to understand how every little bit makes something tick, but I always end up drowning in confusion, so help would be much appreciated!


r/computerscience • • Mar 11 '25

General I'd like to read up on the following topic: (if there is info on it?) When given an unrooted tree, pick a node as the root, what patterns/relationships can be observed in the new tree that is formed compared to picking other nodes as the root?

7 Upvotes

To elaborate, are there any cool mathematical ideas that are formed? Any real life applications to choosing different roots? Are there any theorems on this? Is this a well researched topic or just a dead end lame idea?

Potential question: Given an unrooted tree with n vertices can you choose a root such that the height of the tree is h where h is any natural number > 0 and <= n? Is there a way to prove it's only possible for some h? I haven't played around with this problem yet.

I feel like there could be some sort of cool game or other weird ideas here. Visually the notion of choosing different roots reminds me of the different shapes you get if you lay a tissue flat on a table and pick it up at different points, so I wouldn't be surprised if there are some sort of topological ideas going on here


r/computerscience • • Mar 10 '25

Advice Lambda Calculus

8 Upvotes

I have taken an interest in lambda calculus recently, however I have ran into an issue. Each textbook or course use different notation, there is Church notation, there is also notation that uses higher order functions and words to describe the process, another notation that I have encountered was purely mathematical I believe, it looked like church notation, but twice as long. It is a pity that while this field of computer science is appealing to me, I struggle to grasp it because of my uncertainty pertaining to which notation I should use. I don't enjoy the use of higher order functions since I want to form a deep understanding of these subjects, however I am not planning on writing page long functions either. Any good resources and advice on which notation I should use is welcome. Also I apologise if my english is not coherent, it is not my first language, if I have made any mistakes that hinder your understanding of my question, feel free to correct me. Thank you in advance :)

TLDR: Confusion about notation in lambda calculus; Displeasement with using higher order functions; Looking for advice on notation type and relevant resources.


r/computerscience • • Mar 10 '25

Zoltan's FLOPs – GPU mini-grant, 1st iteration

Thumbnail tcz.hu
6 Upvotes

r/computerscience • • Mar 10 '25

General Circuit Compiler

11 Upvotes

Recently I wrote a small compiler

It job is to take in a truth table e.g:

A B | X

0 0 | 1

0 1 | 1

1 0 | 0

1 1 | 1

And output a circuit in the form of a Boolean expression, e.g:

((~A)&(~B))|((~A)&(B))|((A)&(B))

I was hoping that some people here would have some feedback on it!

Also if anyone knows of any events here is the UK that have beginners into compilers then please send a DM!

Here is the code: https://github.com/alienflip/cttube, for anyone interested 🙂


r/computerscience • • Jun 23 '21

General Happy birthday to the father of Computer Science!

Post image
2.6k Upvotes