• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

feedback designing a simple algorithem

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm reading dietel's java how to program and it talks about the the top down, stepwise refinement and using psudocode.

I decided to solve my next Euler problem(11) using this approach. While I know I could easily solve this problem (quicker even) without using this approach I am try to embrace good design techniques, because I am completely self taught , but aspire to one day be a professional.

my psudocode is below (3 stages of refinement) I want to know if I grasped the point of psudocode and stepwise refinement any advice/constructive criticism is much appreciated.

 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That looks a good example of how to refine an algorithm

One thing to beware: If you are going down, you must stop three rows from the bottom. If you are going right, you must stop three columns from the right.
Another thing which may make things quicker: If you go up for four squares, that give the same result as going down from three rows higher. That means you do not need to check all eight directions, only four of them. You can start going →, ↓ and ↘ from the top left corner, but only start ↙ from three columns to the right.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Branden Bobo wrote:my psudocode is below (3 stages of refinement) I want to know if I grasped the point of psudocode and stepwise refinement any advice/constructive criticism is much appreciated.


Well, I'm afraid I'm not familiar with the book; but I thought that the point of pseudocode was not to include implementation.

ie, You don't describe how something is going to be done, you describe what is going to be done - at least that's the way I was taught - so my pseudocode would never include references to things like Scanner's. To me, you should be able to translate pseudocode into any (or almost any) language.

Example - Suppose I had a piece of high-level pesudocode with the line:
Load grid data from file.

I might 'refine' that by breaking down the action, eg:but that's just the way I do it, and your book may have a completely different notion of 'refinement'.

BTW, one of the businesses of pseudocode is to allow you to refine the logic without resorting to actual code; and, as Campbell already pointed out, yours still contains a fair bit of redundancy:
1. You don't have to check all directions.
2. You don't have to check all 400 cells.

HIH

Winston
 
Branden Bobo
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks you everyone for the feedback
 
reply
    Bookmark Topic Watch Topic
  • New Topic