/r/computerscience

Photograph via snooOG

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.

Rules

  1. Content must be on-topic
  2. Be civil
  3. No career, major, or courses advice
  4. No advertising
  5. No joke submissions
  6. No laptop/desktop purchase advice
  7. No tech/programming support
  8. No homework, exams, projects etc.
  9. No asking for ideas

For more detailed descriptions of these rules, please visit the rules page

Related subreddits

Credits

  • Header image is found here.
  • Subreddit logo is under an open source license from lessonhacker.com, found here

NIGHT MODE NORMAL

/r/computerscience

419,272 Subscribers

1

In your perspective, what do you think we should put in a Letter of motivation/personal statement?

I mean, I mean, they ask you to talk about why are you interested in certain area or what do you spect to accomplish there... But my opinion is that it should show more of your personality and of your character. I wish someone could give me some advice about successful letters of motivation:(

1 Comment
2024/12/01
22:43 UTC

8

What are currently the hot topics in computer science research?

Question

7 Comments
2024/12/01
21:29 UTC

4

Computer Science GCSE student here

Exclaimer: This is not in a way me asking for advice about something to do with my course. I'm curious about something I did due to something my CS teacher said.

During one of my CS lessons, we were covering Binary search again (due to it being a weak spot in our exams) & my teacher jokingly said "For the coders In this room, I wonder if any of you will be able to code Binary Search in Python.". She then immediately retracted this statement because of how difficult it apparently is. I took this as a challenge & immediately jumped to coding it in between tasks. I finished it just as we were wrapping up the lesson & well, it worked perfectly. My teacher told me how she was impressed by me & that 'Coding Binary Search is a university level skill'.

Basically what I'm wondering is if coding Binary Search is actually that difficult. Python was the coding language I used.

13 Comments
2024/12/01
16:37 UTC

6

Need Help with Banker’s Algorithm: Minimal Resources for a Safe State

Hi everyone,

I’m working on a problem involving the Banker’s Algorithm, and I’m stuck on determining the smallest value of x for which the system is in a safe state. Here’s the problem setup:

Problem Description:

The system has 4 processes and 5 allocatable resources. The current allocation, maximum needs, and available resources are as follows:

ProcessAllocationMaxAvailable
P01 0 2 1 11 2 1 3 0 0 x 1 2
P12 0 1 1 02 2 1 0
P21 1 0 1 02 1 3 1 0
P31 1 1 1 01 2 2 2 1

Objective:

What is the smallest value of x such that this is a safe state?

Hints provided:

  1. Compute the "needs matrix" (Need=Max−Allocation).
  2. Identify the process that can complete first if x is sufficiently large.

I’ve calculated the needs matrix and tried different values for x, but I’m not entirely sure how to proceed with finding the exact smallest x that ensures the system remains in a safe state. I’d appreciate if someone could guide me through the steps or point me to resources that explain this process in detail.

Thanks in advance for your help!

What I’ve Tried So Far:

  • Calculated the needs matrix:
    • Need[i][j]=Max[i][j]-Allocation[i][j],
      • where i represents the process number, j represents the resource type. The Max matrix indicates the maximum demand of each resource for each process. The Allocation matrix indicates the resources currently allocated to each process.
    • For each process Pᵢ and each resource Rⱼ, subtract the allocated resources from the maximum demand:  
      • Need ᵢⱼ=Max ᵢⱼ−Allocation ᵢⱼ 

ProcessAllocation (A)Max (M)Need (M - A)
P0[1,0,2,1,1][1,1,2,1,3][0,1,0,0,2]
P1​[2,0,1,1,0][2,2,2,1,0][0,2,1,0,0]
P2​[1,1,0,1,0][2,1,3,1,0][1,0,3,0,0]
P3​[1,1,1,1,0][1,1,2,2,1][0,0,1,1,1]

Now, given the availability vector, we know that R₁=0, R₂=0, R₄=1, R₆=2 are fixed, but we want to determine R₃.

A process can execute if its resource requirements (from the Needs Matrix) are less than or equal to the resources currently available. For each process Pᵢ, we check if:  

Need[i][j] ≤ Available [j] ∀j   

Where:

− Need[i][j] is the need of process Pᵢ for resource Rⱼ.

− Available [j] is the current availability of resource Rⱼ.

If Need(P₀)=[0,1,0,0,2], then:

- For R₁: 0 ≤ 0 (satisfied)

- For R₂: 1 ≤ 0 (not satisfied, so P₀ cannot run yet),

- For R₃: 0 ≤ x (always satisfied because 0 ≤ x for any x ),

- For R₄: 0 ≤ 1 (satisfied),

- For R₅: 2 ≤ 2 (satisfied).

Since all conditions are not satisfied, do we state that P₀ cannot run? Do we repeat this calculation process for the other P's? But I am not sure how we get to the point of determining the smallest x.

Any help is appreciated!

1 Comment
2024/12/01
05:53 UTC

6

Resources for learning some new things?

I'm not interested in programming or business related readings. I'm looking for something to learn and read while I'm eating lunch or relaxing in bed.

Theory, discoveries, and research are all things I'd like to learn about. Just nothing that requires me to program to see results

6 Comments
2024/11/30
23:02 UTC

7

Looking for books/courses on interpreters/compilers

Hello,
I'm looking for a book or a course that teaches interpreters and/or compilers. So far, I have tried two books: Crafting Interpreters by Robert Nystrom and Writing an Interpreter in Go by Thorsten Ball.

The issue I have with the former is that it focuses too much on software design. The Visitor design pattern, which the author introduced in the parsing chapter, made me drop the book. I spent a few days trying to understand how everything worked but eventually got frustrated and started looking for other resources.

The issue with the latter is a lack of theory. Additionally, I believe the author didn't use the simplest parsing algorithm.

I dropped both books when I reached the parsing chapters, so I'd like something that explains parsers really well and uses simple code for implementation, without any fancy design patterns. Ideally, it would use the simplest parsing strategy, which I believe is top-down recursive descent.

To sum up, I want a book or course that guides me through the implementation of an interpreter/compiler and explains everything clearly, using the simplest possible implementation in code.

A friend of mine mentioned this course: Pikuma - Create a Programming Language & Compiler. Are any of you familiar with this course? Would you recommend it?

6 Comments
2024/11/30
19:09 UTC

46

Abstraction and Hierarchy in CS Learning

I’m struggling to adapt to the way abstraction is presented in computer science. It often feels like I’m expected to accept concepts without fully understanding their foundations. When I try to dive deeper into the “why” behind these abstractions, I realize how much foundational knowledge I lack. This leads to excessive research and falling behind in school.

Coming from a math background, this approach feels unnatural. Mathematics starts with axioms and builds an interconnected framework where everything can be traced back to its core principles. I understand that computer science isn’t mathematics, but I find myself wanting to deeply understand the theoretical and technical details behind decisions in CS, not just focus on practical applications.

I want to know your thoughts , if someone ever felt the same and how should I approach this with better mindset.

——— Edit:

I want to thank everyone for the thoughtful advice and insights shared here. Your responses have helped me rethink my mindset and approach to learning computer science.

What a truly beautiful community! I may not be able to thank each of you individually, but I deeply appreciate the guidance you’ve offered.

36 Comments
2024/11/30
13:35 UTC

6

Is there any way or any library to find the top researchers in a specific field of computer science?

I have searched for it quite a bit but havent found anything useful. For example i want to find the top researchers in machine learning, or in theoretical cryptography (they could be ranked by something simple like their citations).

10 Comments
2024/11/29
21:56 UTC

0

What's the difference between volumes, partitions, and containers?

I recently installed Veracrypt (an encryption program) and have been introduced to some file system terms such as volume, partition, and container. From what I understand, a volume is a logical storage area that may or may not be directly tied to a physical drive, a partition is a logical subdivision/region of a drive, and I have no idea what a container is. I also don't quite understand the difference between a volume and a partition, as both seem to be logical areas of storage. Any help would be much appreciated.

5 Comments
2024/11/29
13:00 UTC

1

Proof of the Fundamental Theorem of Algebra in a formalization system I am developing

∀p(z)(Polynomial(p(z)) ∧ deg(p(z)) > 0 → (∃c∈ℂ(Root(p(z), c)) ∧ ∀k(1 ≤ k ≤ deg(p(z)) → ∃c∈ℂ(RootMultiplicity(p(z), c, k)) ∧ TotalRoots(p(z)) = deg(p(z)))))

(Assume ¬∃c∈ℂ(Root(p(z), c))) → (∀z(∃s(|z| > s → |p(z)| > 2|p₀|)) ∧ ∃t(|p(t)| = min(|p(z)|, |z| ≤ s))) ∧ (Define q(z) = p(z + t)) ∧ (q(0) = q₀ = |p(t)|) ∧ (q(z) = q₀ + qₘzᵐ + ∑_{k>m} qₖzᵏ) ∧ (∃r(Choose z = r(-q₀/qₘ)^(1/m))) ∧ (q(z) = q₀ - q₀rᵐ + ∑_{k>m} qₖzᵏ) ∧ (|q(z)| < |q₀| due to geometric decay of ∑_{k>m} qₖzᵏ) ∧ (Contradiction |q(0)| = min(|q(z)|)) → ¬(¬∃c∈ℂ(Root(p(z), c))) → ∃c∈ℂ(Root(p(z), c)).

(∃c∈ℂ(Root(p(z), c))) → (∀p(z)(p(z) = (z - c)q(z) ∧ deg(q(z)) = deg(p(z)) - 1)) → (∀n(Induction(n ≥ 1 ∧ deg(p(z)) = n → p(z) has exactly n roots counting multiplicities))) → ∀p(z)(deg(p(z)) = n → TotalRoots(p(z)) = n).

13 Comments
2024/11/29
07:29 UTC

149

How is it possible for one person to create a complex system like Bitcoin?

I’ve always wondered how it was possible for Satoshi Nakamoto, the creator of Bitcoin, to develop such a complex system like Bitcoin on their own.

Bitcoin involves a combination of cryptography, distributed systems, economic incentives, peer-to-peer networking, consensus algorithms (like Proof of Work), and blockchain technology—not to mention advanced topics like hashing, digital signatures, and public-key cryptography. Given how intricate the system is, how could one individual be responsible for designing and implementing all of these different components?

I have a background in computer science and I’m an experienced developer, but I find the learning curve of understanding blockchain and Bitcoin's design to be quite complex. The ideas of decentralization, immutability, and the creation of a secure, distributed ledger are concepts I find fascinating, but also hard to wrap my head around when it comes to implementation. Was Satoshi working alone from the start, or were there contributions from others along the way? What prior knowledge and skills would one person need to be able to pull something like this off?

I’d appreciate any insights from those with deeper experience in the space, particularly in areas like cryptographic techniques, distributed consensus, and economic models behind cryptocurrencies.

Thanks!

101 Comments
2024/11/28
18:30 UTC

4

Does firewall blocks all packets OR blocks only the TCP connection from forming? Given that HTTP is bidirectional, why is there outbound setting and inbound setting?

4 Comments
2024/11/28
04:13 UTC

1

A thought on P = NP notion...

So today in my Theory of Computation class we were discussing P and NP problems. Our proff told us that "Is P=NP ?" a big question in computer science. Then we discussed the formal definitions for both (the one that says for NP there exists a verification algo which can verify a possible answer in polynomial time...). He said that there are many great computer scientists of our generation who belive that P = NP. He gave some philosophical notions also which argue that P should be equal to NP. During this disccusion I thought of a scenario in my mind which goes as below:

Let's say I am in an interview and I need to solve a problem. I give a solution which solves the problem in exponential time but the interviewer asks me to solve it in polynomial time. So I derive a solution which, when provided a possible answer to the problem, can VERIFY if it is right or wrong in polynomial time. So if P = NP then this should work and I should get the job (given that this problems is the only criteria).

Ofcourse in real life this sceniario is pretty trivial because ofcourse the interviewer will not accpet this and I will be reject.

So I just wanted to here thoughts of the community on this. My apologize if there is a blunder in my understandig of the concept :))

5 Comments
2024/11/26
17:02 UTC

15

A doubt about blockchain technology use in our day to day lives

hey everyone, So I was doing this course on blockchain from youtube (Mainly for a research paper) and was just wondering.....If blockchain is decentralized, has these smart contracts and so many other benefits in transactions, why isn't it fully implemented yet?? I'm kinda confused abt this and no one seems to be pointing out the cons or drawbacks of blockchain

76 Comments
2024/11/26
10:04 UTC

32

What will happen to the old computers after year 9999.

68 Comments
2024/11/25
20:01 UTC

10

Must I learn COBOL

I curious about this language is it still fisible to learn it in 2024

37 Comments
2024/11/25
18:44 UTC

44

Sudoku as one-way function example?

Hi! I am a CS student and I have a presentation to make. The topic that I chose is about password storaging.
I want to put a simple example to explain to other classmates how one-way functions work, so that they can understand why hashing is secure.

Would sudoku table be a good example? Imagine that someone gives you his completed sudoku table and asks you to verify if it's done correctly. You look around for a while, do some additions, calculations and you come up with a conclusion that it is in fact done correctly.
Then the person asks you if You can tell them which were theirs initial numbers on that sudoku?
Obviously, You can't. At the moment at least. With a help of a computer You could develop an algorithm to check all the possibilities and one of them would be right, but You can't be 100% certain about which one is it.

Does that mean that completing a sudoku table is some kind of one-way function (or at least a good, simple example to explain the topic)? I am aware of the fact that we're not even sure if one-way functions actually exist.
I'm looking for insights, feedback and general ideas!
Thanks in advance!

71 Comments
2024/11/24
12:56 UTC

70

How in the world did dijkstra come up with the shunting yards algorithm

i would have never reached to that conclusion on how a compiler would solve an equation that way. If anyone can provide any more insight on how he could have come to that conclusion i would really appreciate it

10 Comments
2024/11/24
05:22 UTC

6

I have a wierd question ?

first of all, my question might be abbsurd but i ask you guys because i dont know how it works :(

so lets say 2 computers each renedering diffrent scenes on blender(or any app). focusing on cpu, is there any work or any calculations they do same ? well we can go as down as bits or 0's and 1's. problably there are same works they do but we are talking on a diffrent scene renders, is the work the cpu's doing "same" has considerable enough workload ?

idk if my english is good enough to explain this sorry again, so ill try to give example ;

b1 and b2 computers rendering diffrent scenes on blender. they both using %100 cpu's. what precent cpu usage is doing the same calculations on both computers ? i know you cant give Any precent or anything but i just wonder is it considerable enough like %10 or %20 ??

you can ask any questions if you didnt understand, its all my fault. im kinda dumb

18 Comments
2024/11/23
18:19 UTC

31

Computer arithmetic question, why does the computer deal with negative numbers in 3 different ways?

For integers, it uses CA2,

for floating point numbers, it uses a bit sign,

and for the exponent within the floating point representation, it uses a bias.

Wouldn't it make more sense for it to use 1 universal way everywhere? (preferably not a bit sign to access a larger amount of values)

34 Comments
2024/11/23
13:23 UTC

8

Computer architecture book suggestions

I thought about building a small computer with raspberry pi Pico and a 6502 but I don't know much about computer architecture, what are good books to deepen my understandig?

4 Comments
2024/11/23
13:15 UTC

70

If every program/data can be seen as a single binary number, could you compress it by just storing that number's prime factors?

Basically title, wouldn't that be close to being the tightest possible compression that doesn't need some outlandish or specific interpretation to unpack? Probably it's hard to find the prime factors of very large numbers, which is why this isn't done, but unpacking that data without any loss in content would be very efficient (just multiply the prime factors, write the result in binary and read that binary as code/some data format)

65 Comments
2024/11/22
12:53 UTC

10

Is there an official specification of all unicode character ranges?

I've experimented little script which outputs all unicode characters, in specified character ranges (cause not all code-point values from 0x00000000 to 0xFFFFFFFF are accepted as unicode)

Surprisingly, i found no reliable information for full list of character ranges (most of them didn't list emoticons)

the fullest list, i've found so far is this with 209 character range entries (most of the websites give 140-150 entries):
https://www.unicodepedia.com/groups/

6 Comments
2024/11/20
19:17 UTC

0

Is a non intrusive peer to peer network possible?

I would like to know if a peer to peer network can be established that can be done without 3rd party software or code, just non intrusive.

For example someone has a file that he wants to send to someone but wants to do it the fastest way using peer to peer over public internet how can he do it without downloading any additional stuff to perform it? I mean that the receiving peer doesn't need anything to get it

Other question

How can someone in a peer to peer contribution network connect to the nearest peer? Does the network need a data centre with database that has all geolocation data and it calculates the nearest peer using formula or machine learning?

The closest peer is one with lowest ping.

The geolocation data is there in firsthand because the peer to peer contribution network. The contributors must share it to reduce latency.

9 Comments
2024/11/19
22:34 UTC

0

How are Loads balanced in blockchain?

Is there a central hypervisor that assigns task centrally or any other way?

9 Comments
2024/11/19
22:25 UTC

35

I don't understand what you do with big data.

So when you have a website or app that has lots of traffic and it creates lots of data. What do you do with the data besides recomendations and ML training and selling? What can be applications of the data? What do you do with the Data?

13 Comments
2024/11/19
20:10 UTC

5

Revolutionizing Computing: Memory-Based Calculations for Efficiency and Speed

Hey everyone, I had this idea: what if we could replace some real-time calculations in engines or graphics with precomputed memory lookups or approximations? It’s kind of like how supercomputers simulate weather or physics—they don’t calculate every tiny detail; they use approximations that are “close enough.” Imagine applying this to graphics engines: instead of recalculating the same physics or light interactions over and over, you’d use a memory-efficient table of precomputed values or patterns. It could potentially revolutionize performance by cutting down on computational overhead! What do you think? Could this redefine how we optimize devices and engines? Let’s discuss!

62 Comments
2024/11/18
22:04 UTC

0

Starburst or Starbust???

One of them is suspected to be the name of a character generation method in the Computer Graphics subject.

If someone here actually knows the right answer please let me know, because I have been trying to find the correct spelling and some searches say it as Starburst and others say it as Starbust. I have a study material given to me by my teacher that uses both spellings.

3 Comments
2024/11/18
10:23 UTC

Back To Top