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...
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...
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...
Given two unsorted arrays of integers. a) Write a pseudocode algorithm which will output only the...
Given two unsorted arrays of integers. a) Write a pseudocode algorithm which will output only the integers not common to both arrays. When writing pseudocode, consider that no implementation for data structures or algorithms exist. b) Implement your algorithm in Modern C++
Suppose that the array X consists of real numbers X[1], X[2], …, X[N]. Write a pseudocode...
Suppose that the array X consists of real numbers X[1], X[2], …, X[N]. Write a pseudocode program to compute the minimum of these numbers.
C++ Questions What is the output of the following pseudocode code: ages = new List Append(ages,...
C++ Questions What is the output of the following pseudocode code: ages = new List Append(ages, 55) Append(ages, 88) Append(ages, 66) Print(ages) A. 55, 66, 88 B. 55, 88, 66 C. 55, because there is no loop D. 66, because there is no loop E. None of the above. QUESTION 2 Type the list after the given operations. Each question starts with an empty list. Type the list as: 5, 7, 9 Append(list, 3) Append(list, 2) Append(list, 1) Remove(list, 3)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT