Introductiont To Aray,Tree,Stack, Queue

5,434 views

Published on

Published in: Technology
4 Comments
5 Likes
Statistics
Notes
No Downloads
Views
Total views
5,434
On SlideShare
0
From Embeds
0
Number of Embeds
50
Actions
Shares
0
Downloads
3
Comments
4
Likes
5
Embeds 0
No embeds

No notes for slide

Introductiont To Aray,Tree,Stack, Queue

  1. 1. Introduction to Data Structures By: Abdul Ghaffar
  2. 2. Contents <ul><ul><li>Introduction </li></ul></ul><ul><ul><li>Queues </li></ul></ul><ul><ul><li>Stacks </li></ul></ul><ul><ul><li>Linked lists </li></ul></ul><ul><ul><li>Trees </li></ul></ul>
  3. 3. Basic Terminology <ul><ul><li>Data </li></ul></ul><ul><ul><ul><ul><ul><li>Raw facts and figures are called data. </li></ul></ul></ul></ul></ul><ul><ul><li>Information </li></ul></ul><ul><ul><ul><ul><li>Data with given attributes, or meaningful or processed data is called information </li></ul></ul></ul></ul><ul><ul><li>Group & Elementary data items </li></ul></ul><ul><ul><ul><ul><li>If a data item can be divided into sub items then it is called group item else it is called elementary item. </li></ul></ul></ul></ul><ul><ul><li>Entity </li></ul></ul><ul><ul><ul><ul><li>An entity is something that has certain attributes or properties which may be assigned values. </li></ul></ul></ul></ul>
  4. 4. Basic Terminology <ul><ul><li>Entity Set </li></ul></ul><ul><ul><ul><ul><li>Entities with similar attributes form an entity set . </li></ul></ul></ul></ul><ul><ul><li>Hierarchy of data organization </li></ul></ul><ul><ul><ul><li>Field </li></ul></ul></ul><ul><ul><ul><ul><li>A field is a single elementary unit of information representing an attribute of an entity. </li></ul></ul></ul></ul><ul><ul><ul><li>Record </li></ul></ul></ul><ul><ul><ul><ul><li>A record is collection of field values of a given entity. </li></ul></ul></ul></ul><ul><ul><ul><li>File </li></ul></ul></ul><ul><ul><ul><ul><li>A file is a collection of records of the entities in a given entity set </li></ul></ul></ul></ul>
  5. 5. Basic Terminology <ul><ul><li>Primary Key </li></ul></ul><ul><ul><ul><li>If the value in certain field may uniquely identity the record in the file then such a field is called primary key </li></ul></ul></ul>
  6. 6. Basic Terminology <ul><li>Data Structures </li></ul><ul><ul><ul><li>The logical and mathematical model of a particular organization of data is called Data structure </li></ul></ul></ul><ul><ul><ul><ul><li>Essential to implement most algorithms </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Data Structures + Algorithms = Programs </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Computer languages support their creation </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Defined using “primitive types” and language constructs </li></ul></ul></ul></ul><ul><ul><li>Steps the in study of Data Structures </li></ul></ul><ul><ul><ul><ul><li>Logical or mathematical description of the structure </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Implementation of the structure on a computer </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Quantitative analysis of the structure (time & Space) </li></ul></ul></ul></ul>
  7. 7. Data Structures <ul><ul><li>Arrays </li></ul></ul><ul><ul><ul><li>A list of finite number n of similar data elements referenced respectively by a set of n consecutive numbers </li></ul></ul></ul><ul><ul><ul><ul><li>One-Dimensional </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Two-Dimensional </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Three-Dimensional </li></ul></ul></ul></ul>
  8. 8. Data Structures <ul><ul><li>Linked List </li></ul></ul><ul><ul><ul><li>A linked list is a linear collection of data elements, called nodes, where linear order is given by means of pointers. </li></ul></ul></ul>7 next head 11 next 14 next 18 next NULL
  9. 9. Data Structures <ul><ul><li>Trees </li></ul></ul><ul><ul><ul><li>The data structure which reflects hierarchical relationship between various elements is called a rooted tree or simply Tree. </li></ul></ul></ul>17 15 14 9 6 5 8
  10. 10. Data Structures <ul><ul><li>Stack </li></ul></ul><ul><ul><ul><li>A stack is a linear list in which insertion and deletion can take place only at one end (LIFO) </li></ul></ul></ul>9 1 2 3 4 5 6 7 8 9 11 7 18 14 S top
  11. 11. Data Structures <ul><ul><li>Queue </li></ul></ul><ul><ul><ul><li>A queue is a linear list in which deletion & insertion can not take place at the same end (FIFO) </li></ul></ul></ul>1 2 3 4 5 6 7 8 9 11 7 18 14 Q head tail
  12. 12. Data Structures <ul><ul><li>Graph </li></ul></ul><ul><ul><ul><li>The data structure which reflects relationship between pairs of elements is called a graph. </li></ul></ul></ul>
  13. 13. Data Structures <ul><li>Data Structure Operations </li></ul><ul><ul><ul><li>Traversing </li></ul></ul></ul><ul><ul><ul><li>Searching </li></ul></ul></ul><ul><ul><ul><li>Inserting </li></ul></ul></ul><ul><ul><ul><li>Deletion </li></ul></ul></ul><ul><ul><ul><li>Sorting </li></ul></ul></ul><ul><ul><ul><li>Merging </li></ul></ul></ul><ul><ul><li>MINIMUM(S) </li></ul></ul><ul><ul><li>MAXIMUM(S) </li></ul></ul><ul><ul><li>IsEMPTY(S) </li></ul></ul><ul><ul><li>PRINT(S) </li></ul></ul><ul><ul><li>COUNT(S) </li></ul></ul>
  14. 14. Algorithm <ul><li>Algorithm </li></ul><ul><ul><ul><li>An algorithm is a finite step by step list of well defined instructions for solving a particular problem. </li></ul></ul></ul>
  15. 15. Algorithm <ul><li>Example </li></ul>
  16. 16. Algorithm <ul><li>Control Structures </li></ul><ul><ul><li>Sequence logic </li></ul></ul><ul><ul><li>Selection logic </li></ul></ul><ul><ul><ul><li>Single alternative </li></ul></ul></ul><ul><ul><ul><ul><li>If condition, then </li></ul></ul></ul></ul><ul><ul><ul><ul><li>[Module A] </li></ul></ul></ul></ul><ul><ul><ul><ul><li>[End of if structure] </li></ul></ul></ul></ul>
  17. 17. Algorithm <ul><ul><ul><li>Double Alternative </li></ul></ul></ul><ul><ul><ul><ul><ul><li>If condition, then </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>[Module A] </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Else </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>[Module B] </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>[End of If structure] </li></ul></ul></ul></ul></ul>
  18. 18. Algorithm <ul><ul><ul><li>Multiple Alternatives </li></ul></ul></ul><ul><ul><ul><ul><ul><li>If condition, then </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>[Module A] </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Else if condition2, then </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>[Module B] </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Else if condition3, then </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>[Module C] </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Else if condition4, then </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>[Module D] </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Else </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>[Module E] </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>[End of if structure] </li></ul></ul></ul></ul></ul>
  19. 19. Algorithm <ul><li>Example </li></ul>
  20. 20. Algorithm <ul><li>Control Structures </li></ul><ul><ul><li>Iteration logic </li></ul></ul><ul><ul><ul><ul><li>Repeat for K=R to S by T </li></ul></ul></ul></ul><ul><ul><ul><ul><li>[Module] </li></ul></ul></ul></ul><ul><ul><ul><ul><li>[End of loop] </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Repeat while condition </li></ul></ul></ul></ul><ul><ul><ul><ul><li>[Module] </li></ul></ul></ul></ul><ul><ul><ul><ul><li>[End of loop] </li></ul></ul></ul></ul>
  21. 21. Algorithm <ul><li>Example </li></ul>
  22. 22. Algorithm <ul><ul><li>Complexity of Algorithm </li></ul></ul><ul><ul><ul><li>The complexity of an algorithm f(n) is the function which gives the ruining time or space in term of the input size. </li></ul></ul></ul><ul><ul><li>Time-Space trade-off </li></ul></ul><ul><ul><ul><li>The Time-Space trade-off refers to a choice between algorithmic solution of a data processing problem that allows one to decrease the running time of an algorithmic solution by increasing the space to store the data and vice versa. </li></ul></ul></ul><ul><ul><ul><ul><ul><li>Linear Search </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>C(n) = (n+1)/2 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Binary Search </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>C(n) = log 2 n </li></ul></ul></ul></ul></ul>
  23. 23. Algorithm <ul><ul><ul><li>Binary Search </li></ul></ul></ul>

×