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

B-Tree index vs B-Tree as a data structure used in a storage engine?

I'm reading DDIA and it references LSM Trees and B-Trees as indexes used in DBs. But it also talks about both data structures used to store data. Are B-Trees used purely as indexes so when I query a column that I created an index on a B-Tree is…
Paul
  • 1,101
  • 1
  • 11
  • 20
1
vote
2 answers

Sorting Structures using qsort

I have to use quicksort to sort the states by percentage of population whose ages are equal or greater than 65 years old. I can't figure out on how to use it in the function. I cannot seem to change the compare function. I also have to make a new…
1
vote
1 answer

why dont i have to declare the variable in javascript for loop

in javascript, why are we able to use variables that havent been declared (i.e. const, let, var) in the for loop? example code below: function testFunc(items) { for (item of items) { console.log(item) } } I would expect the above…
1
vote
0 answers

Best allocation strategy that need not preserve pointer validity

I have a contiguous heap of heterogeneous objects that need not preserve the validity of pointers to previously allocated objects upon a call to allocate, i.e: int* p = heap.allocate(1); int* q = heap.allocate(1); // p need not point to the int it…
1
vote
0 answers

Black Scholes PDE for call and put option

So I am trying to implement this PDE so I can obtain the price of a call and put option at t=0.I am having trouble setting up my parameters for stepsize and time step size. Would I need to create a mesh? or Would I need to make another axis?
1
vote
1 answer

Determining language from a grammar

I'm trying to solve an exercise on grammars and languages. Here is the exercise: Let the grammar G be: G = {V, T, P, S}, V = {S, A, B}, T = {a, b, c}, P = {S → ABA; A → a | bb; B → bS | ε} What language is generated by this grammar? I've tried…
Draconyx
  • 11
  • 2
1
vote
3 answers

Convert Integer number to a Boolean List with 3 elements (Java)

I have an integer number withing an interval [0,7]. And I want to convert this number into a Boolean list with 3 elements with Java. 1st element in the list has a value of 4, 2nd element has 2 and 3rd element is 1. Their sum makes 7 if all the…
firefighter
  • 171
  • 1
  • 14
1
vote
1 answer

Two 2d Arrays Sum

I'm trying to take two 2d array inputs, and then add them together, but it won't compile correctly. For some reason if i declare the 'addedMatrix' outside of the method the code compiles but the addedMatrix is blank Heres what I have so far…
Techy
  • 13
  • 4
1
vote
0 answers

Cs50 pset5 - program crashing

I finished writing my code for speller. It compiles fine but the only output being printed is "Misspelled words". The words misspelled , words in text, words in dictionary does not get printed. I'm assuming its because the program crashes before…
1
vote
4 answers

Countability Question (Theory)

I'm taking the GRE tomorrow, and had a question. Based on the answer key, this practice test states that the set of all functions from N to {0, 1} is not countable. Can't you map the natural numbers to these functions, as follows? i 1 2 3 4 5 6…
Claudiu
  • 224,032
  • 165
  • 485
  • 680
1
vote
0 answers

Python while loop and timeout - looking for better solution

The objective of the below function is: Scale down an app instance to 0 on K8s cluster. Wait for the scale down to complete. Verify if the current scale is reached 0 and no active instances are present for that app. Scale up the app to its original…
1
vote
2 answers

Implementation of the spell checking method

I am to create a method that checks spelling. The user is asked to enter a word, which is stored in str. And the word from the dictionary is stored in word, however I am having issues. I didn't manage to get this code working. The method should…
1
vote
1 answer

Find a desired index in a binary matrix in 3n − ⌊lg n⌋ − 3

Given an n×n matrix M in which every entry is either a 0 or 1. Present an algorithm that determines if ∃i, 1 ≤ i ≤ n, such that M[i,j] = 0 and M[j,i] = 1, ∀j, 1 ≤j≤ n ∧ j!=i, using examining an entry of M as the key operation. Your algorithm must…
dg22
  • 13
  • 3
1
vote
0 answers

How many bits can each memory location hold?

I am having trouble understanding this question... For a CPU with 28 address lines and 16 data lines, determined how many memory locations can be addressed by the CPU and how many bits each of these memory locations should be able to store. How do…
1
vote
5 answers

Comparison sorting algorithms evaluating more than 2x elements at each step

Comparison sorting algorithms normally evaluate 2x elements at each step (and do something different if the first element is smaller/bigger than or equal to the second element.) What are some examples of sorting algorithms, preferably stable ones,…
Oleg
  • 24,465
  • 8
  • 61
  • 91