Question: AIM: Write a program for Traversing in Linear Array: Description: It means processing or visiting each element in the array exactly once for one operation.

 AIM: Write a program for Traversing in Linear Array: Description: It

means processing or visiting each element in the array exactly once for

AIM: Write a program for Traversing in Linear Array: Description: It means processing or visiting each element in the array exactly once for one operation. Let 'A' is an array stored in the computer's memory and we want to display the contents of A, then it has to be traversed i.e. by accessing and processing each element of 'A' exactly once. Linear array A with lower boundary LB (0 in C++) and upper boundary ( UB = N - 1 in C++) where N is the number of values stored in the array. If the array is empty then N will be equal 0. SIZE is the total locations/positions available in array. This algorithm traverses A applying process to each element of A. SIZE = 10 Lower Bound N = 5 A[O] A[1] A[3] A[6] 1151 A[7] A[8] A[9 A[21 12 5 A[41 15 Algorithm: (Traverse a Linear Array) Here A is an array has N elements stored in it, with lower bound LB=0 and upper bound UB= N - 1. 1. K = LB and UB = N - 1 2. Repeat Steps 3 and 4 while K S UB. 3. Apply PROCESS to A[k]. 4. K = K+1. [End of Step 2 loop.] 5. End. The alternate algorithm using for-loop to traverse A: Algorithm: (Traverse a Linear Array) This algorithm traverse a linear array A with lower bound LB=0 and upper bound UB= N - 1. 1. Repeat for K = LB to UB Apply PROCESS to A[K]. [End of loop]. 2. Fnd. AIM: Write a program to Delete an Item from Linear Array: Description: Deletion refers to the operation of removing one of the element from the array A Deleting an item at the end of the array presents no difficulties. But, deleting an item from beginning or somewhere in the middle of array would require that each subsequent element be moved one location upward in order to fill up the array. The following algorithm deletes the Kth element from a linear array A with N values stored in it. Here A is a Linear Array with SIZE locations, N is the number of total values stored in A and K is a positive integer such that K

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!