Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Elevation in 2D arrays (C++) DATA FILE: http://pastebin.com/DTQ9kenP Goals: Usin

ID: 3568450 • Letter: E

Question

Elevation in 2D arrays (C++)

DATA FILE: http://pastebin.com/DTQ9kenP

Goals: Using 2-dimensional arrays.

Problem: Navigation over a terrain can be an important concept. Usually you want to avoid high areas (peaks) and low areas (valleys). For this problem, you may assume the terrain that you want to navigate over may be represented as a 2-dimensional grid of cells. You are to determine the number of peaks and valleys in this terrain as well as give the location of these peaks and valley. A peak is defined as a cell for which all eight neighbors are lower than the cell being considered. A valley is defined as a cell for which all eight neighbors are higher than the cell being considered. An example grid is given below with some of the peaks in bold and some of the valleys underlined. Note that no cell on the perimeter may be considered a peak or valley.

Your main function should

Example Grid (6 rows with 8 columns). Peaks are given in bold and valleys are underlined. You could use this array as test data.

25        58        63        23        21        34            21        50

32        45        43        40        41        32            30        27

34        40        38        39        36        28            30        35

40        45        42        48        32        34            29        32

39        39        40        42        47        49            27        30

31        31        31        32        32        33            44        35

Carefully consider what each function is supposed to do, what it needs to receive from the function call and what it will return to the function call. Do not anything to the function that it does not need to complete its task.

language : c++

Explanation / Answer

package com.nbethi.basins; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.HashMap; import java.util.StringTokenizer; public class BasinUtil { public static void main(String args[]) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Please enter square size : "); String line = reader.readLine(); int size = Integer.parseInt(line); int area[][] = new int[size][size]; for (int x = 0; x
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote