Creating Words of Length K from {1,...,k}: A Recursive Approach

  • Thread starter MathematicalPhysicist
  • Start date
In summary, the conversation discusses finding the number of words of length k that can be created from the set {1,...,k} with an even number of 1s. The solution involves using a recursion formula and considering strings of length k as being formed by appending a digit to a string of length k-1 with an even number of 1s. The speaker also mentions a solution using power series, but is having trouble understanding it. They mention a specific equation involving a generating function, but do not understand how it was derived.
  • #1
MathematicalPhysicist
Gold Member
4,699
371
how many words of length k can you create from {1,...,k} such that 1 appears even number of times?
well, for k=0 we have 1, for k=1 we have zero, and for k=2 we have one.
i thought to use here a recursion formula.
but not quite sure how to do so, i mean if k>=3, and a_k stands for the number of legitiamte words, then if no 1 appears in the word then we have (k-1)^k words, let's assume that in a_k-1 1 appears even number times then for the the last number we have (k-1) choices, so i think that the equation should be:
a_k=(k-1)*a_k-1+(k-1)^k
am i correct here?
now if this is correct then how find a suitable private answer for non homogenoues part?
 
Physics news on Phys.org
  • #2
my mistake for a_2 we have two options 22 and 11.
 
  • #3
You have written that the way to make a word of length k with an even number of 1s in it is to append a non-1 to a string of length k-1 with an even number of 1s. This is not true. Plus, you have over counted - why treat the string with no 1s in it separately and therefore counted it twice?
 
  • #4
so how would you go to solve this?
i saw a solution with power series, but didn't understand it.
 
  • #5
You should try to learn how to use power series (generating functions) - they are incredibly powerful.

If you really want a recurrence relation, then do the naive thing.

A string of length k is gotten by adding a digit to a string of length k-1. In order for this string of length k to have an even number of 1s, then the shorter string must have an even number of 1s and you append a non-1, or it has an odd number of 1s and you append a 1. So count them. Hint: do you need to count the number of strings with an odd number of 1s in or is there a way to write that in terms of strings with an even number of 1s?
 
  • #6
yes i know how to use power series, my problem is that i don't undersatnd the answer.
I'm given that for
[tex]F(x)=\sum_{n>=0} a_n*x^n=(1+x^2/2!+x^4/4!+...)(1+x+x^2/2!+...)^{(k-1)}[/tex] where a_n is the sequence we searching for.
but i don't understand how did they got to this, can you explain?


p.s
iv'e learned already generating functions, but still i don't see how arrive to this equation.
 
Last edited:

1. What is the purpose of creating words of length K from {1,...,k}?

The purpose of creating words of length K from {1,...,k} is to explore different ways of generating words using a recursive approach. This can be useful in various fields such as linguistics, computer science, and mathematics. It also helps in understanding the principles of recursion and its applications.

2. Can you explain the recursive approach in creating words of length K?

The recursive approach in creating words of length K involves breaking down the problem into smaller subproblems and then combining the solutions of those subproblems to form the final solution. In this case, we start with a base case (K=1) and then build on it by adding one more character at each step until we reach the desired length K.

3. Is this approach efficient in generating words of length K?

Yes, the recursive approach is efficient in generating words of length K. As we break down the problem into smaller subproblems, we eliminate the need for repetitive calculations and reduce the complexity of the algorithm. This results in better time and space efficiency compared to other approaches.

4. How can we use this approach in practical applications?

This approach can be used in various practical applications such as generating passwords, creating unique identifiers, and generating test cases in software development. It can also be applied in natural language processing tasks such as word prediction and word generation in predictive text algorithms.

5. What are the limitations of this approach?

One limitation of this approach is that it may not be suitable for generating words of very large lengths due to the recursive nature of the algorithm. It may also become computationally expensive for larger values of K. Additionally, the approach may not be applicable in cases where the characters or symbols used in the word are restricted or have specific rules.

Similar threads

  • Set Theory, Logic, Probability, Statistics
Replies
20
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
1K
  • Topology and Analysis
Replies
2
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
10
Views
793
  • Set Theory, Logic, Probability, Statistics
2
Replies
42
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
484
  • Engineering and Comp Sci Homework Help
Replies
3
Views
934
  • Set Theory, Logic, Probability, Statistics
2
Replies
36
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
Back
Top