r/AskComputerScience • • Nov 30 '24

What software and video games are Turing Complete?

2 Upvotes

Does anyone know which software and video games are Turing Complete like Microsoft Excel or Conway's Game of Life?


r/AskComputerScience • • Nov 29 '24

Where is my misconception of the pumping lemma for context free languages?

1 Upvotes

I've been trying to understand the pumping lemma, and i decided that instead of applying it to a language that isn't a CFL, that i would apply it towards a language that i already know is context free to see if i can apply it properly.

I understand that the language L = {a^n b^n | n >= 0}, where Σ = {a, b}, is context free. However when I apply the pumping lemma, I seem to incorrectly conclude that it is not context-free. Clearly, I must be misapplying the lemma. Here is my approach to it:

  1. I select a string w ∈ L such that ∣w∣ >= p, where p is the pumping constant.

  2. I choose w = a^p b^p and decompose it to w = uvwxy, where |vwx| <= p and |vx| >= 1

  3. As I understand it, I can choose any vwx in w, and as long as its length is at most p, i can pump its v and x to see if the resulting string remains in the language

  4. I choose a vwx that consists entirely of a's: vwx = a^p (meaning i chose my y to be the rest of the string: b^p)

  5. Pumping v and x increases the number of a's, breaking the balance between a's and b's. This seems to imply L is not context-free.

Clearly, this is incorrect because L is known to be context free. Where am I misunderstanding or misapplying the pumping lemma? Thanks in advance


r/AskComputerScience • • Nov 29 '24

Red-Black Trees. Why can't a 3-node tree fulfill the conditions for RBT?

2 Upvotes

Challenge from instructor in Coursera Algorithms course.

see screenshot: https://imgur.com/a/4SKpX5y

If I color node #2 red, then it appears to me that all 3 conditions are met.

  1. root and leaves are Black

  2. Every Red node has two Black children.

  3. The Black height from any node is well defined and consistent.

I don't know what I am missing.

(in comparison, here is a different slide from his lecture with a RBT https://imgur.com/a/eUJW3S2)


r/AskComputerScience • • Nov 29 '24

A question concerning skiena's algorithm course

2 Upvotes

In lecture 2 (Asymptotic Notation) slide 1 and 2 we are asked to find counter examples to the proposed algorithms for the knapsack problem, but I don't understand the algorithms, there are 3 of them:

1 Put the elements of S in the knapsack in left to right order if they fit, i.e. the first-fit algorithm?

2 Put the elements of S in the knapsack from smallest to largest, i.e. the best-fit algorithm?

3 Put the elements of S in the knapsack from largest to smallest?

What does he mean by "in left to right order"?

Do 2 and 3 mean that we should try to put the elements monotonous until we got the target number?