title: algorithm for 2D array that represents the topographic map of geographic surface
body: <p>I'm having difficulty figuring out what to do with the following problem</p>
  
  <p>The input will be 2D array A[n][n] numbers, representing the topographic map of the geographic surface. Also among the input will be a starting location (r,c). referring to entry A[r][c]</p>
  
  <p>If you were planning hiking trails you would be bound by the differences in elevation between neighboring entries. A person could traverse between 2 adjacent locations, if their elevations differ by no more than 2). Adjacency follows just the 4 standard compass directions, (<strong>so I assume no diagonals).</strong> Therefore , a point on the map is considered reachable if it is traversable from A[r][c] through any sequence of adjacent entires.</p>
  
  <p>Write an algorithm that computes all of the reachable locations. The output will be another 2D array R[n][n] with true/fals values. (I assume true means reachable, false means unreachable)</p>
  
  <p><strong>If i understand this question correctly, I can create following matrix.
  (suppose A[10][10] looks like this from A[0][0]:)</strong></p>
  
  <p>50 51 54 58 60 60 60 63 68 71</p>
  
  <p>48 52 51 59 60 60 63 63 69 70</p>
  
  <p>44 48 52 55 58 61 64 64 66 69</p>
  
  <p>44 46 53 52 57 60 60 61 65 68</p>
  
  <p>42 45 50 54 59 61 63 63 66 70</p>
  
  <p>38 42 46 56 56 63 64 61 64 62</p>
  
  <p>36 40 44 50 58 60 66 65 62 61</p>
  
  <p>36 39 42 49 56 62 67 66 65 60</p>
  
  <p>30 36 40 47 50 64 64 63 62 60</p>
  
  <p>50 50 50 50 50 50 50 50 50 50</p>
  
  <p><strong>Both south and east are traversable from A[0][0] so reachable entries would be:</strong> </p>
  
  <p><strong>50</strong> <strong>51</strong> 54 58 60 60 60 <strong>63</strong> 68 71</p>
  
  <p><strong>48 52</strong> <strong>51</strong> 59 60 60 <strong>63 63</strong> 69 70</p>
  
  <p>44 48 <strong>52</strong> 55 58 61 <strong>64 64 66</strong> 69</p>
  
  <p>44 46 <strong>53</strong> <strong>52</strong> 57 60 60 61 <strong>65</strong> 68</p>
  
  <p>42 45 50 <strong>54</strong> 59 61 63 63 <strong>66</strong> 70</p>
  
  <p>38 42 46 <strong>56</strong> <strong>56</strong> 63 64 61 <strong>64 62</strong></p>
  
  <p>36 40 44 50 <strong>58</strong> <strong>60</strong> 66 65 <strong>62 61</strong></p>
  
  <p>36 39 42 49 <strong>56</strong> <strong>62</strong> 67 66 65 <strong>60</strong></p>
  
  <p>30 36 40 47 50 <strong>64</strong> <strong>64</strong> <strong>63 62 60</strong></p>
  
  <p>50 50 50 50 50 50 50 50 50 50</p>
  
  <p>so I can conclude that my resulting array should be</p>
  
  <p><strong>1 1</strong> 0 0 0 0 0 <strong>1</strong> 0 0</p>
  
  <p><strong>1 1 1</strong> 0 0 0 <strong>1 1</strong> 0 0</p>
  
  <p>0 0 <strong>1</strong> 0 0 0 <strong>1 1 1</strong> 0</p>
  
  <p>0 0 <strong>1 1</strong> 0 0 0 0 <strong>1</strong> 0</p>
  
  <p>0 0 0 <strong>1</strong> 0 0 0 0 <strong>1</strong> 0</p>
  
  <p>0 0 0 <strong>1 1</strong> 0 0 0 <strong>1 1</strong> </p>
  
  <p>0 0 0 0 <strong>1 1</strong> 0 0 <strong>1 1</strong></p>
  
  <p>0 0 0 0 <strong>1 1</strong> 0 0 0 <strong>1</strong></p>
  
  <p>0 0 0 0 0 <strong>1 1 1 1 1</strong></p>
  
  <p>0 0 0 0 0 0 0 0 0 0</p>
  
  <p>I want to implement this in c code but i think its improper to ask for the code here. My plan is to implement this in pseudocode first then implementing in c code, which I will try doing it by myself =). I'm not sure as to where to start with my pseudocode. Can anyone please clarify this?</p>
  
  <p>Thank you very much!</p>
  
  <p>p.s just edited my matrix</p>