-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample_program_arrayOperations.cpp
114 lines (87 loc) · 3.21 KB
/
sample_program_arrayOperations.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include<iostream>
#include<conio.h>
#include "arrayoperations.h"
using namespace std;
//for testing purpose
int main()
{
int ArrayInput[10] = {1,2,2,2,3,3,4,5};
Array a;
int count=8;
// showing initial array
cout<<"\ninitial array - \n";
a.traverseArray(ArrayInput , count);
cout<<endl<<endl;
// after inserting 10 at position 5
cout<<"after inserting 10 at the position 5 - \n";
a.insertPosValue(ArrayInput , count , 10 , 5);
a.traverseArray(ArrayInput , count);
cout<<endl<<endl;
// after deleting value at position 5
cout<<"after deleting value at position 5 - \n";
a.deletePosValue(ArrayInput , count , 5);
a.traverseArray(ArrayInput , count);
cout<<endl<<endl;
// after deleting the value = 4
cout<<"after deleting value = 4 by finding it , only deleted first occurence as deleteAll is set to false - \n";
a.deleteValue(ArrayInput , count , 4 , false);
a.traverseArray(ArrayInput , count);
cout<<endl<<endl;
// after reversing the array
cout<<"after reversing the array - \n";
a.reverseArray(ArrayInput , count);
a.traverseArray(ArrayInput , count);
cout<<endl<<endl;
// after sreaching for value 5 after using normal search
cout<<"searching value = 5 using normal search - \n";
cout<<a.normalSearch(ArrayInput , count , 5);
cout<<endl<<endl;
// after searching for value 5 using binary search
cout<<"searching value = 1 using binary search - \n";
cout<<a.binarySearch(ArrayInput , count , 1);
cout<<endl<<endl;
// array after sorting it using bubble sort
cout<<"sorting array using bubble sort - \n";
a.bubbleSort(ArrayInput , count);
a.traverseArray(ArrayInput , count);
cout<<endl<<endl;
// new array for duplicate element function
int ArrayInput2[10] = {1,2,2,2,3,3,4,5};
count=8;
// showing the new array
cout<<"new array - \n";
a.traverseArray(ArrayInput2 , count);
cout<<endl<<endl;
// array after removing duplicate elements
cout<<"array after removing duplicate elements - \n";
a.duplicateElementRemover_fromSortedArray(ArrayInput2 , count);
a.traverseArray(ArrayInput2 , count);
cout<<endl<<endl;
// new array for duplicate element function 2
int ArrayInput3[10] = {1,2,2,2,3,3,4,5};
count=8;
// showing the new array
cout<<"new array - \n";
a.traverseArray(ArrayInput3 , count);
cout<<endl<<endl;
// array after removing duplicate elements
cout<<"array after removing duplicate elements using function 2 - \n";
a.duplicateElementRemover_fromUnshortedArray1(ArrayInput3 , count);
a.traverseArray(ArrayInput3 , count);
cout<<endl<<endl;
// new array for duplicate element function 2
int ArrayInput4[10] = {1,2,2,2,3,3,4,5};
count=8;
// showing the new array
cout<<"new array - \n";
a.traverseArray(ArrayInput4 , count);
cout<<endl<<endl;
// array after removing duplicate elements
cout<<"array after removing duplicate elements using function 3 - \n";
a.duplicateElementRemover_fromUnshortedArray2(ArrayInput4 , count);
a.traverseArray(ArrayInput4 , count);
cout<<endl<<endl;
// press enter to continue
getch();
return 0;
}