Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Two Dementional Spiral Fill

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How could i write two methods... one recursive and one not to fill a two dementional array of size n.

ex. 5 x 5 array

0 1 2 3 4
15 16 17 18 5
14 23 24 19 6
12 22 21 20 7
12 11 10 9 8


the non-recursive routine would be like void spiralFill(int [][]a, int n) where it spiral fills the first n rows and columns
 
Marshal
Posts: 68985
275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Please post what you have got so far; we don't simply hand out answers to that sort of question. Read this.
I am not sure what the difference between spiral filling and ordinary filling is.
 
Campbell Ritchie
Marshal
Posts: 68985
275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I have worked out what you mean by spiral filling. I tried it and failed. It's bl**d* difficult.
 
Amateurs built google. Professionals built the titanic. We can't find the guy that built this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic