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
2 answers

How to fix Value of type cannot be assigned to entity of type ERROR?

I am developing a 2-Dimensional array in c++ using user input of rows and columns and want to allocate memory for the columns but I keep receiving an error which states; A value of type "int" cannot be assigned to entity of type "int" I know what…
1
vote
1 answer

Finding 2 least correlating/similar lists in a list of lists

I have a list of paths taken from networkX by nx.shortest_simple_paths(g,s,d) and the paths are: [[T1, E1B, E2B, ACD6B, DE6, T3], [T1, E1B, ACD3B, ACD6B, DE6, T3], [T1, E1B, ACD3B, DE2, DE4, DE6, T3], [T1, E1B, E2B, ACD6B, ACD3B, DE2, DE4, DE6,…
1
vote
1 answer

How is the Root Node being updated when child nodes are the ones updated when performing Tree modifications?

How does a Tree's parent node get updated with the child updates we perform? Specifically like when you do a BFS or DFS search, perform a check at the node, and then update that node. What causes in memory or in the programming language to know "Oh…
1
vote
5 answers

Nested for loop to compare pairs

My java project is having a little issue here, I simplified it to the following codes. My codes print out: Index 0 and 1 are pointing to same value. Index 1 and 0 are pointing to same value. Index 3 and 4 are pointing to same value. Index 4 and 3…
1
vote
0 answers

Time complexity of the recursive Gray Code algorithm

The following Gray Code algorithm is taken from the Elements of Programming Interviews book. Given a partially built result in which all pairs of adjacent elements differ at most in one bit, it computes the next element by changing one bit of the…
super.t
  • 2,526
  • 7
  • 32
  • 51
1
vote
2 answers

Do I avoid the risk of privacy leaks, if I set the instance variables to private?

I am working on a Java assignment. My professor wrote: Warning: Be sure to set the attributes of the Class in such a way to avoid the risk of any privacy leaks. I am getting confused with it. My understanding towards privacy leaks is always to use a…
1
vote
1 answer

Error with unit testing using selfassertAlmostEqual

right so I am getting an error with unit testing where I can't use selfassertAlmostEqual in assertAlmostEqual diff = abs(first - second) TypeError: unsupported operand type(s) for -: 'list' and 'list this is my unittest method where I am…
bart
  • 21
  • 3
1
vote
1 answer

I'm trying how to print this output to a text file on python

I'm struggling to print the output to a text file. Right now whenever I run it, it just says none in the text file. Someone, please help. def SieveOfEratosthenes(): n = int(input("Enter a Number: ")) file = open("primes.txt", "w") prime…
1
vote
1 answer

How to detect in LMC that calculation is greater than 999 and then output 999?

I need to write an LMC program to solve a+bx+x2. Further, if the result is greater than 999, then it needs to output 999; if less than 999, then output the result. I have done the a+bx+x2 part, but have no idea how to output 999 when there is…
陈俊滔
  • 21
  • 1
1
vote
1 answer

Convert undirected graph to directed graph such that the indegree of each vertex is at least 2

For an undirected graph G if possible I want to convert G to a directed graph such that in the directed graph each vertex must have an indegree of at least 2. I worked out that for it to be possible the amount of edges will need be at least 2|V|…
1
vote
1 answer

Is there an algorithm to compute if a calculation will overflow a type size?

Is there an algorithm which can be applied to most languages to determine if a calculation when preformed will overflow the type size? As an example if given the following code fragment in Java (although again I am looking for a general approach in…
Dev
  • 13
  • 3
1
vote
1 answer

How to find a point within a square in racket?

Currently, I am struggling with figuring out a function that can determine if a point is in a square or not given the side length and top left corner of the square. ; tl is a Posn, giving the top-left corner of the square ; side is a Number, giving…
1
vote
1 answer

Total Time Complexity of Nested Big-O's

I wrote a program to calculate the factorial of a number, and store the digits of the result in a Python list. To find the factorial, I run a loop that takes O(N) and store the result in "ans" To find the number of digits of "ans", I run another…
1
vote
1 answer

Parsing loops in a javascript interpreter

I've been exploring writing a very basic / limited interpreter in javascript as an exercise. All has been going well until I introduced the concept of LOOPs. Given the following script: LOOP 2 A LOOP 3 B END LOOP 4 C LOOP 5 …
1
vote
2 answers

How do you get rid of Hz when calculating MIPS?

I'm learning computer structure. I have a question about MIPS, one of the ways to calculate CPU execution time. The MIPS formula is as follows. And if the clock rate is 4 GHz and the CPI is 1. I think MIPS is 4,000hz. Because It's 4 * 10^9 * Hz / 1…
SoNoob
  • 17
  • 5