r/AskComputerScience • • Nov 14 '24

Experience with MIT Distributed Systems Course

0 Upvotes

Hello!

I recently got started with the MIT Distributed Systems course. I've had an interest in distributed systems for a long time and I've thought to commit myself to this course for this semester.

However, I am having a little bit of trouble with the lab assignments. I was able to do well in the assignments until I hit the Raft implementation. I'm having a little trouble wrapping my head around it.

For example, how do you maintain state in the application? Do you have a separate goroutine for it and have one (or many) goroutines intercepting requests that will send messages via channels to the state goroutine? I read about this concept in the "Fault Tolerant Virtual Machines" paper about representing state via state machines and I thought it could apply to this implementation of raft. Would you want to replicate this goroutine state so that if the main state goroutine goes down, you don't lose the state completely? How would you even decide which state goroutine is the master and which goroutine is the one that just has the state replica?

Furthermore, if I expect more than one node to be in the network, how would know where to send my RPC requests? Isn't Raft used to solve this problem of service discovery? Similarly, if any node in the network can assume the position of leader and can also become a follower, how do you configure your applications so that they can both be RPC receivers (servers) and RPC senders (clients)? Do you just have two goroutines for these two purposes?

These are some of the questions I am asking myself while trying to think of how Raft was to be implemented. As you can see, I am struggling with the basics. I am willing to learn. I am willing to be good at this stuff. But right now, I cannot figure out how to start thinking about things in a distributed manner.

Is it just me or do other people have the same experience? If so, what did you do that made you "level up"? Any resource (literature, videos, etc) would be extremely helpful. I'm hoping for any advice that could help my situation. Thank you for the help!

TLDR: Struggling with understanding how to implement distributed systems code. Any resources would be extremely helpful!


r/AskComputerScience • • Nov 13 '24

Question about instruction set from a book

2 Upvotes

Hi, I'm studying computer structure with a book named A secret life of programs written by Jonathan E. Steinhart.

In chapter 4, there is machine language program calculating Fibonacci sequence as followed.

AddressInstructionDescription
000010 0000 0000000000Clear the accumulator (load 0 immediate).
000100 0111 0001100100Store the accumulator (0) in memory location 100.
001010 0000 0000000001Load 1 into the accumulator (load 1 immediate).
001100 0111 0001100101Store the accumulator (1) in memory location 101.
010000 0000 0001100100Load the accumulator from memory location 100.
010110 0100 0001100101Add the contents of memory location 101 to the accumulator.
011000 0111 0001100110Store the accumulator in memory location 102.
011100 0000 0001100101Load the accumulator from memory location 101.
100000 0111 0001100100Store it in memory location 100.
100100 0000 0001100110Load the accumulator from memory location 102.
101000 0111 0001100101Store it in memory location 101.
101110 0110 0011001000Compare the contents of the accumulator to the number 200.
110000 0111 0000000100Do another number if the last one was less than 200 by branching to address 4 (0100).

So, here is my first question. In the sixth row, description says add the contents of memory location 101 to the accumulator, though, why mode code is 10 which means immediate addressing mode, not 00 - direct?

As far as I understand, 10 - immediate mode code means access the value from the address instead of access the value in the address. This is well displayed in the second instruction from the bottom.

But when I see the sixth instruction, it's a little complicate and quite confusing.

If there is anything wrong in my mind, I hope anyone help me to fix this.


r/AskComputerScience • • Nov 14 '24

Please order them from easiest to hardest

0 Upvotes

There are many playlists on MIT channel

  • MIT data structure and algorithms 2015
  • MIT 6.006 Introduction to Algorithms, Spring 2020
  • MIT 6.006 Introduction to Algorithms, Fall 2011
  • MIT 6.849 Geometric Folding Algorithms, Fall 2012
  • MIT 6.851 Advanced Data Structures, Spring 2012
  • MIT 6.890 Algorithmic Lower Bounds, Fall 2014

r/AskComputerScience • • Nov 13 '24

Choosing the Right Brute Force Approach

3 Upvotes

Hey fellow programmers,

I'm struggling with a specific aspect of problem-solving. When presenting solutions, I'm unsure about the best brute force approach to explain, especially when constraints are involved.

For example, consider merging two sorted arrays into one sorted array with no extra space allowed. Two possible brute force approaches come to mind:

Create a new array, merge and sort (O(n log n) time, O(n) space)

Use an O(n^2) approach like insertion sort, comparing and shifting elements in-place

I've seen people use the first approach (extra space) as a brute force example, but it technically violates the constraint. Should I:

A) Explain the extra space approach as brute force, acknowledging the constraint violation

B) Choose a different, less efficient brute force method (like O(n^2) insertion sort) that adheres to constraints

C) Other considerations?

What's your take on this? How do you choose the right brute force approach in similar situations?


r/AskComputerScience • • Nov 07 '24

pumping lemma for context free language

3 Upvotes

so the L={a^nb^mc^(m+n)}, this is a context-free language, but first I using pumping lemma to prove, this is not, so for the first case i want to pick v=ab, and y = bbb, when i=2, isn't v^2 = abab, and not follow the format of language, so it's not context-free?

And i have another question, is proving not context-free i need to consider all possible case, if one case is failed, then it means it is not context-free language or if through all case and i found it has one case that i pumping and it's still in the language, and it proves that this language is context free, and can i pick v or x as ab or bc, i was really confused, thank you so much if you can provide the explaination.


r/AskComputerScience • • Nov 07 '24

Why is the condition in the Quicksort Partition algorithm <= and not < ?

1 Upvotes

In the Algorithms textbook by Cormen (chapter 7.1), The Partition algorithm is

Partition(A,p,r)
x = A[r]
i = p-1
for j = p to r-1
    if A[j] <= x
        i = i+1
        exchange A[i] with A[j]
    exchange A[i+1] with A[r]
return i+1

Why is the condition in the Partition algorithm <= and not < ?

Quicksort(A,p,r)
if p<r
    q = Partition(A,,p,r)
    Quicksort(A,p,q-1)
    Quicksort(A,q+1,r)

r/AskComputerScience • • Nov 07 '24

Making a 4 bit subtractor from a 4 bit adder

3 Upvotes

Hey guys, I'm using Logisim to create a 16 bit cpu and right now I'm making a 4 bit adder/subtractor. I've followed this picture but a problem I'm getting is that the carry is 1 for values that it should not be 1 for, like when both inputs are 0. How should I fix this?


r/AskComputerScience • • Nov 06 '24

How did you guys get so good at algorithms?

17 Upvotes

I really don't get how some people can just pick up algorithms like it's nothing

I'm in this algorithms and design class and its absolutely fucking me up. Trying to come up with recurrence relations, find out amortized costs using potential functions, and then needing to come up with a proof for everything too...

I can understand the algorithms like Knapsack and Bellman-Ford etc. when they're explained to me, but when it comes to deriving something original using these algorithms as a base, I'm just completely lost. Looking at our posted solutions to said problems as well just adds to my confusion. Maybe I just need more practice, but it just feels so damn defeating to constantly be losing at this

If anyone out there is nutty with algorithms and proofs, how did you guys get so good? How do you think? Are there any good resources out there for this ?

Sorry if this kind of post isn't welcome here, I just wanted to let out little bit of steam


r/AskComputerScience • • Nov 05 '24

what is microcode and where is it located?

13 Upvotes

(Second-year CS major here) So, I’ve been looking into lower and lower level stuff recently, as I find it fascinating at how much stuff computers are doing under the hood. I’ve been told many times that machine code is the lowest level of abstraction in controlling the computer, but now I’m seeing that there is another layer of microcode beneath that, and that it can be updated. Where is the microcode stored and how can it be updated? Is the microcode the lowest level of abstraction for computers, or is there another level beneath that, or is machine code actually at the bottom of that hierarchy? Can programmers utilize microcode in their programs in the same way you can use assembly to have more control over their programs or to optimize them?


r/AskComputerScience • • Nov 05 '24

question about self attention in the paper "Hopfield Network is All You Need."

1 Upvotes

Hello, I'm having some difficulty with the paper "Hopfield Network is All You Need." I don’t understand a particular passage, and I’d be incredibly grateful to anyone who could help me make sense of it. The passage in question is here: "https://ml-jku.github.io/hopfield-layers/#update".

In this section, they refer to matrices WWW, which are projections of patterns into associative spaces. I don’t understand what that means. Likewise, I don’t really understand the concrete function of Equation 28 and Equation 30. For instance, I have a clear idea of what the update equation introduced earlier in the article does (it helps denoise a pattern), but here, for Equations 28 and 30, I don’t understand their purpose at all.

Thanks


r/AskComputerScience • • Nov 04 '24

Books about the history of computers.

10 Upvotes

Im trying to get into the history of computers. im looking for a book that goes into depth about the technologies and how they were made. i want to start at the beginning and work my way up to the present day.


r/AskComputerScience • • Nov 04 '24

Why does 6502 Assembly not have any opcodes ending in 3, 7, B, or F, and only one ending in 2? (A2 - LDX $xx)

2 Upvotes

This greatly confuses me.


r/AskComputerScience • • Nov 03 '24

Few questions on interpretation and evaluator ......

2 Upvotes

A program when is passed to the evaluator breaks it down to the simplest of instructions ... the primitive instructions... My question is does the primitive instruction directly get converted to the maschine code from there ? Like + is a primtive instrcution in a language so does the evaluator or the interpreter have a data structure storing these primitive instructions and thier respective maschine codes ..... or is it conversion happening at a later time ?

In normal order evaluation ... suppose i have defined a list of (1,2,3,4,(1 / 0)). Here the 5th element is an error.. so when I define the list and never use list[4] the program will run without an error or what ??

Ik in applicative order evaluation the moment u define it the evaluator program will evaluate the list and throw an error on the 5th element ... please correct me on this if I am wrong....

Any help would be appreciated. And sorry if this is the wrong sub ....


r/AskComputerScience • • Nov 03 '24

binary operators and sets

4 Upvotes

if we say that some operator is a binary operator to set S, does that necessarily mean that the set is closed relative to the operator?, the way the book talked about it seemed like both terms are referring to the same case.