Question

Assume the arrays nbrArray1 and nbrArray2 each have 10 elements. Design an algorithm that copies the...

Assume the arrays nbrArray1 and nbrArray2 each have 10 elements. Design an algorithm that copies the values in nbrArray1 to nbrArray2 using a FOR Loop.

Please write in pseudocode, thanks

Homework Answers

Answer #1

Algorithm:

1. START

1 STEP: Given Arrays nbrArray1 and nbrArray2.

2 STEP: Let m= nbrArray1[10] is the given size of Array.

3 STEP: Let n= Elements of nbrArray1 like ( 1, 5,4,8,7,11,9,21,-3,14).

4 STEP: Let k= nbrArray2[10] to store the copy of nbrArray1

5 STEP: To copy all elements of nbrArray1 to nbrArray2 , we need to iterate every element of nbrArray1.

6 STEP: Hence a FOR loop should iterate from 0 to m which is the size of the given Array like ( For i=0; i<m; i++)

7 STEP: In the loop assign current array of m to k like k[i]=m[i]

8 END.

PSEUDOCODE:

Procedure copy_array( nbrArray1, nbrArray2)

SET index to 1

FOR Each value in nbrArray1 Do

nbrArray2[index]= nbrArray1[index]

INCREMENT index

END FOR

end procedure

  

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write pseudocode for a simple algorithm for addition of two n-digit numbers (one of them could...
Write pseudocode for a simple algorithm for addition of two n-digit numbers (one of them could be &lt; n digits with 0&#39;s appended to the left) in base-10, as follows. Assume the digits are stored in arrays A and B, with A[1] and B[1] being the rightmost digits and A[n] and B[n] being the leftmost digits. Use a for loop to go from right to left adding the digits and keeping track of the carry. Now, here&#39;s the real task:...
Briefly distinguish between Arrays and Linked List. Write an algorithm for each as well as develop...
Briefly distinguish between Arrays and Linked List. Write an algorithm for each as well as develop computer programs that implement each of them. Show the results of your output including your code.
Assignment 3 Chapter 2: Algorithm Discovery and Design More about Pseudocode Design an algorithm that is...
Assignment 3 Chapter 2: Algorithm Discovery and Design More about Pseudocode Design an algorithm that is given a positive integer N and determines whether N is a prime number, that is, not evenly divisible by any value other than 1 and itself. The output of your algorithm is either the message ‘not prime’, along with a factor of N, or the message ‘prime ‘ Many excellent simulations of sorting algorithms are available, examine them if they have questions about this...
One of the components of Design by Contract is the invariants. The following function copies one...
One of the components of Design by Contract is the invariants. The following function copies one array to another. What is invariant in this function? please be quick. i dont have enough time thanks
Logic and Design Programming In Syntax Pseudocode Algorithm Workbench 1. Design a simple function named timesDozen...
Logic and Design Programming In Syntax Pseudocode Algorithm Workbench 1. Design a simple function named timesDozen that accepts an Integer argument into a parameter named nbr. When the function is called, it should return the value of its argument multiplied times 12. 2. Assume that a program has two String variables named alpha and bravo. Write - a pseudocode statement that assigns an all uppercase version of alpha to the bravo variable. Book name is Starting Out with Programming Logic...
Test each algorithm (Counting Sort, Radix Sort, and Bucket Sort algorithms) on three different arrays of...
Test each algorithm (Counting Sort, Radix Sort, and Bucket Sort algorithms) on three different arrays of 1000 elements each with the following properties: By the way: To perform bucket sort the right way, convert the array elements to a value between 0 and 1 Array1: integers only in the range 0 through 999, already sorted in increasing order Array2: integers only in the range 0 through 999, already sorted in decreasing order Array3: integers only in the range 0 through...
Please answer in C++ with the correct files (in bold). Thanks! Write a program that creates...
Please answer in C++ with the correct files (in bold). Thanks! Write a program that creates three identical arrays, list1, list2, and list3, of 5000 elements. The program then sorts list1 using bubble sort, list2 using selection sort, and list3 using insertion sort and outputs the number of comparisons and item assignments made by each sorting algorithm. Please use the file names listed below since your file will have the following components: Ch18_Ex15.cpp searchSortAlgorithms.h
Write an iterative algorithm in Java-like pseudocode for printing a singly linked list in reverse in...
Write an iterative algorithm in Java-like pseudocode for printing a singly linked list in reverse in O(N) time. You can use as much extra space as you need. The original list pointers CAN NOT BE MODIFIED. State in big-O notation how much extra space is used by this algorithm. Write another iterative algorithm in Java-like pseudocode for printing a singly linked list in reverse using O(1) extra space. The original list pointers CAN NOT BE MODIFIED. This algorithm can have...
C++ Design a class named Computer that holds the make, model, and amount of memory of...
C++ Design a class named Computer that holds the make, model, and amount of memory of a computer. Include methods to set the values for each data field, and include a method that displays all the values for each field. Create the class diagram and write the pseudocode that defines the class. Pseudocode help please
Create a class called BirthYear. It should only have two member, both of them arrays. One...
Create a class called BirthYear. It should only have two member, both of them arrays. One of type string called Names. The second of type int called BirthYears. in your main class create a StudentBirthYear object. Make sure both arrays are of the size 10. Add ten different names and ten different birth years. Then display each name with its birth year using only 1 for loop. (You can display in a for loop as well as a foreach loop,...