In: Computer Science
Write pseudocode (C++) that will create a 50 x 50 grid of nodes and an output function that displays the row and column of each node in the grid after it is created.
-Creating the grid
-Printing the grid
-Deleting the grid
• For each function
o Determine the parameters and return type
o Detail the step-by-step logic that the function will perform
PSEUDOCODE
data type** create_grid(passing n as parameter){ //here n=50 declare pointers: p, row_1 and row_2 row_1 = head // creating first row of grid for (index 1 to n) p = new node //row_2 point to node to the right of curent node (row_1) //link left and right connect p left to row_1 connect row_1 right to p end loop reset row_1 to head of grid //create row_2 - n for(index 2 to n) //create first node in row and link it up/down row_2 = new node connect row_2 up to row_1 connect row_1 down to row_2 //hold beginning of row move row_1 to row_2 //create rest of nodes on row for (index 2 to n) //row_2 will always point to previous node in row p = new node connect p left to previous node connect previous node right to p connect p up to node above (row_2 up right) connect node above p down to p move row_2 to the right end loop end loop
return grid
}
void print_grid( &rows, &columns){
for (index1: 1 to rows)
print("|")
for(index2: 1 to columns)
print("-")
}
void delete_grid( &rows, &columns){
for(index 1 to n){
delete grid[index]
delete grid;
}
**For all the three functions, we can see the return type written before function and parameters are passes through the function