Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

01-Introduction of DSA-1.pptx

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Próximo SlideShare
Data structures
Data structures
Cargando en…3
×

Eche un vistazo a continuación

1 de 32 Anuncio

Más Contenido Relacionado

Similares a 01-Introduction of DSA-1.pptx (20)

Más reciente (20)

Anuncio

01-Introduction of DSA-1.pptx

  1. 1. What is the Meaning of Data ????  Data is the unit of information like as alphabetic , numeric , scientific value etc.  Data are just a collection of facts and figures.  Data will be collected through various observation
  2. 2.  Structure is the organization of data in a proper channel or in systemic order with taking from previous result.  Structure is pre-define method to handle or manage the data , information or any other things. What is Structure ?? DNA Structure
  3. 3. What is Data Structure  Data Structure can be defined as the group of data elements which provides an efficient way of storing and organising data in the computer so that it can be used efficiently.  Data may be arranged in many different ways, such as the logical or mathematical model, for a particular organization of data is termed as a data structure.  The variety of a specific data model depends on the two factors - 1. Firstly, it must be loaded enough in structure to reflect the actual relationships of the data with the real-world object. 2. Secondly, the formation should be simple enough so that anyone can efficiently process the data each time it is necessary.
  4. 4. Data Structure Image & Video data Information Mathematical model
  5. 5. Need of Data Structures  Processor speed: To handle very large amount of data, high speed processing is required, but as the data is growing day by day to the billions of files per entity, processor may fail to deal with that much amount of data.  Data Search: Consider an inventory size of 100 items in a store, If our application needs to search for a particular item, it needs to traverse 100 items every time, results in slowing down the search process.  Multiple requests: If thousands of users are searching the data simultaneously on a web server, then there are the chances that a very large server can be failed during that process
  6. 6. Data Structure Classification
  7. 7. 1. An array is defined as the collection of similar type of data items stored at contiguous memory locations. 2. Arrays are the derived data type in C programming language which can store the primitive type of data such as int, char, double, float, etc. 3. It also has the capability to store the collection of derived data types, such as pointers, structure, etc. 4. The array is the simplest data structure where each data element can be randomly accessed by using its index number. 1. Each element of an array is of same data type and carries the same size, i.e., int = 4 bytes. 2. Elements of the array are stored at contiguous memory locations where the first element is stored at the smallest memory location. 3. Elements of the array can be randomly accessed since we can calculate the address of each element of the array with the given base address and the size of the data element. Properties of Array Introduction
  8. 8. Declaration of Array {1-D} :- Data_type array_name[array_size]; Ex. int marks[5];
  9. 9. Initialization of C Array 1) One by one or using a single statement :- double balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0}; 2) Size of the array :- double balance[] = {1000.0, 2.0, 3.4, 7.0, 50.0}; Ex. marks[0]=80;//initialization of array marks[1]=60; marks[2]=70; marks[3]=85; marks[4]=75;
  10. 10. Two Dimensional Array ( 2-D ):- 1. The two-dimensional array can be defined as an array of arrays. The 2D array is organized as matrices which can be represented as the collection of rows and columns. 2. To declare a two-dimensional integer array of size [x][y]. Declaration of two dimensional Array :- data_type array_name[rows][columns]; Ex. int twodimen[4][3]; int arr[4][3]={{1,2,3},{2,3,4},{3,4,5},{4,5,6}};
  11. 11. DataStructure Stack
  12. 12.  A stack is an Abstract Data Type (ADT), commonly used in programming languages. It is named stack as it behaves like a real-world stack, for example – (1) deck of cards (2) pile of plates, etc. stack  A Stack is a linear data structure that follows the LIFO (Last-In-First- Out) principle. This means the last element inserted inside the stack is removed first.  It contains only one pointer top pointer pointing to the topmost element of the stack. Whenever an element is added in the stack, it is added on the top of the stack, and the element can be deleted only from the stack.  In other words, a stack can be defined as a container in which insertion and deletion can be done from the one end known as the top of the stack.
  13. 13. Stack Representation
  14. 14. Standard Stack Operations 1) push(): When we insert an element in a stack then the operation is known as a push. If the stack is full then the overflow condition occurs. 2) pop(): When we delete an element from the stack, the operation is known as a pop. If the stack is empty this state is known as an underflow state. 3) isEmpty(): It determines whether the stack is empty or not. 4) isFull(): It determines whether the stack is full or not. 5) peek(): Get the value of the top element without removing it 6) count(): It returns the total number of elements available in a stack. 7) change(): It changes the element at the given position. 8) display(): It prints all the elements available in the stack.
  15. 15. PUSH operation 1) Before inserting an element in a stack, we check whether the stack is full. 2) If we try to insert the element in a stack, and the stack is full, then overflow condition. 3) When we initialize , we set the value of top as -1 to check that the stack is empty. 4) When the new element is pushed, the value of the top gets incremented, i.e., top=top+1, and the element will be placed at the new position of the top 5) The elements will be inserted until we reach the max size of the stack.
  16. 16. POP operation 1) Before deleting the element from the stack, we check whether the stack is empty. 2) If we try to delete the element from the empty stack, then the underflow condition. 3) If the stack is not empty, we first access the element which is pointed by the top 4) Once the pop operation is performed, the top is decremented by 1, i.e., top=top-1.
  17. 17. Working of Stack Data Structure
  18. 18. Applications of Stack in Data Structure 1. Evaluation of Arithmetic Expressions 1) Infix Notation 2) Prefix Notation 3) Postfix Notation 2. Backtracking 3. Delimiter Checking 4. Reverse a Data 5. Processing Function Calls
  19. 19. 1. A queue can be defined as an ordered list which enables insert operations to be performed at one end called REAR and delete operations to be performed at another end called FRONT. 2. Queue is referred to be as First In First Out list. 3. For example, people waiting in line for a rail ticket form a queue. 4. A queue is a linear list of elements Queue
  20. 20. Queue Representation Queue is an abstract data structure, similar to Stacks.  Queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue).
  21. 21. Basic Operations enqueue() − add (store/insert) an item to the queue. dequeue() − remove an item from the queue. peek() − Gets the element at the front of the queue without removing it. isfull() − Checks if the queue is full. isempty() − Checks if the queue is empty.
  22. 22. Enqueue Operation Queues maintain two data pointers, front and rear. Therefore, its operations are comparatively difficult to implement than that of stacks. Step 1 − Check if the queue is full. Step 2 − If the queue is full, produce overflow error and exit. Step 3 − If the queue is not full, increment rear pointer to point the next empty space. Step 4 − Add data element to the queue location, where the rear is pointing. Step 5 − return success.
  23. 23. Dequeue Operation Accessing data from the queue is a process of two tasks − 1)access the data where front is pointing 2)remove the data after access. Step 1 − Check if the queue is empty. Step 2 − If the queue is empty, produce underflow error and exit. Step 3 − If the queue is not empty, access the data where front is pointing. Step 4 − Increment front pointer to point to the next available data element. Step 5 − Return success.
  24. 24. Types of Queue 1) Linear Queue 2) Circular Queue 1.Linear Queue Data insert at Rear position , if we insert more value then the rear value by +1. Data deletion from front position , if we delete more value then the front value by -1.  
  25. 25. 2.Circular Queue
  26. 26. Applications of Queue 1. Serving requests on a single shared resource, like a printer, CPU task scheduling etc. 2. In real life scenario, Call Center phone systems uses Queues to hold people calling them in an order, until a service representative is free. 3. Handling of interrupts in real-time systems. The interrupts are handled in the same order as they arrive i.e First come first served

×