/r/AskComputerScience

Photograph via snooOG

Ask Computer Science Questions And Get Answers! This subreddit is intended for questions about topics that might be taught by a computer science department at a university.

Ask Computer Science Questions And Get Answers!

Before posting please read our rules.

This subreddit is intended for questions about topics that might be taught by a computer science department at a university. Questions do not have to be expert-level - it's perfectly fine to ask beginner questions. We all start somewhere. All we ask is that your questions be on-topic.

If you have questions that aren't directly about computer science, here are some other subreddits that can likely offer you more help:

If your post is off-topic, or violates one of our other rules, your post may be removed.

/r/AskComputerScience

78,491 Subscribers

1

Pathing/Travelling Salesman Problem for Risk AI.

Hey guys! I'm coding an AI for Risk: Global dominations which is a popular online implementation of the board game Risk. I'll be writing a symbolic AI which will manually calculate paths for capturing territories and bonuses. Currently I have been stuck on finding a method to find the paths which the AI should take to capture a territory bonus (pics if you are unfamiliar with the game).

I am intending to represent the board as a graph, with nodes representing territories (and their troop/player data) and edges representing the connections between these territories. Examples of the AI pathing to take territories would be this position for the green agent to take Europe, and this position for the pink agent to take Asia. In this problem, we can have multiple starting stacks, with the goal to travel to all unoccupied territories and preferably end with the troops on external border territories to guard from invasion. Note that I am only looking for ways to find these paths from multiple starting points, not the evaluation of them. Also note that each territory can only be visited once, but as shown in the pink agent example, one territory can make multiple attacks off the same territory, it just cannot be recaptured.

Algorithms to achieve this, tips on board representation and fields of study covering similar problems would all be greatly appreciated! Cheers.

0 Comments
2024/04/20
04:54 UTC

0

Market value of data compression projects

How big is the market for data compression projects? I'm working on a software project related to data compression. I won't go into details about exactly how it works. At the end of the day, if I manage to make something really useful, I want to make money from it. But as I mentioned above, I don't know anything about the market side of things. Thanks in advance for your answers.

6 Comments
2024/04/20
02:37 UTC

4

Is learning assembly useful? IA32/AMD64/ARM?

I'm taking a Architecture & Assembly course in school right now and we're being taught x86-IA32.
I will say, I rather enjoy it. It's pretty cool learning this stuff, but I am curious if it's like... useful?
I'm sure assembly languages aren't useful for... say web developers... but are any of them useful for anyone?
My specific questions:

  1. is IA32 pretty much completely obsolete now or is it still valuable to learn? I'm learning it for this class so I'm sure it has some usefulness... right?
  2. is AMD64 (or any type of 64 bit CISC assembly) really that fucking hard to learn/code with? Does anyone code in 64 bit assembly? AMD64 is the ISA currently used for most Windows PCs correct?
  3. how much crossover is there with ARM if I'm learning some type of CISC (IA32) assembly? Are they completely unrelated, or will learning any assembly language make it easier to pick up any other assembly language (CISC or RISC, doesn't matter)?
7 Comments
2024/04/19
18:24 UTC

0

Is deciding all combinations of repeated usage of A; does not sum up to A coNP-complete?

Given a set A = {2,3,5,....} decide if every possible combination with repeated usage of set A makes the following true. Where sum(A) ≠ sum(D), where D = every possible combination with repeated usage.

Edit: D must contain at least 2 multiplicities of an element. For example {2,2,3,5,6...}

Edit: A must consist of ONLY distinct numbers > 1. No repeated elements in A

I think this a special case of subset sum and partitioning, but we're allowed to use elements more than once.

Here's an example where the output would be FALSE

When A = {2,4}, and the counter-result is {2,2,2} . Notice that {2+2+2} = {2+4}, as they both sum up to 6.

Since sum(S) = sum(D), the expression sum(A) ≠ sum(D is not true thus the output is FALSE

7 Comments
2024/04/19
03:10 UTC

1

What do companies do with deleted data?

So this is a question I’ve had for a few years now and since I made a reddit account I can finally ask people. If this subreddit isn’t the right one for this question I’d appreciate someone told me where I should ask.

Onto the actual question: Let’s say you uploaded something, sent a message, searched something or whatever else and then deleted it. I understand companies keep backups but if it were a company with millions and millions of users, do they really keep all of that or do they purge it after a certain amount of time? I don’t know much about how storing data works but I think the storage is limited, meaning they can’t keep deleted data indefinitely forever or they’ll run out of storage. Can anyone explain to me how it works?

6 Comments
2024/04/18
23:57 UTC

2

Can anyone talk about what data security tasks are like in industry, or recommend an introductory data security textbook?

I had a professor suggest to me at one point that this niche might be up my alley. Seems worth looking at, at the very least!

3 Comments
2024/04/18
23:47 UTC

1

What is CAL and CBT

What's the difference? I can't understand

4 Comments
2024/04/18
22:42 UTC

0

Since Drive-mount points in Windows start at C:, is it accurate to say that A and B are reserved for the CPU socket and RAM slots?

Just curious.

And if not, Why does it always start at C?

11 Comments
2024/04/18
19:26 UTC

1

What is "Funny Hex?!"

I want to design and create pinball machines as a hobby. To that end, I'm studying for ETA International's Gaming and Vending Technician (GVT) certification. I'm looking at the list of necessary competencies, and everything seems to be in order until I see the following entry:

4.2.3 Perform Hex to Funny Hex conversions

...what the hell is Funny Hex? I've never heard of it and the internet has so far come up empty. Can anyone here please enlighten me?

4 Comments
2024/04/18
14:47 UTC

0

Is line segmentation method can be used in virtual memory locations?

Greetings dear Scientists. Yesterday I study Analytical Geometry. And find an interesting formula. ( At least its interesting to me.) Which is Dividing a Line-Segment in a Given Ratio. For better understanding I describe the formula then asking the question.

If you have point1 and point2 in a rectangular coordinate system and you want to segment the line which point1 and point2 it holds you should use this formula:

point1(x1,y1)
point2(x2,y2)

segment ratio => m1:m2

pointSegment(x3,y3)

x3 = (m2*x1 + m1*x2) / m1+m2

y3= (m2*y1 + m1 *y1) / m1+m2

if you choose segment ratio 1:1 than its the center of the line.

x3 = (x1+x2) /2
y3 = (y1+y2) /2

I thought this formula can be using virtual memory locations to be better paging. ( I know in paging methods you cant use segmentation method. Because paging needs to be doing in flat memory model. But I don't know why it cant be by using this way)

Thank you for giving a time.

1 Comment
2024/04/18
11:37 UTC

2

Testing plans

hi, I'm working on my A level coursework on the testing section, my program is a game and I'm not sure what to put as the test type for some of my tests (normal/erroneous/boundary). so for example, part of my game involves remembering a sequence of characters (eg. a2k2k) and inputting them. if I do a test on the user inputting an incorrect string and in the test say to enter 'aaaaa' would this be normal or erroneous data? because I thought it might be erroneous but then I was thinking that erroneous data might actually be using incorrect data types like '!' or inputting a 'backspace'. I hope this explanation made sense and I apologise if this is just me being a silly (I've been working on this thing for too long)

0 Comments
2024/04/18
09:01 UTC

2

Why don't just merge browser and search engine 🤔

I'm no expert.(Just curiosity)

7 Comments
2024/04/18
01:03 UTC

2

What would a correctness proof look like for a cycle-counting algorithm on a strongly connected simple directed graph that runs graphsearch and increments cycle count for every encounter of an already visited vertex?

After testing with some examples, I believe that this algorithm should work, but my proof relied on the assumption that the number of back edges equals the number of cycles, which is wrong, since the existence of a back edge only indicates whether there's a cycle or not. Any hints on where to proceed?

1 Comment
2024/04/16
21:18 UTC

1

Diagrammes

I want to create a class diagramme, use case diagramme and sequence diagramme to create an e commerce website. what the steps i should make and if there's a point you think i should pay attention to?

0 Comments
2024/04/16
17:17 UTC

1

Is nesting layers of visualisation something that should be avoided?

So although this is question that I find myself wondering for pragmatic reasons (should I create a container inside this container or create a new container on the host ... etc?) I thought it might be worth asking from a general computer science standpoint.

I have a very limited understanding of the mechanics that make the miracle of virtualisation actually work (the hypervisors, etc).

But as a general principle:

Does creating nested layers of virtualisation "stress" or pose a challenge to the operation of modern CPUs that can support at least one layer of it?

Or can one virtualize as many layers deep as one wishes (a container inside a VM inside a VM etc) and it's all the same so long as the CPU cores and threads can handle the workload?

3 Comments
2024/04/16
12:52 UTC

2

Working through OSTEP, wondering when I should do the projects

Hey all, never took an OS course before so I'm filling the gaps.

Got a copy of OSTEP for a few bucks, plus using the online repository. I noticed they have projects in there, but no reference to the projects.

Is there a syllabus I could grab from somewhere to pace myself?

0 Comments
2024/04/15
22:50 UTC

4

How would you determine the time complexity of a function that has nested functions?

I get that whenever you have nested for loops that are iterating over the same input, then the time complexity is O(n^2), but what if the inner loop is iterating over a different set of inputs, meaning the inner loop (or function) has a separate running time complexity than the first loop.

validate_primes iterates over each number in the input list, that already puts the time complexity at O(n), but in each iteration, `is_prime` is being called and it has a time complexity of O(sqrt(n)) for a different input n. I'm not sure how I would consolidate these 2 patterns. Could anyone help me in understanding what the ultimate time complexity of `validate_primes` is?

Example code:

def is_prime(number: int) -> bool:
    # implementation inconsequential
    # this function is O( sqrt(n) ) for any given input number
    ...

def validate_primes (numbers: list[int]) -> list[bool]:
    """Takes an input of numbers and determines whether each number is prime

    examples:
        expected input: [3, 4, 5]
        expected output: [True, False, True]

    Args:
        numbers (list[int]): list of positive integers

    Returns:
        list[bool]: list of booleans, indicating whether 
        each corresponding element of the input list is prime
    """

    for num in numbers:
        result = is_prime(num)
        print(result)

Thank you

1 Comment
2024/04/15
17:59 UTC

1

What would a high-level description be of an algorithm that checks if there exists a walk that goes through each vertex at least once?

I'm thinking this algorithm has something to do with BFS or DFS search, but I'm not completely sure how to describe the specific details.

9 Comments
2024/04/15
03:50 UTC

1

algorithm that search the pareto set

I have a task that involves finding a Pareto set in a group of data I have, for example there are some vectors, and from these vectors I have to find the Pareto set. I'm new to the game, learning some C.

I see there are so many algorithms that do this, but I really don't understand how they work. I don't want the solution, I just want to know how they work.

For example, here it is my work from now, but it didn't work:

https://wtools.io/paste-code/bU8v

https://www.sciencedirect.com/science/article/pii/S0925772111000642#se0010,

i tried to use the sequencial algorithm, the second one, but for me the hard part to understand is that i have so many index associated to the struct province, a lot, and if you take a look at this paper it say literally the definition of dominance, in n-dimensional space, i understand how it works in 2 -dimensional space(https://en.wikipedia.org/wiki/Maxima\_of\_a\_point\_set), but in n-dimensional space i think that is impossible that even one province dominates another one. and in the other hand, i don't understand why there isn't a unique way to do that, because, if i read correctly, each algorithm have its own problems.

please help.

1 Comment
2024/04/14
08:55 UTC

3

Why do they include the pivot in the left partition?

I was reading hoares quicksort on the quicksort Wikipedia page and saw it included the pivot in the left. Why is this, I thought the pivot would already be in the correct position?

5 Comments
2024/04/14
00:56 UTC

1

Explanation needed

Hi. I’m trying to understand 8bit 2’s complement binary addition but I’m a bit confused. I have seen explanations that it is considered overflow if the carry into MSB is not the same as carry out of MSB, but also that overflow is when a carry over results in a bit outside of the specified bit range.

E.g. for one of the practice questions I have done, the carry out into MSB and carry out of MSB are both 1 but it leads to a ninth bit when doing this 8 bit 2’s complement addition between a positive and negative number.

Is that considered overflow because theres a ninth bit or is it fine because carry in = carry out of MSB and can just discard it.

Any explanation would help 🙏

2 Comments
2024/04/12
08:26 UTC

1

Edge Computing Playlist

Im interested in learning edge computing from fundamentals. But I could not find any good resources for edge computing. So, can anyone please suggest any good playlist or course for edge computing??

Thanks in advance.

2 Comments
2024/04/11
09:07 UTC

6

What are some recent innovations in DBMS?

In 2030 or 2035, what DBMS implementation innovations will be standard which are today research papers or niche technologies?

7 Comments
2024/04/11
08:44 UTC

7

Proving that Hindi is a context free language

This question was recently given to me in a university assignment for theory of computation and I am not really sure on how I can approach such a question.

I know that one option is to use pumping lemma on the grammar, but how do I make the grammar for a language as vast as Hindi?

There were some articles about taking examples such as a^(n)b^(m)c^(n)d^(m). But I didn't fully understand these examples either.

Any suggestions on how I should approach this proof?

29 Comments
2024/04/11
06:41 UTC

1

What is meant by "schemes" in this context?

"In computer programming, Base64 is a group of binary-to-text encoding schemes that transforms binary data into a sequence of printable characters"

2 Comments
2024/04/11
04:48 UTC

0

WHY does quicksort work?

I see how it works but why? Why is each step done and why do they make it work?

10 Comments
2024/04/11
01:41 UTC

6

What are some "authorities" in cs?

I know IEEE is responsible for many standards, and was wondering what are some of the principal organizations in the industry. Sorry if the post is against the rules.

1 Comment
2024/04/10
15:06 UTC

0

another "attempt of mine to solve" the P vs NP problem, or rather a question of, why not?

i was once again thinking about the P vs NP problem, so i had this idea and i needed someone who knows about the topic to explain me why it can't be an answer to it (because i'm not expecting to even nearly solve such a major problem) in any case, it's just curiosity and i'm far away from being a "professional" and just doing it for fun, also i'm not sure whether this can be possibly considered an NP-Complete problem. but anyways there you go.

let's put it this way: i have this super intelligent artificial intelligence, an ai far beyond humans capacity intelligence and logic which can solve any problem as long as it is possible and solvable. if i asked this machine to solve the P = NP problem itself, i don't know how but it definitively will, it could only possibly come up with two answers: if it states that P = NP then it would mean it, if so, it is true and everybody is happy. now, if the machine can't possibly solve the problem, it would mean that P is not equal NP. but, if we see this whole problem itself i gave you as an NP problem, for the machine, stating that P != NP would be an answer to the problem itself. if the computer can't solve P = NP in polynomial time using all the knowledge it's got, then it would mean that it is not possible for it to solve P = NP. but remember, this problem itself is a P vs NP problem for the machine so that stating P != NP would be solving the problem, solving it in polynomial times by contradiction. by using this logic, wouldn't it mean that there's only one possible answer for this problem, being: P = NP?

--

now, here comes the possible trick. what i just wrote, that is the problem you would actually feed to the ai. solving P = NP itself might not be an NP problem, to be fair i don't know (if it is, great. it makes things easier). but the text i wrote above does seem to be one, and i find it similar to the halting problem. so, if you were to feed it to the machine, i think that the problem itself would be turned into a P vs NP problem (that or the symptoms of not having slept the whole night are starting to show... if it's too dumb please just ignore this chunk and keep the first one for good :b) in any case, let's go straight to the point, where did i mess?

7 Comments
2024/04/10
11:55 UTC

1

Is this TSP simplification NP-Hard

I'm currently having to deal with a version of the travelling salesman problem and I'm wondering if any clever algorithms exist which can determine if a route exists or not.

More specifically I don't need a circuit, just a route which traverses every single node, so it can start and end in different nodes. Furthermore the graph I'm looking is not fully connected.

I'm wondering if there exist any algorithms which can quickly determine if there is a possible path in O(N) or O(nlog(n)) time.

A bonus would be an algorithm which also finds the path but this is not required. Can anyone help?

6 Comments
2024/04/09
18:43 UTC

1

creative thinking around a numbering scheme

I maintain a number of Servers, on each of these Servers I run a set of core software components which are required for the application to run correctly

Each of these core software components use a particular software version, and they often are different between servers.

I would like to come up with a way to 'name' or 'version' these components so that I can refer to them as a group.

For an example, these are servers A1, B1, C1, D1 and the components they have, I am presenting it as a dictionary:

A1: { "COMP1": 1.1, "COMP2": 1.0, "COMP3": 8.0, "COMP4": 1.2, "COMP5": 1.5 }

B1: { "COMP1": 1.0, "COMP2": 0.9, "COMP3": 8.0, "COMP4": 1.2, "COMP5": 1.5 }

C1: { "COMP1": 0.8, "COMP2": 1.1, "COMP3": 7.0, "COMP4": 1.2, "COMP5": 1.5 }

D1: { "COMP1": 1.3, "COMP2": 0.3, "COMP3": 9.0, "COMP4": 1.2, "COMP5": 1.5 }

What could be a naming or versioning framework I could use so that I could say:

server A1 - is on version XPTO1

server B1 - is on version XPTO2

And that would allow me to understand which versions are in use by each server.

Also that could allow me to understand how one version is running components that are older than components of another version.

This assuming the higher the numeric value for a component the more recent that component is.

I have been going around in circles trying to come up with something useful and human readable, maybe it is not possible to achieve both.

suggestions ?

1 Comment
2024/04/09
09:57 UTC

Back To Top