Introduction to Data Structures & Algorithm. Objectives: By the end of the class, students are expected to understand the following: data structure and.

Slides:



Advertisements
Similar presentations
Programming Logic and Design Fourth Edition, Introductory
Advertisements

Object Oriented Design An object combines data and operations on that data (object is an instance of class) data: class variables operations: methods Three.
Software Engineering and Design Principles Chapter 1.
1 CSE1301 Computer Programming: Lecture 15 Flowcharts and Debugging.
COS Sept 9, 2005 Key Issues in Programming Stefan Brandle.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Data Abstraction & Problem Solving with C++ Fifth Edition by Frank.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 1 Principles of Programming and Software Engineering.
1 CSE1301 Computer Programming: Lecture 15 Flowcharts, Testing and Debugging.
Chapter 1 Program Design
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 2: Algorithm Discovery and Design
Introduction - The Need for Data Structures Data structures organize data –This gives more efficient programs. More powerful computers encourage more complex.
Data Structures and Programming.  John Edgar2.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
5.1 and 5.4 through 5.6 Various Things. Terminology Identifiers: a name representing a variable, class name, method name, etc. Operand: a named memory.
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
Comp 245 Data Structures Software Engineering. What is Software Engineering? Most students obtain the problem and immediately start coding the solution.
Review C++ exception handling mechanism Try-throw-catch block How does it work What is exception specification? What if a exception is not caught?
Simple Program Design Third Edition A Step-by-Step Approach
Introduction to Data Structures. Definition Data structure is representation of the logical relationship existing between individual elements of data.
Chapters 7, 8, & 9 Quiz 3 Review 1. 2 Algorithms Algorithm A set of unambiguous instructions for solving a problem or subproblem in a finite amount of.
Chapter 12 Recursion, Complexity, and Searching and Sorting
Programming Concepts Chapter 3.
Chapter 13 Recursion. Learning Objectives Recursive void Functions – Tracing recursive calls – Infinite recursion, overflows Recursive Functions that.
Prepared By Ms.R.K.Dharme Head Computer Department.
SE: CHAPTER 7 Writing The Program
1 Life Cycle of Software Specification Design –Risk Analysis –Verification Coding Testing –Refining –Production Maintenance.
CSIS 123A Lecture 9 Recursion Glenn Stevenson CSIS 113A MSJC.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
Programming Logic and Design Using Methods. 2 Objectives Review how to use a simple method with local variables and constants Create a method that requires.
Algorithms & Flowchart
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
1 Program Planning and Design Important stages before actual program is written.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Software Engineering and Object-Oriented Design Topics: Solutions Modules Key Programming Issues Development Methods Object-Oriented Principles.
Data Structures. Abstract Data Type A collection of related data is known as an abstract data type (ADT) Data Structure = ADT + Collection of functions.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Chapter 2 Principles of Programming and Software Engineering.
Data Structure and Algorithms
Principles of Programming. Achieving an Object-Oriented Design  Abstraction and Information Hiding  Object-Oriented Design  Functional Decomposition.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
 Problem Analysis  Coding  Debugging  Testing.
Prof. I. J. Chung Data Structure #1 Professor I. J. Chung.
Maitrayee Mukerji. INPUT MEMORY PROCESS OUTPUT DATA INFO.
Mohammed I DAABO COURSE CODE: CSC 355 COURSE TITLE: Data Structures.
Introduction toData structures and Algorithms
Principles of Programming & Software Engineering
5.13 Recursion Recursive functions Functions that call themselves
Data Structure Interview Question and Answers
GC211Data Structure Lecture2 Sara Alhajjam.
DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
Principles of Programming and Software Engineering
Data Structures Data Structure is a way of collecting and organising data in such a way that we can perform operations on these data in an effective.
Data Structures Interview / VIVA Questions and Answers
Lecture 2 Introduction to Programming
Introduction to Data Structures & Algorithm
Unit# 9: Computer Program Development
Objective of This Course
Introduction to Data Structures
Introduction to Data Structure
Basic Concepts of Algorithm
Presentation transcript:

Introduction to Data Structures & Algorithm

Objectives: By the end of the class, students are expected to understand the following: data structure and algorithm concept key programming principle Programming development paradigm

Software Eng. & Problem Solving Software engineering Provides techniques to facilitate the development of computer program Problem solving The entire process of taking the statement of a problem and developing a computer program that solves that problem Requires to pass many phases, from understanding the problem, design solution and implement the solution.

Problem Solving A solution to a problem is computer program written in C++ and consist of: Modules A single, stand-alone function A method of a class A class Several functions or classes working closely together Other blocks of code

Problem Solving Challenges to create a good solution Create a good set of modules that must store, move, and alter data use algorithms to communicate with one another Organize your data collection to facilitate operations on the data in the manner that an algorithm requires

Algorithm Functions and methods implement algorithms Algorithm: a step-by-step recipe for performing a task within a finite period of time Algorithms often operate on a collection of data, which is stored in a structured way in the computer memory (Data Structure) Algorithms: Problem solving using logic

Algorithm a sequence of instructions, often used for calculation and data processing calculationdata processing It is formally a type of effective method in which a list of well-defined instructions for completing a task will:effective method when given an initial state, (INPUT) proceed through a well-defined series of successive states, (PROCESS) eventually terminating in an end-state (OUTPUT)

Algorithm Initial state Series of process

Algorithm 3 types of algorithm basic control structure Sequential Selection Repeatition (Looping)

Algorithm Basic algorithm characteristics Finite solution (ada penamat) Clear instructions (jelas) Has input to start the execution Has output as the result of the execution Operate effectively ( dilaksana dengan berkesan) Algorithm creation techniques Flowchart, pseudo code, language etc Factors for measuring good algorithm Running time Total memory usage

Algorithm & Data Structure Data Structure a way of storing data in a computer so that it can be used efficiently – (this class – RAM only)data carefully chosen data structure will allow the most efficient algorithm to be usedefficientalgorithm A well-designed data structure allows a variety of critical operations to be performed, Using as few resources, both execution time and memory space, as possible

Data Structure Operations to the Data Structure Traversing- access and process every data in data structure at least once Searching – search for a location of data Insertion – insert item in the list of data Deletion - delete item from a set of data Sorting – sort data in certain order Merging – merge multiple group of data

Data Types Basic data types and structured data types Basic Data Types (C++) – store only a single data Integral Boolean – bool Enumeration – enum Character - char Integer – short, int, long Floating point – float, double

Structured Data Types Storage Structure Linked Structure State Structure Array Structure (struct) Unsorted Linked List Sorted Linked List Binary Tree Graph Network Stack Queue

Data Types Structured Data Types Array – can contain multiple data with the same types Struct – can contain multiple data with different type typedef struct { int age; char *name; enum {male, female} gender; } Person;

Data Types Linked Data Structure Linear Data Structure with restriction Queue & Stack Linear Data Structure with no restriction Unsorted linked list Sorted linked list Non-linear Data Structure Binary Tree Graph

Linear Data Structure with restriction Queue First-In-First-Out (FIFO) data structureFIFO the first element added to the queue will be the first one to be removed (post office, bank etc)

in First In First Out out Queue

Linear Data Structure with restriction Stack Based on the principle of Last In First Out (LIFO)Last In First Out Stacks are used extensively at every level of a modern computer system (compiler etc.)

Stack top

in out Last In First Out Stack

Linear Data Structure with no restriction Linked list consists of a sequence of nodes, each containing arbitrary data fields and one or two references ("links") pointing to the next and/or previous nodesnodesfieldsreferences

Linear Data Structure with no restriction

Sorted linked list Data stored in ascending or descending order with no duplicates Insertion at front, middle or rear of the list Deletion will not affect the ascending / descending order of the list Unsorted linked list A linked list with no ordering

Non-linear Data Structure Binary Tree A data structure based on a tree structure A tree structure is a way of representing the hierarchical nature of a structure in a graphical formhierarchicalstructure a binary tree is a tree data structure in which each node has at most two childrentree data structurechildren Used for searching big amount of data

Tree Root leaf Children / Sibling Node Link

Programming Principle

Seven Key Issues in Programming 1. Modularity 2. Style 3. Modifiability 4. Ease of Use 5. Fail-safe programming 6. Debugging 7. Testing

Key Issues in Programming: Modularity Modularity has a favorable impact on Constructing programs – small/large modules Debugging programs – task of debugging large programis reduced to small modular program. Reading programs- easier to understand compared to large program Modifying programs – reduce large modification by concentrating on modules Eliminating redundant code – by calling the modules will avoid the same code to be written multiple times

Key Issues in Programming: Style 1. Use of private data members – hide data members from modules – information hiding 2. Proper use of reference arguments – pass by value / pass by reference 3. Proper use of methods to reduce coupling 4. Avoidance of global variables in modules – thru encapsulation 5. Error handling – invalid input : action to handle 6. Readability – code easy to follow 7. Documentation – well documented

Key Issues in Programming: Modifiability Program need to change after each iteration. Requires program to be written in a way that is easy to modify. Modifiability is easier through the use of Named constants const int number = 200; int scores[number]; The typedef statement typedef float cpaStudent; typedef long double cpaStudent;

Key Issues in Programming: Ease of Use In an interactive environment, the program should prompt the user for input in a clear manner A program should always echo its input The output should be well labeled and easy to read.

Key Issues in Programming: Fail-Safe Programming Fail-safe programs will perform reasonably no matter how anyone uses it Test for invalid input data and program logic errors Enforce preconditions Check argument values

Key Issues in Programming: Debugging Programmer must systematically check a program’s logic to find where an error occurs Tools to use while debugging: – Single-stepping – Watches – Breakpoints – cout statements – Dump functions

Key Issues in Programming: Testing Levels Unit testing: Test methods, then classes Integration testing: Test interactions among modules System testing: Test entire program Acceptance testing: Show that system complies with requirements

Key Issues in Programming: Testing Types Open-box (white-box or glass-box) testing Test knowing the implementation Test all lines of code (decision branches, etc.) Closed-box (black-box or functional) testing Test knowing only the specifications

Development Paradigm

System Development Process Understand the problem: Input Output Process Algorithm is the steps to solve problems Develop the solution ( Algorithm ): Structure chart Pseudocode Flowchart Converting design to computer codes. e.g: Flowchart -> C program

Coding Coding is a process of converting flowchart to program code (source code) But, before you can start doing this, you should learn some basics including the language itself.

The conversion is almost straight forward Example: multiplying two numbers void main (void) { printf(“Enter the first number=> ”); scanf(“%d”,&A); printf(“Enter the second number=> ”); scanf(“%d”,&B); C = A * B; printf(“The Result is %d”, C); return; } Source Code The program still cannot be executed. It is not completed yet.

You will get these errors Error 1: Call to undefined function ‘printf’ We’re trying to call a function that is not recognized by the compiler. Error 3: Undefined symbol ‘A’ We’re trying to use a variable but it has never been defined. Compiler doesn’t recognize it

Fix the errors and complete the program This statement will help the compiler to recognize function ‘printf’ and function ‘scanf’ Variable must be declared before we can use it

Conclusion In this class you have learned about: Data structure and types of data stuructures Algorithm and its characteristics Programing principle System development process The knowledge given is to ensure that you are able to provide good solution to problem solving

References Frank M. Carano, Data Abstraction and problem solving with C++. Nor Bahiah et al. Struktur data & algoritma menggunakan C++.