Presentation is loading. Please wait.

Presentation is loading. Please wait.

LECTURE# 1: INTRODUCTION TO DATA STRUCTURE

Similar presentations


Presentation on theme: "LECTURE# 1: INTRODUCTION TO DATA STRUCTURE"— Presentation transcript:

1 LECTURE# 1: INTRODUCTION TO DATA STRUCTURE
DATA STRUCTURE & ALGORITHMS LECTURE# 1: INTRODUCTION TO DATA STRUCTURE

2 Course objective: Describe various data structures and their algorithms Apply basic algorithms and determine their complexities. Use appropriate data structures and algorithms to design solutions.

3 Course Outline: Data types, Array, Records, Set structure, Abstract data types, Sequential allocation, Linked allocation. Stacks (sequential as well as linked Implementation) Queues. (Sequential as well as linked implementation), Linked Lists, Traversal, Insertion, Deletion, Doubly linked lists, Root Node, Terminal Node, Branch Node, Level of a Node, Degree of a node, Binary tree, Tree traversal, (In-order/Pre-order/post-order traversal). Conversion of tree in to binary tree/ Bin tree in to a heap, Traversing and searching in a tree, Insertion: Deletion, Heap, Heap-sort, Graphs. Adjacency Matrix. Traversal, DFS, BFS, Path lengths, Shortest Path Searching and sorting Algorithms, Insertion sort, Selection Sort, Merge Sort, Radix Sort, Hashing.

4 Recommended books: Horowitz Sahni “Fundamentals of Data Structures in C++”, 1999. Lipshutz, “Data Structures”, Sachaum Outline Series, 1999. Weiss, “ Data Structures and Algorithms analysis in C++”. A.M. Tanenbaum, “Data Structures using C and C++” 2001.

5 Programming languages
A programming language is a vocabulary and set of grammatical rules for instructing a computer or computing device to perform specific tasks. The term programming language usually refers to high-level languages, such as BASIC, C, C++, COBOL, Java, FORTRAN and Pascal. Each programming language has a unique set of keywords (words that it understands) and a special syntax for organizing program instructions.

6 Programming languages
Programming languages are broadly classified into two types. i.e., low-level languages and high-level languages and there is a big difference between them.

7 Programming languages
High-level programming languages, while simple compared to human languages, are more complex than the languages the computer actually understands, called machine languages. Each different type of CPU has its own unique machine language.

8 Programming languages
Lying between machine languages and high-level languages are languages called assembly languages. Assembly languages are similar to machine languages, but they are much easier to program in because they allow a programmer to substitute names for numbers. Machine languages consist of numbers only.

9 Programming languages
Lying above high-level languages are languages called fourth- generation languages (usually abbreviated 4GL). 4GLs are far removed from machine languages and represent the class of computer languages closest to human languages.

10 Difference Between High-Level Language and Low-Level Language
High-Level Languages Low-Level Languages High-Level Languages are easy to learn and understand. They are executed slower than lower level languages because they require a translator program. Low-Level Languages are challenging to learn and understand. They execute with high speed.

11 Difference Between High-Level Language and Low-Level Language
High-Level Languages Low-Level Languages For writing programs, hardware knowledge is not required. The programs are easy to modify. BASIC, Perl, Pascal, COBOL, Ruby etc are examples of High- Level Languages. For writing programs, hardware knowledge is a must. Modifying programs is difficult. Machine language and Assembly language are Low-Level Languages.

12 Differences between C and C++ are:
C was developed by Dennis Ritchie between the year and 1973 at AT&T Bell Labs. C is a subset of C++. C contains 32 keywords. C++ was developed by Bjarne Stroustrup in 1979. C codes can be run by C++ but C cannot run the C++ codes. C++ contains 52 keywords.

13 Differences between C and C++ are:
scanf and printf functions are used for input/output in C. Header file used by C is stdio.h. C is a function-driven language. cin and cout are used for input/output in C++. Header file used by C++ is iostream.h. C++ is an object-driven language

14 C++ Basic Syntax When we consider a C++ program, it can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what a class, object, methods, and instant variables mean. Object − Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors - wagging, barking, eating. An object is an instance of a class. Class − A class can be defined as a template/blueprint that describes the behaviors/states that object of its type support. Methods − A method is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed. Instance Variables − Each object has its unique set of instance variables. An object's state is created by the values assigned to these instance variables.

15 C++ Program Structure Let us look at a simple code that would print the words Hello World.

16 C++ Program Structure The C++ language defines several headers, which contain information that is either necessary or useful to your program. For this program, the header <iostream> is needed. The line using namespace std; tells the compiler to use the std namespace. Namespaces are a relatively recent addition to C++. The next line '// main() is where program execution begins.' is a single-line comment available in C++. Single-line comments begin with // and stop at the end of the line. The line int main() is the main function where program execution begins. The next line cout << "Hello World"; causes the message "Hello World" to be displayed on the screen. The next line return 0; terminates main( )function and causes it to return the value 0 to the calling process.

17 Built in Types

18 What is Data Structure? Data structure is a representation of data and the operations allowed on that data. A data structure is a way to store and organize data in order to facilitate the access and modifications. Data Structure are the method of representing of logical relationships between individual data elements related to the solution of a given problem.

19 Basic Data Structure

20 Basic Data Structure

21 Data Structures Data structures are classified as either linear or nonlinear. A data structure is said to be linear if its elements form a sequence or in other word a linear list. There are two basic ways of representing such linear structures in memory. One way is to have the linear relationship between the elements represented by means of sequential memory locations. These linear structures are called arrays. The other way is to have the linear relationship between the elements represented by means of pointers or links. These linear structures are called linked lists. Non linear structures such as trees and graphs.

22 Data Structures The operations one normally performs on any linear structure, whether it be array or a linked list, include the following: Traversal: Processing each element in the list. Search: Finding the location of the element with a given value or the record with a given key. Insertion: Adding a new elements from the list. Deletion: Removing an element from the list. Sorting: Arranging the elements in some type of order. Merging: Combing two lists into single list.

23 Types of Data Structure
Linear: In Linear data structure, values are arrange in linear fashion. ◦ Array: Fixed-size ◦ Linked-list: Variable-size ◦ Stack: Add to top and remove from top ◦ Queue: Add to back and remove from front ◦ Priority queue: Add anywhere, remove the highest priority

24 Types of Data Structure
Non-Linear: The data values in this structure are not arranged in order. ◦ Hash tables: Unordered lists which use a ‘hash function’ to insert and search ◦ Tree: Data is organized in branches. ◦ Graph: A more general branching structure, with less strict connection conditions than for a tree

25 Type of Data Structures
 Homogenous: In this type of data structures, values of the same types of data are stored. ◦ Array Non-Homogenous: In this type of data structures, data values of different types are grouped and stored. ◦ Structures ◦ Classes

26 Stacks Collection with access only to the last element inserted
Last in first out insert/push remove/pop top make empty

27 Queues Collection with access only to the item that has been present the longest Last in last out or first in first out enqueue, dequeue, front priority queues and dequeue

28 List A Flexible structure, because can grow and shrink on demand. Elements can be: Inserted Accessed Deleted At any position first last

29 Tree A Tree is a collection of elements called nodes.
One of the node is distinguished as a root, along with a relation (“parenthood”) that places a hierarchical structure on the nodes. Root

30 BASIC DATA TYPES Data type determines the set of values that a data item can take and the operations that can be performed on the item


Download ppt "LECTURE# 1: INTRODUCTION TO DATA STRUCTURE"

Similar presentations


Ads by Google