Recursive-Array

  • #1
28
2

Summary:

to walk around the array

Main Question or Discussion Point

I want to write code walk around the array recursively. For some reason I cannot share my code. Let's say I have a array like this: arr[4], I want to look 012 123 013 or 01 12 23 02 03 13. In code I write I can look 012 123 or 01 12 23 but I cannot look 013 or 02 03 13. What algorithm should I develop?
 

Answers and Replies

  • #2
Filip Larsen
Gold Member
1,256
183
  • Like
Likes FactChecker and Klystron
  • #3
33,503
5,190
This is not a particularly recursive algorithm, so perhaps you can elaborate on why you think you need recursion (that is, what problem are you trying to solve)?
"If the only tool you have is a hammer, everything begins to look like a nail."
The OP has started a number of threads with the goal of trying to solve some problem by the use of recursion. For some of the problems, recursion isn't a viable solution.
 
  • Like
Likes jim mcnamara
  • #4
jim mcnamara
Mentor
3,873
2,255
@Mark44 - that is a great concept-
"If the only tool you have is a hammer, everything begins to look like a nail."
Where did you encounter that?
 
  • #5
33,503
5,190
@Mark44 - that is a great concept-
"If the only tool you have is a hammer, everything begins to look like a nail."
Where did you encounter that?
It might have been in a programming class I took back in the early 80s.
 
  • #6
Svein
Science Advisor
Insights Author
2,068
662
I started to sketch such a recursive program, but I had not written more than 7 or 8 lines before i stopped. I suddenly discovered that my mantra in programming was not satisfied - I had not written a requirement spec (what is the desired output of the program) or a program design (how do we go about solving this using a recursive method). And then I found out that it was too much work anyhow.
 
  • #7
Svein
Science Advisor
Insights Author
2,068
662
One thing I thought of late yesterday night: You need a "sentinel" (meaning end-of-sequence) in your list (otherwise you will only get resulting sequences the same size as your list of symbols).
 

Related Threads on Recursive-Array

Replies
39
Views
2K
  • Last Post
Replies
12
Views
80K
Replies
1
Views
186
  • Last Post
Replies
10
Views
3K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
14
Views
4K
  • Last Post
Replies
10
Views
5K
  • Last Post
Replies
5
Views
2K
  • Last Post
Replies
3
Views
30K
Replies
16
Views
3K
Top