Question

In: Computer Science

Write pseudocode (C++) that will create a 50 x 50 grid of nodes and an output...

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

Solutions

Expert Solution

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


Related Solutions

write pseudocode for the following problems not c code Pseudocode only Write a C program to...
write pseudocode for the following problems not c code Pseudocode only Write a C program to print all natural numbers from 1 to n. - using while loop Write a C program to print all natural numbers in reverse (from n to 1). - using while loop Write a C program to print all alphabets from a to z. - using while loop Write a C program to print all even numbers between 1 to 100. - using while loop...
Create a kD tree with: x-nodes and y-nodes -- and maintain the following two properties: The...
Create a kD tree with: x-nodes and y-nodes -- and maintain the following two properties: The children of an x-node are y-nodes The children of a y-node are x-nodes Each type of node uses a different comparison to order points. This causes different levels of the tree to compare points differently, using the following rules: For every x-node: All descendants in the left subtree have a smaller x-coordinate than the point stored at the node. Visually, all descendant points are...
Write a  program in c++ using a map to create the following output. Here is the list...
Write a  program in c++ using a map to create the following output. Here is the list of students: 100: Tom Lee 101: Joe Jones 102: Kim Adams 103: Bob Thomas 104: Linda Lee Enter a student an ID to get a student's name: ID:  103 students[103] - Bob Thomas # of students: 5 Delete a student (Y or N)?  Y Enter ID of student to be deleted:  103 Here is the list of students after the delete: 100: Tom Lee 101: Joe Jones...
C Program and pseudocode for this problem. Write a C program that plays the game of...
C Program and pseudocode for this problem. Write a C program that plays the game of "Guess the number" as the following: Your program choose the number to be guessed by selecting an integer at random in the rang of 1 to 1000. The program then asks the use to guess the number. If the player's guess is incorrect, your program should loop until the player finally gets the number right. Your program keeps telling the player "Too High" or...
Backtracking Write a program in c++ that moves an asterisk ‘*’ in a grid of 10x10...
Backtracking Write a program in c++ that moves an asterisk ‘*’ in a grid of 10x10 cells. Your program should start with * on position (2,3) i.e. 3rd column of 2nd row. After printing the grid and ‘*’, your program will ask user if he wants to move the ‘*’ Up, Down, Left or Right. If user presses ‘U’, ‘D’, ‘L’ or ‘R’, your program will move the ‘*’ one position accordingly. If user presses ‘Q’, your program should terminate....
write pseudocode not c program If- else programming exercises 1.    Write a C program to find...
write pseudocode not c program If- else programming exercises 1.    Write a C program to find maximum between two numbers. 2.    Write a C program to find maximum between three numbers. 3.    Write a C program to check whether a number is negative, positive or zero. 4.    Write a C program to check whether a number is divisible by 5 and 11 or not. 5.    Write a C program to check whether a number is even or odd. 6.    Write...
Write a Python program that: Create the algorithm in both flowchart and pseudocode forms for the...
Write a Python program that: Create the algorithm in both flowchart and pseudocode forms for the following requirements: Reads in a series of positive integers,  one number at a time;  and Calculate the product (multiplication) of all the integers less than 25,  and Calculate the sum (addition) of all the integers greater than or equal to 25. Use 0 as a sentinel value, which stops the input loop. [ If the input is 0 that means the end of the input list. ]...
Write a C++ program that will read in the number of nodes (less than 10) and...
Write a C++ program that will read in the number of nodes (less than 10) and a adjacency relation representing a graph. The program will create an adjacency matrix from the adjacency relation. The program will then print the following items: 1. Print the adjacency matrix 2. Determine if there are any isolated nodes and print them 3. Determine if an Euler path exists Sample run output Please input the number of nodes: 6 Please input the adjacency relation: {(1,2),(1,5),(2,1),(2,3),(3,2),(3,4),(4,3),(4,5),(5,1),(5,4)}...
Write a C++ program that will read in the number of nodes (less than 10) and...
Write a C++ program that will read in the number of nodes (less than 10) and a adjacency relation representing a graph. The program will create an adjacency matrix from the adjacency relation. The program will then print the following items: 1. Print the adjacency matrix 2. Determine if there are any isolated nodes and print them 3. Determine if an Euler path exists Sample run (to make program output more clear, I have put it in boldface): Please input...
Write a C++ program will read in the number of nodes and a binary relation representing...
Write a C++ program will read in the number of nodes and a binary relation representing a graph. The program will create an adjacency matrix from the binary relation. The program will then print the following : 1. The adjacency matrix 2. Determine if there are any isolated nodes and print them 3. Determine if an Euler path exists and said so. The sample run of the program is as follows. The output should just like this: It starts by...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT