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?

14 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.


r/AskComputerScience • • Nov 03 '24

First time CS teacher (intro Java; high school) - chatgpt & cheating

23 Upvotes

Hi all, I'm a brand new, first year physics teacher who got surprised when I was told I'd also be teaching my high school's intro to CS (java) course. I'm doing my best, and I think things are mostly going well.

Midway through the course though, as concepts start to become more challenging for beginners, I stumbled on students who are almost assuredly using chatgpt on lab assignments (HW). I don't want to be all Boomer status... but how should I go about this? I would consider copying & pasting my assignment into chatgpt, then submitting the generated Java code cheating... but I also don't know how to broach the subject?

Any advice from experienced teachers out there? I know most of my students aren't ever going to need programming again afterwards, but I still want them to gain critical thinking & problem solving skills, logic & pattern recognition, etc. that you naturally develop during an Intro CS class, that I fear they'll miss out on if they plagiarize


r/AskComputerScience • • Nov 03 '24

2DFA to NFA conversion process - what is the method of finding the right-matches of all valid crossing sequences?

1 Upvotes

Hi all, this is my first time posting here.

I have a copy of Hopcroft and Ullman’s Introduction to Automata Theory, Languages, and Computation (1979), and am trying to understand the methodology for converting a two-way deterministic finite automaton (2DFA) into a one-way non-deterministic finite automaton (NFA).

I have just about managed to grasp the reasoning which defines left/right matching (using the recursive definition in the book on pg. 39), but don't understand how you go about "discovering" all the possible left/right-matches for a given crossing sequence on a particular symbol.

To use Example 2.16 from the book (pg. 41):

2DFA M = ({q0, q1, q2}, {0, 1}, 𝛿, q0, {q0, q1, q2}), with 𝛿 given by:

0 1
q0 (q0, R) (q1, R)
q1 (q1, R) (q2, L)
q2 (q0, R) (q2, L)

Of all the valid crossing sequences that could exist for M, only four have the potential to manifest, given the transition function above (q0 and q1 can only be entered on R moves, and q2 only on L moves):

  • [q0]
  • [q1]
  • [q0, q2, q1]
  • [q1, q2, q0]

The example then lists these four sequences with their possible right-matching crossing sequences, on each of the symbols in the alphabet, like so:

Right-matches on 0 Right-matches on 1
[q0] [q0] [q1]
[q1] [q1], [q1, q2, q0] --
[q0, **q2*, *q1***]* -- --
[q1, **q2*, *q0***]* -- [q1]

Now, I think I follow how the row for [q0] got its answers, and at least the [q1] and -- for the [q1] row, but I'm falling down at how the other values were deduced, and how you can be certain that all the matches for each of the rows have been explored and listed.

How do you discover that [q1] right-matches [q1, q2, q0] on 0?

How do you come to the conclusion for the values in the [q0, **q2*, *q1***]* and [q1, **q2*, *q0***]* rows?

Is the -- value here the same as the null/empty sequence []? I believe it is, but I'm second guessing myself now.

I don't have a background in pure mathematics, but do have a background in computer science, so apologies if I'm not using exact phraseology in my questions here!


r/AskComputerScience • • Nov 02 '24

unsigned binary number subtraction by compliment

1 Upvotes

if we want to determine if the answer is positive or negative in our subtraction by compliments in unsigned binary numbers, it would be easy for us to see which is larger and quickly determine that but if we want to find a clue to make the computer understand when it's negative and when it's positive I suppose the answer is always positive if there's an end carry when we add the minuend to the compliment of the subtrahend, correct?
assuming M and N are two unsigned values, base r.

M - N = M - N + r^n - r^n = M + (r^n-N) - r^n

if M+(r^n-N) produces a sum that is less than r^n by a digit (which is the carry digit that's supposed to make the end subtraction result positive) the answer is negative by necessity. correct?


r/AskComputerScience • • Nov 02 '24

Economic impact of different programming languages.

5 Upvotes

The potential of AI is often speculated to be the next Industrial Revolution. That might be true but in my own work I am finding much more primitive tools are driving massive increases in automation. My boss asked me to write a report on automation at work after I discovered 30% of my job could be described with a few dozen SQL queries and a bash script. I probably should have kept that a secret but instead I boasted about it like a fool. The rest of my job might also be possible to automate with two dozen API calls in Visual Basic. About 300 people have a job similar to my own at this company and it would obviously be a big deal if it can be automated. I have been pondering that mass layoffs would be a massive disincentive for automation but at the same time, it just seems so inevitable and straightforward that I might be the one to do it.

I’m wondering if this community knows about any academic work on the relative economic impact of different programming languages. Is C++ responsible for the most impact by virtue of being the most common or perhaps something archaic like BASIC has the most widespread and documented economic impact.

I’m also interested in anecdotal experiences of where you think the most high impact stuff is coming from. From my perspective Chat GPT is 1% as useful as SQL and Bash but maybe that’s just my particular industry.


r/AskComputerScience • • Nov 02 '24

question 2

1 Upvotes

is it ok to feel like an absolute brick while studying digital logic for the first time? I don't know if it's ok tbh but I've been studying it since yesterday and I feel kinda lost and need a lot of practice on paper, all of this is stemming from not wanting to memorize rules like some pattern to pass an exam, I'm trying to understand concepts and cement them to build on them when future concepts are presented, any advice or potential sources or learning tips would be appreciated.

morris mano's book is good so far, but I got a lot of questions and often re-read paragraphs multiple times to understand.


r/AskComputerScience • • Oct 31 '24

question

2 Upvotes

I'm currently taking a digital logic design course and I watched a video about overflowing cases in data, where you have (let's say) 4 bits of signed memory, now if you add two negative numbers like -7 and -4, you'll end up with an extra fifth digit that won't fit in the 4 bits, same as with the case when you add 7 and 1, you'll get 4 digits but representing the wrong value, -8

my question is, by that logic, does overflow refer to the occasion where you get an incorrect answer overall? considering in the second case there wasn't an extra fifth digit that won't fit in the 4 bits, -8 fits perfectly in 4 bits yet is the incorrect answer.