Presentation on theme: "Summary of lectures (1 to 11)"— Presentation transcript:
1 Summary of lectures (1 to 11) Data StructuresSummary of lectures (1 to 11)Azhar MaqsoodNUST Institute of Information Technology (NIIT)
2 Features of c++ you need to know VariablesParameter PassingPointersClasses and ObjectsInheritanceOthers
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 elementsTwo dimensional ArraysMultiply 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 recordA 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 foundA dynamic data structure: grows and shrinks as necessary at runtimeThere 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 listEach node object consists of a reference to the data object being stored, and a reference to the next node in the listThe 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 listInitialize pointers to NULL;Inserting nodesInsert at beginningInsert at middleInsert at lastDeleting nodesDelete from beginning, middle, lastTraversing the listDestroying 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 listThe last node points back to the head.Sorted listItems stored in sorted order.
9 What is a StackA 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 stackData 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