Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © Wondershare Software Introduction to Data Structures Prepared by: Eng. Ahmed & Mohamed Taha.

Similar presentations


Presentation on theme: "Copyright © Wondershare Software Introduction to Data Structures Prepared by: Eng. Ahmed & Mohamed Taha."— Presentation transcript:

1 Copyright © Wondershare Software Introduction to Data Structures Prepared by: Eng. Ahmed & Mohamed Taha

2 Copyright © Wondershare Software Company Logo Agenda  Data Structures and Algorithms.  Characteristics of Data Structures.  Abstract Data Types.  General form of any Data structure

3 Copyright © Wondershare Software Company Logo Data Structures  A data structure is an arrangement of data in a computer's memory or even disk storage.  An example of several common data structures are: arrays linked lists Queues Stacks binary trees hash tables.  Algorithms, on the other hand, are used to manipulate the data contained in these data structures such as searching and sorting algorithms.

4 Copyright © Wondershare Software Company Logo Algorithms  Many algorithms apply directly to a specific data structures. When working with certain data structures you need to know how to insert new data, search for a specified item, and deleting a specific item.  Commonly used algorithms are useful for: Searching for a particular data item (or record). Sorting the data. There are many ways to sort data. Simple sorting, Advanced sorting Iterating through all the items in a data structure. (Visiting each item in turn so as to display it or perform some other action on these items)

5 Copyright © Wondershare Software Company Logo Characteristics of Data Structures DisadvantagesAdvantagesData Structure Slow search Slow deletes Fixed size Quick inserts Fast access if index known Array 1 Slow inserts Slow deletes Fixed size Faster search than unsorted array Ordered Array 2 Slow access to other items Last-in, first-out LIFO access Stack 3 Slow access to other itemsFirst-in, first-out FIFO access Queue 4 Slow searchQuick inserts Quick deletes Linked List 5 Deletion algorithm is complex Quick search Quick inserts Quick deletes (If the tree remains balanced) Binary Tree 6

6 Copyright © Wondershare Software Company Logo Characteristics of Data Structures DisadvantagesAdvantagesData Structure Complex to implement Quick search Quick inserts Quick deletes (Tree always remains balanced) Red-Black Tree 7 Complex to implement Quick search Quick inserts Quick deletes (Tree always remains balanced) (Similar trees good for disk storage) 2-3-4 Tree 8 Slow deletes Access slow if key is not known Inefficient memory usage Very fast access if key is known Quick inserts Hash Table 9 Slow access to other items Quick inserts Quick deletes Access to largest item Heap 10 Some algorithms are slow and very complex Best models real-world situations Graph 11 Cont.

7 Copyright © Wondershare Software Company Logo A red-black Tree A red-black tree is a binary search tree where each node has a color attribute, the value of which is either(red or black). In addition to the ordinary requirements imposed on binary search trees, the following additional requirements apply to red-black trees: 1.A node is either red or black. 2.The root is black. (This rule is sometimes omitted from other definitions. Since the root can always be changed from red to black but not necessarily vice-versa this rule has little effect on analysis.) 3.All leaves are black. 4.Both children of every red node are black. 5.Every simple path from a given node to any of its descendant leaves contains the same number of black nodes.

8 Copyright © Wondershare Software Company Logo A red-black Tree Example Cont.

9 Copyright © Wondershare Software Company Logo Abstract Data Types (ADT)   An Abstract Data Type (ADT) is more a way of looking at a data structure: focusing on what it does and ignoring how it does its job.   A stack or a queue is an example of an ADT. It is important to understand that both stacks and queues can be implemented using an array.   It is also possible to implement stacks and queues using a linked list. This demonstrates the "abstract" nature of stacks and queues: how they can be considered separately from their implementation.   To best describe the term Abstract Data Type, it is best to break the term down into "data type" and then "abstract".   data type: a data item with certain characteristics and the permissible operations on that data. An “int”, for example, can contain any whole-number value. It can also be used with the operators +, -, *, and /. understanding the type means understanding what operations can be performed on it.   Abstract: The word abstract in our context stands for "considered apart from the detailed specifications or implementation“. Consider for example the stack class. The end user knows that push() and pop() (amoung other similar methods) exist and how they work. The user doesn't and shouldn't have to know how push() and pop() work, or whether data is stored in an array, a linked list, or some other data structure like a tree.

10 Copyright © Wondershare Software Company Logo General form of any Data structure Data structure operations Insert item function Delete item function Search for an item function

11 Copyright © Wondershare Software Thank you !


Download ppt "Copyright © Wondershare Software Introduction to Data Structures Prepared by: Eng. Ahmed & Mohamed Taha."

Similar presentations


Ads by Google