Questions tagged [computer-science]

Computer science (CS) is the science behind programming. Use for questions related to the more theoretical questions involving programming. Questions of a purely theoretical nature may be off-topic. All CS questions can be asked on https://cs.stackexchange.com/

Computer science (also called computing science, and often abbreviated CS) is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems. Computer scientists invent algorithmic processes that create, describe, and transform information and formulate suitable abstractions to model complex systems.

As a discipline, computer science spans a range of topics from theoretical studies of algorithms and the limits of computation to the practical issues of implementing computing systems in hardware and software.

While some computer science questions are on-topic for Stack Overflow, many of the more theoretical questions or questions that do not apply to programming are off-topic. You can ask these types of questions on the Computer Science Stack Exchange.

4449 questions
1
vote
1 answer

Reading/Writing to a File?

What does it mean to "read to" or "write to" a file? I am a beginner at CS and am fairly confused what is the meaning of these terms. Does "reading" a text file just mean printing it?
James Rider
  • 633
  • 1
  • 9
1
vote
1 answer

Object destructuring in R for writing packages; like Python's `**` or JavaScript's `...`

I have been looking for a way to do object destructuring. This in an effort to write cleaner code when developing packages. I often have a complex system of functions that call others etc and I want to make those arguments available at the higher…
1
vote
2 answers

Complement of non-deterministic context-free language

The complement of a context-free language is not always context-free. It is not allowed to just swap the final and non-final states of an NPDA and assume that it produces the complement of the language. Could someone give an example where it goes…
1
vote
1 answer

Remove first useless productions and then unit productions?

When transforming a Context-free grammar into Chomsky Normal Form, we first remove null-productions, then unit-productions and then useless productions in this exact order. I understand that removing null-productions could give raise to…
1
vote
1 answer

Sort shopping list based on previous shopping trips

I want to sort a shopping list based on the order items were checked off in previous shopping trips. For example I go to the store and shop Apples, Bananas and Eggs. Next I go to the store I shop Avocados and Tomatos and Apples. For my next trip the…
dehlen
  • 7,325
  • 4
  • 43
  • 71
1
vote
1 answer

What is global address space?

I was reading about Cache-only memory access on Wikipedia. There is a line saying that "In NUMA, each address in the global address space is typically assigned a fixed home node". I don't know what is global address space. Can someone tell me what…
Rynor
  • 13
  • 2
1
vote
2 answers

CRC calculation: Polynomial division with bytewise message XOR-ing?

Trying to understand what is meant in this bit of pseudocode from "Code fragment 3" in the following Wikipedia page: function crc(byte array string[1..len], int len) { remainderPolynomial := 0 // A popular variant complements…
martin's
  • 3,853
  • 6
  • 32
  • 58
1
vote
1 answer

Is the UML class diagram the only notation / language to describe the structure of the system and what is the alternative?

What other languages or notations can be used to describe the structure of the system in addition to the classic UML class diagram?
1
vote
1 answer

If A is in RP and there is a polynomial time reduction from B to A then B in RP?

I think it's true because you can reduce B to A and then run the probabilistic algorithm of A and if we got a reject then it's also a reject for B and at least half of the time if the input is in A we would get an accept which means that at least…
1
vote
1 answer

Polymorphism Terminology

I've looked and I've looked, and can't find the academic answer I'm looking for. If a method is polymorphic: public class Widget { public void doSomething() { // ... } public void doSomething(int fizz) { // ... …
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
1
vote
1 answer

How to write an algorithm which finds the best possible event distribution?

I'm trying to write an algorithm that takes a list of events (in this case, screenings of movies - each movie usually has more than one screening, although that's not always the case) and returns the best possible combination of events, i.e. the one…
Nicolas
  • 87
  • 2
  • 8
1
vote
2 answers

Check symmetry in binary tree

I'm trying to check symmetry in a given tree, my idea was that i could make two Arraylists from the left subtree with pre order traversal(NLR) and from the right subtree with reverse preorder traversal(NRL), and then compare the two with equality…
Christian
  • 33
  • 4
1
vote
1 answer

How does accessing by array index affect efficiency?

Lets say, in a for loop, i am accessing 2 indexes of an array say x and x+1, and comparing those two things to find out how often the numbers of the array increase or decrease. Is it more/less/equally efficient to have a variable outside of the loop…
ebenito
  • 11
  • 1
1
vote
0 answers

LSH and minhasing - Why does hashing the signature matrix make sense?

I'm learning about LSH and minhashing and I'm trying to understand the rational of hashing the signature matrix: We divide the signature matrix to bands and we hash (using which hash function?) every portion of column to k buckets. Why would it make…
Elimination
  • 2,619
  • 4
  • 22
  • 38
1
vote
3 answers

Zybooks 6.18 LAB: Track laps to miles

So I have written the code correctly for this problem, but I don't understand a part of the code that was already present as a requirement to use. What does this part of the code do?: if __name__ == '__main__': The problem prompt is: One lap around…
Angie
  • 41
  • 1
  • 4