0% found this document useful (0 votes)
20 views

1) Insert Value at The End of The Array in INDEX'

The document describes algorithms for inserting, deleting, and retrieving values from an array at different indices. It includes steps to insert a value at the end of the array, insert a value before, after, or at a given index, and delete a value at a given index. Pseudocode uses variables like N for array size, K for the given index, J as a counter, and shifts elements in the array to make space for insertion or fill in space after deletion.

Uploaded by

Sehar Fatima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

1) Insert Value at The End of The Array in INDEX'

The document describes algorithms for inserting, deleting, and retrieving values from an array at different indices. It includes steps to insert a value at the end of the array, insert a value before, after, or at a given index, and delete a value at a given index. Pseudocode uses variables like N for array size, K for the given index, J as a counter, and shifts elements in the array to make space for insertion or fill in space after deletion.

Uploaded by

Sehar Fatima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1) Insert Value at the end of the Array In ‘INDEX’

1) Start
Insert New value In Index
2) Set N=Size of Array
3) N=N+1;
4) LA[N-1]=12; 1 2 3 4 5 12
5) END
0 N-1

Insert Value at the Given ‘INDEX’ in the Array


1. Start
Insert New value In Index
2. Set N=Size of Array
3. Set K= Given location //K=3
J J+1
4. Set=J=N 1 2 3 4 5
J+1
5. N=N+1; J

6. Repeat Step 7 & 8 While (J>=K-1) 1 2 3 4 5

7. LA[J+1]=LA[J]; 1 2 3 4 5

4>=2 1 2 3 4 5
8. J=J-1; 3>=2 10 2 12 3 4 5
K-1
9. LA[K-1]=12; 2>=2
N-1
10. END 1>=2 false
Insert Value at the Before Given ‘INDEX’ in the Array
11. Start
Insert New value In Index
12. Set N=Size of Array
K=3
13. Set K= Given location //K=3
J J+1
14. Set=J=N 1 2 3 4 5
J+1
15. N=N+1; J
1 2 3 4 5
16. Repeat Step 7 & 8 While (J>=K-
1 2 3 4 5
2)
17. 1 2 3 4 5
18. LA[J+1]=LA[J]; 1 2 3 4 5
4>=3-2
19. J=J-1; 3>=3-2 1 12 2 3 4 5
20. LA[K-2]=12; 2>=3-2
21. END 0
1>=3-2 K-2 K-1 N-1
0>=3-2false

K=3;

K=3-2

K=1

J=4
Insert Value at the After Given ‘INDEX’ in the Array
22. Start
Insert New value In Index
23. Set N=Size of Array
24. Set K= Given location //K=3
J J+1
25. Set=J=N 1 2 3 4 5
J+1
26. N=N+1; J

27. Repeat Step 7 & 8 While (J>=K) 1 2 3 4 5

28. LA[J+1]=LA[J]; 1 2 3 4 5
29. J=J-1; 1 2 3 12 4 5
4>=3
30. LA[K]=12;
3>=3
31. END 0 K-1
2>=3 false N-1
K
Delete Value at the Given ‘INDEX’ in the Array
32. Start
Insert New value In Index
33. Set N=Size of Array
34. Set K= Given location //K=3
J J+1
35. Set=J=k-1 K-1 1 2 3 4 5
36. Repeat Step 7 & 8 While (J<N)
1 2 4 5 Delete J+1
J
Replace 3 with 4
37. LA[J]=LA[J+1]; 1 2 4 5
1 2 4 5 Delete
38. J=J+1; 1 2 4 5 Delete
2<4
39. N=N-1;
3<4
40. END 0
4<4 false N-1

1 2 4 5
(A*(B+C))
Symbol Scanned Stack Post fixed
1 ( (
2 A ( A
3 * (* A
4 ( (*( A
5 B (*( AB
6 + (*(+ AB
7 ) (*(+) AB+
8 ) (*) AB+*
(A*(B+C)) IN post fixed AB+*

((A/B)+C/D)
Symbol Scanned Stack Post fixed
1 ( (
2 ( ((
3 A (( A
4 / ((/ A
5 B ((/ AB
6 ) ((/) AB
7 + (+ AB/
8 C (+ AB/C
9 / (+/ AB/C
10 D (+/ AB/CD
11 ) (+/) AB/CD/+
((A/B)+C/D) IN post fixed AB/CD/*

You might also like