Presentation is loading. Please wait.

Presentation is loading. Please wait.

Summary of lectures (1 to 11)

Similar presentations

Presentation on theme: "Summary of lectures (1 to 11)"— Presentation transcript:

1 Summary of lectures (1 to 11)
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! Two dimensional Arrays Multiply a Matrix
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 Circular list Sorted 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 end called 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 Implementation of these operations
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

Download ppt "Summary of lectures (1 to 11)"

Similar presentations

Ads by Google