Insertion of an element in a linear array, Data Structure & Algorithms

Assignment Help:

To delete an element in the list at the end, we can delete it without any difficult. But, assume if we desire to delete the element at the straining or middle of the list, then, we ought to rewrite all the elements after the position where the element that ought to be deleted exists. We ought to shift (r+1)th element to rthposition , where 'r' refer for position of deleted element in the list, the (r + 2)th element to (r + 1)th position,  and it will continue till the (n)th element to ( n-1 )th position, where n refer to the number of elements in the list, and after that the count is decremented.

From the above instance, if we desire to delete an element '44' from the list. We ought to shift 55 to the 4th position, 66 to the 5th position, and 77 to the 6th position.

Before deletion

 

Count  1      2         3               4         5           6            7

11

22

33

44

55

66

77

 

Step 1

Count     1       2            3       4               5           6            7

11

22

33

55

55

66

77

 

Step 2

Count     1     2            3          4           5             6            7

11

22

33

55

66

66

77

 

Step 3

Count     1        2         3          4             5            6

11

22

33

55

66

77

 

 


Related Discussions:- Insertion of an element in a linear array

2 way merge sort, merge sort process for an example array {38, 27, 43, 3, 9...

merge sort process for an example array {38, 27, 43, 3, 9, 82, 10}. If we take a closer look at the diagram, we can see that the array is recursively divided in two halves till the

How do you rotate a binary tree, How do you rotate a Binary Tree?  Rot...

How do you rotate a Binary Tree?  Rotations in the tree: If after inserting a node in a Binary search tree, the balancing factor (height of left subtree - height of right

Which sorting algorithms not have running time of o (n2), Which sorting al...

Which sorting algorithms does not have a worst case running time of  O (n 2 ) ? Merge sort

Explain best - fit method, Best - Fit Method: - This method obtains the sma...

Best - Fit Method: - This method obtains the smallest free block whose  size is greater than or equal to get such a block by traversing the whole free list follows.

Rules for abstract data type-tree, null(nil) = true                     // ...

null(nil) = true                     // nil refer for empty tree null(fork(e, T, T'))= false   //  e : element , T and T are two sub tree leaf(fork(e, nil, nil)) = true leaf(

Illustrate the back face detection method, Illustrate the Back Face Detecti...

Illustrate the Back Face Detection Method A single polyhedron is a convex solid, which has no external angle between faces less  than 180° and there is a simple object space me

C, padovan string

padovan string

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd