What is Algorithm according to Data Structure?
Algorithm is a finite sequence of steps for the solution of a problem.
Example,
Consider there are a number of students whose marks are needed to be stored in the computer, now we can store them in computer in an efficient way by using data structure like array, Linked List etc..
Consider we need to find the maximum marks obtained by a student in this list, now for this we need to use an algorithm (Sequence of steps), for example,
1. Define Variables (Max, i, List_Size, List[List_Size])
2. Max = List[0];
3. For ( i = 1; i<List_Size;i++) // Loop from 1 to End of list
i If ( List[i] > Max)
ii Max = List[i];
iii End of loop;
4. Print (Max);
5. End of Algorithm.
Example,
Consider there are a number of students whose marks are needed to be stored in the computer, now we can store them in computer in an efficient way by using data structure like array, Linked List etc..
Consider we need to find the maximum marks obtained by a student in this list, now for this we need to use an algorithm (Sequence of steps), for example,
1. Define Variables (Max, i, List_Size, List[List_Size])
2. Max = List[0];
3. For ( i = 1; i<List_Size;i++) // Loop from 1 to End of list
i If ( List[i] > Max)
ii Max = List[i];
iii End of loop;
4. Print (Max);
5. End of Algorithm.
0 Comments
Please add nice comments or answer ....