1 / 10

Data Structures

Data Structures. Summary of lectures (1 to 11) Azhar Maqsood NUST Institute of Information Technology (NIIT). Features of c++ you need to know. Variables Parameter Passing Pointers Classes and Objects Inheritance Others. An Array!.

Download Presentation

Data Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Structures Summary of lectures (1 to 11) Azhar Maqsood NUST Institute of Information Technology (NIIT)

  2. Features of c++ you need to know • Variables • Parameter Passing • Pointers • Classes and Objects • Inheritance • Others

  3. An Array! The simplest form of an Array is a one dimensional array that may be defined as a finite ordered set of homogenous elements • Two dimensional Arrays • Multiply a Matrix

  4. Structures and Classes • A structure is an aggregate data structure used to keep different pieces of information together as a single data record • A structure is a collection of named fields whereas a class is a collection of named fields and methods that apply to objects of that class type. • Class: Methods, Inheritance, constructor and destructor

  5. Linked List • Consists of items that are linked to each other • Each item on the list is associated with a reference (pointer) that indicates where the next item is found • A dynamic data structure: grows and shrinks as necessary at runtime • There are no unused/empty locations

  6. Singly Linked List • Simplest form of linked list • Linked list object holds a reference to the first node on the list • Each node object consists of a reference to the data object being stored, and a reference to the next node in the list • The pointer to the first node in the list is referred to as the head pointer, because it points to the head node in the list.

  7. Singly Linked List Operations With a linked list, there are a standard set of functions that operate on the list: • Creating the list • Initialize pointers to NULL; • Inserting nodes • Insert at beginning • Insert at middle • Insert at last • Deleting nodes • Delete from beginning, middle, last • Traversing the list • Destroying the list

  8. Other list flavors • Doubly-linked list • Each node has a pointer to its successor and its predecessor. • Faster insert/delete, but more space. • Circular list • The last node points back to the head. • Sorted list • Items stored in sorted order.

  9. What is a Stack • A stack is an ordered collection of items into which new items may be inserted and from which items may be deleted at one endcalled the TOP of the stack • Data items are "popped" and "pushed" (retrieved and stored) from the top of the stack. • Stacks normally have a maximum size. • LIFO: Last In First Out

  10. Stack features • ORDERING: maintains order when elements added(new elements are added to the end by default) • OPERATIONS: • add element to end of list ('push') • remove element from end of list ('pop') • isEmpty() • isFull() • Top() • Implementation of these operations

More Related