Posts

Showing posts from March, 2021

DATA STRUCTURE - Searching methodes

Image
  Searching methods                 In data structure there are searching methods applying to search element. There are two searching methods are available for searching data element in two different ways.   1)     Linear search – This is the first and basic searching techniques. According to its name in this searching method we have to follow sequence, i.e., we have to check each and every data element of data structure one by one. It doesn’t matter how many data elements are there in data structure. We have to check all data element because we cannot directly go to the data element for which we are looking. There is one disadvantage of this searching method that this is time consuming searching method, because it takes time to compare each and every element for the required data. Algorithm for linear search   1.        Initialize counte...

Data structure - Sorting methodes

Image
  Sorting methods 1)     Bubble sort – Sorting is a technique to rearrange in data structure. Here in bubble sort adjacent element if first element is greater than next element then swapping occurs. In the same way between inner loop and outer loop goes continuously and all the elements gets compared and swapped for all the arrangement.   Algorithm for bubble sort   1.        Repeat for i=1 to n. 2.        Repeat for j=1 to n. 3.        If LA[j]>LA[j+1], Then:swap. [end of if] [end of step 2 loop] [end of step 1 loop] 4.        Exit .     2)     Selection sort – As per its name in this sorting method the elements are compared with all other position that’s why the smallest element will be automatically comes to 1 st position. In the same way loops goes continuously from first p...

Cpp-Program for Constructor and Distructure with Output

Image
   //Program for constructure #include<iostream> #include<conio.h> int count=0; class alpha {     public:     alpha()     {         count++;        cout<<"\n\tNumber of created object "<<count;              } }; int main() {     clrscr();      cout<<"\n\t\t\tOUTPUT";     cout<<"\n\t\t\t------";     cout<<"\n\t\tEnter main";     alpha A1, A2, A3, A4;     {         cout<<"\n\t\tEnter block1";         alpha A5;     }     {         cout<<"\n\t\tEnter block";         alpha A5;     }   ...