Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

Data Structure.pptx

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Prochain SlideShare
Data structure.pptx
Data structure.pptx
Chargement dans…3
×

Consultez-les par la suite

1 sur 25 Publicité
Publicité

Plus De Contenu Connexe

Plus récents (20)

Publicité

Data Structure.pptx

  1. 1. CS261 DATA STRUCTURES & ALGORITHMS (WEEK-1) LECTURE-1 & 2 INTRODUCTION TO DATA STRUCTURES & ALGORITHMS Lecturer Azka Aziz Azka.a@scocs.edu.pk
  2. 2. 2  Assignment = 10% (Research review report)  Quizzes = 20%  Mid-Term = 30%  Final Exam = 40%
  3. 3.  Week 1: Introduction to data structures, algorithm ,Pseudo code, Al-Khawarzmi’s Principle Relation of algorithm with Data Structures Multiplication of numbers Multiplication Problem with Iterative.  Week 2: Array Data structure ,Multidimensional arrays, Dynamic Arrays, Link List  Week 3: Double Link list , Insertion , Deletion, Insert after, Insert Before  Week 4: More on Asymptotic Analysis Insertion Sort Merge Sort, Selection sort, Bubble Sort  Week 5: Substitution Method Master Theorem Tree Method  Week 6: Select Algorithm (Kth Smallest and Kth Largest Element) Quick Sort Difference From Merge Sort
  4. 4.  Week 7: Sorting Lower Bounds and O(n) Sorting Radix Sort Counting Sort  Week 8: Binary Search Tree using Array Binary Search Tree using linked list  Week 9: AVL Trees RB Tree using Linked List  Week 10: Hashing Hash Functions Hash Tables  Week 11: Stack using Link List, using Arrays  Week 12: Queues using Link List, using Arrays  Week 13: Graph Basics Graphs Representation Graph Types Basic Graphs Algorithm
  5. 5.  Week 14: DFS BFS Strongly Connected Components Topological Order  Week 15: Minimum Spanning Tree  Week 16: Shortest Path
  6. 6.  CLO1 Understand the fundamentals data structures such as lists, queues, trees, etc.  CLO2 Analyze time and space complexities of data structures and algorithms  CLO3 Select appropriate algorithms to use in specific applications
  7. 7. Data Structure = Data + Structure “A specialize format to store data in a particular organization”. Any data structure is designed to enable certain operations in an efficient manner e.g. Queue is a data structure that facilitates data items to be stored in a manner that supports first come first serve order. Similarly there are many data structures already designed to meet certain objectives including Array, Stack, Tree, Graph etc.
  8. 8. “An algorithm is any well-defined computational procedure that takes some values, or set of values, as input and produces some value, or set of values, as output”  Algorithm is basic element of programming  A mathematical entity independent of programming languages, operating system & compiler  Algorithms provide a scientific way of handling general programming techniques  Given any input values, an algorithm will definitely terminate after executing a finite number of steps
  9. 9. “A data container whose contents can vary” Say a variable ‘radius’ is defined as integer using any programming language in a program then its value can be changed as the result of assignment within the lifetime of that variable when that variable is in scope
  10. 10. “A data type is a classification of data that tells the compiler or interpreter how the variables (declared with that data type) will be used” Every data type allows a certain type of data values (and forbids other types) e.g. typically a data type ‘int’ allows numerical values without decimal points with a certain range while not allowing string data All variables defined with same data type will have same range and permitted data
  11. 11. “An abstract data type (ADT) is a set of elements with a collection of well defined set of operations” Said operations can take the same ADT instances as well as other ADT instances as operands Operation results may not be instances of same ADT Java / C++ allows ADTs by means of classes
  12. 12. Data Structure = Data + Structure “A specialize format to store data in a particular organization”. Any data structure is designed to enable certain operations in an efficient manner e.g. Queue is a data structure that facilitates data items to be stored in a manner that supports first come first serve order. Similarly there are many data structures already designed to meet certain objectives including Array, Stack, Tree, Graph etc.
  13. 13. “An implementation of an ADT using a programming language is called a data structure” Data structure includes data items stored Data structure also includes implementation of all operations within the data structure
  14. 14. A data structure allows different operations in an efficient way but it certainly has its cost Time Vs. Space complexity Trying to achieve efficiency in one operation may make other operations less efficient Generality may not be achieved While enabling certain operations, simplicity may be compromised
  15. 15. While designing a data structure, following questions should be asked: Does this data structure support the required operations efficiently? Will it be easier to implement in our desired programming language? Will be easier to debug? What are the possibilities for its usage? What operands should it support?
  16. 16.  What is a Static Data structure? In Static data structure the size of the structure is fixed. The content of the data structure can be modified but without changing the memory space allocated to it. Example Array
  17. 17.  In Dynamic data structure the size of the structure in not fixed and can be modified during the operations performed on it. Dynamic data structures are designed to facilitate change of data structures in the run time. Example: Link List
  18. 18.  Linear Data Structure: Data structure where data elements are arranged sequentially or linearly where each and every element is attached to its previous and next adjacent is called a linear data structure. In linear data structure, single level is involved. Therefore, we can traverse all the elements in single run only. Linear data structures are easy to implement because computer memory is arranged in a linear way. Its examples are array, stack, queue, linked list, etc.
  19. 19. Non-linear Data Structure: Data structures where data elements are not arranged sequentially or linearly are called non-linear data structures. In a non-linear data structure, single level is not involved. Therefore, we can’t traverse all the elements in single run only. Non-linear data structures are not easy to implement in comparison to linear data structure. It utilizes computer memory efficiently in comparison to a linear data structure. Its examples are trees and graphs.
  20. 20.  Physical Data Structure: The Array and Link List are the two physical data structures. We can have more physical data structures by taking the combination of these two data structures i.e. array and linked list.  Logical Data Structure: Physical data structures are actually meant for storing the data in the memory. Then on the stored data or values, we may be performing some operations like inserting more values or deleting existing values or searching for the values, and many more operations. Now, the question is, how you want to utilize those values? How you will be performing insertion and deletion? What is the discipline that you are going to follow? That discipline is defined by logical data structures i.e. stack, queues, trees, graphs, and hash table.
  21. 21.  Al-Khwarizmi left a golden rule for the world to create science with. The al-Khwarizmi principle states that all complex problems of science must be and can be solved by means of the following five simple steps: 1. Break down each problem into a number of elemental or ‘atomic’ steps. An elemental or atomic step is one, which cannot be simplified any further. 2. Second, arrange all the elements or steps of the problem in an order or sequence, such that each element can be taken up and solved one at a time, without affecting other parts of the problem. 3. Next, find a way to solve each of the elements separately. Because each element has been simplified to the maximum, it is very likely that the solution of an elemental step will itself be extremely simple or elemental making it available with relative ease. 4. Then proceed to solve each element of the problem, either one at a time or several at a time, but in the correct order. Thus, when all steps are solved, the original problem itself has also been solved.
  22. 22.  Pseudocode is the expressive form of the algorithm or a way to describe an algorithm.  It is a combination of natural language and high-level programming practices which represent the fundamental concept behind a general implementation of a data structure or algorithm.  Pseudocode incorporated the natural language when the details are insignificant with the standard programming language constructs to obtain more clarity. However, we can not execute pseudocode on a computer, but it models the actual programming code along with a similar level of detail.
  23. 23. Pseudocode is also written using some specific words and characters, which are shown below: 1. To begin the comment double forward slash are used “//“. 2. Matching braces “{ and }” are used to present blocks where a compound statement (set of simple statements) can be illustrated as a block and terminated by a semicolon”;“. The body of a procedure constructs a block as well. 3. All the identifiers start with a letter and the datatype of the variables are not declared explicitly. 4. An assignment statement is used for the assigning values to the variables. 5. To produce the boolean values (i.e., true and false) the logical operators and, or and not and the relational operators <, ≤, =, =, ≥ and > are provided. 6. Input and output are presented by read and write instructions. 7. “if and then” expressions are used to express a conditional statement.
  24. 24.  An algorithm is a definite, clear sequence-wise procedure to solve a problem. It involves the high-level language builds which cannot be understood by a non-technical person. On the other hand, pseudocode is a more plain and human understandable form of algorithm where natural language is also combined with the high-level programming language constructs.  Pseudocode is easy to understand and interpret as compared to an algorithm.  The algorithm uses high-level constructs meaning the snippet of code but the pseudocode involves natural language with high-level programming builds.  Pseudocode is easily constructed and debugged relative to the algorithm.

×