Introduction to Data Structures & Algorithm

Similar documents
Chapter 1: Principles of Programming and Software Engineering

Chapter 1: Programming Principles

12 Abstract Data Types

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

SCJ2013 Data Structure & Algorithms. Binary Search Tree. Nor Bahiah Hj Ahmad

Data Abstractions. National Chiao Tung University Chun-Jen Tsai 05/23/2012

Short Notes of CS201

CS201 - Introduction to Programming Glossary By

Objectives. Chapter 4: Control Structures I (Selection) Objectives (cont d.) Control Structures. Control Structures (cont d.) Relational Operators

CSE030 Fall 2012 Final Exam Friday, December 14, PM

Chapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d.

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?

Software Development Fundamentals (SDF)

ONE MARKS QUESTION AND ANSWERS

C++ Programming: From Problem Analysis to Program Design, Fourth Edition. Chapter 4: Control Structures I (Selection)

Basic Types & User Defined Types

C++ (Non for C Programmer) (BT307) 40 Hours

CompuScholar, Inc. Alignment to Nevada "Computer Science" Course Standards

Data Structure - Binary Tree 1 -

1. Stack overflow & underflow 2. Implementation: partially filled array & linked list 3. Applications: reverse string, backtracking

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.

Introduction to Programming Using Java (98-388)

Purpose of Review. Review some basic C++ Familiarize us with Weiss s style Introduce specific constructs useful for implementing data structures

Problem Solving with C++

CS Sorting Terms & Definitions. Comparing Sorting Algorithms. Bubble Sort. Bubble Sort: Graphical Trace

PROGRAMMING IN C++ (Regulation 2008) Answer ALL questions PART A (10 2 = 20 Marks) PART B (5 16 = 80 Marks) function? (8)

1 P a g e A r y a n C o l l e g e \ B S c _ I T \ C \

Standard. Number of Correlations

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

IUSE Knowledge Test. 1. Demographic Questions. IUSE Knowledge Test. 2. Computational Thinking Knowledge Test

Lecture Chapter 2 Software Development

The goal of this assignment is to implement and test Breadth-first search (BFS) on a simple navigation problem (path-finding).

C++: Const Function Overloading Constructors and Destructors Enumerations Assertions

CS301 - Data Structures Glossary By

Outline. Program development cycle. Algorithms development and representation. Examples.

Chapter 9. Priority Queue

Largest Online Community of VU Students

Data Structures and Abstractions with Java

[ DATA STRUCTURES] to Data Structures

Data Structure. IBPS SO (IT- Officer) Exam 2017

Chapter 8: Data Abstractions

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

Computer Components. Software{ User Programs. Operating System. Hardware

Code No: R Set No. 1

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010

Cpt S 122 Data Structures. Course Review Midterm Exam # 1

Chapter 8 Algorithms 1

Advanced Algorithms: Project

Lecture Notes. char myarray [ ] = {0, 0, 0, 0, 0 } ; The memory diagram associated with the array can be drawn like this

Graphs. The ultimate data structure. graphs 1

MIDTERM EXAMINATION Spring 2010 CS301- Data Structures

Absolute C++ Walter Savitch

CS 231 Data Structures and Algorithms, Fall 2016

Variables and Constants

Programming II (CS300)

Name CPTR246 Spring '17 (100 total points) Exam 3

9/17/2015 7:56 AM. CSCE 625 Programing Assignment #1 due: Tues, Sep 22 (by start of class) Objective

Introduction to Computer Science

UNIT-4 Black Box & White Box Testing

Representation Techniques for Logical Spaces

TIE Graph algorithms

Object-Oriented Programming

DATA STRUCTURES AND ALGORITHMS

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

Introduction to C Final Review Chapters 1-6 & 13

Software Design Fundamentals. CSCE Lecture 11-09/27/2016

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Introduction and Overview

Graphs. The ultimate data structure. graphs 1

Euclid s algorithm, 133

UNIT-4 Black Box & White Box Testing

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

Tokens, Expressions and Control Structures

AIMS Embedded Systems Programming MT 2017

MLR Institute of Technology

CGS 2405 Advanced Programming with C++ Course Justification

COP 1220 Introduction to Programming in C++ Course Justification

Module 10A Lecture - 20 What is a function? Why use functions Example: power (base, n)

Higher Computing Science Software Design and Development - Programming Summary Notes

Queue Linked List Implementation

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

CSE 230 Computer Science II (Data Structure) Introduction

MPATE-GE 2618: C Programming for Music Technology. Syllabus

Data Structures and Algorithms in Java. Second Year Software Engineering

CSE 373: Practice Final

Graphs. CSE 2320 Algorithms and Data Structures Alexandra Stefan and Vassilis Athitsos University of Texas at Arlington

State two analytical tools used to understand feasibility of a proposed application. Acceptable answer(s) Guidance Max mks

Elementary Graph Algorithms. Ref: Chapter 22 of the text by Cormen et al. Representing a graph:

2015 Academic Challenge

PLD Semester Exam Study Guide Dec. 2018

Introduction to Programming

Chap 0: Overview. Overview of basic C++ syntax Refresh programming basics C++ Vs. Java differences Coding conventions used. EECS 268 Programming II 1

AE52/AC52/AT52 C & Data Structures JUNE 2014

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

1.1 Basic Concepts 1

Abstract Data Types. Different Views of Data:

5. Control Statements

CodeHS: Arkansas Standards Alignment

Motivation was to facilitate development of systems software, especially OS development.

Algorithm Design (8) Graph Algorithms 1/2

Transcription:

Introduction to Data Structures & Algorithm

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

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

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

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

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

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

Algorithm & Data Structure Flowchart to withdraw money from ATM machine Initial state

Algorithm & Data Structure n 3 types of algorithm basic control structure n Sequential n Selection n Repeatition (Looping)

Algorithm & Data Structure n n n Basic algorithm characteristics n n n n n 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 n Flowchart, pseudo code,structure chart, language etc Factors for measuring good algorithm n n Running time Total memory usage

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

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

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

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

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

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

Linear Data Structure with restriction n Queue n First-In-First-Out (FIFO) data structure n the first element added to the queue will bethefirstonetoberemoved(postoffice, to removed office, bank etc)

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

Stack Stack

Stack out in Last In First Out

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

Linear Data Structure with no restriction

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

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

Tree

Graph n A graph consists of a set of vertices, and a set of edges, such that each edge in is a connection between a pair of vertices. n Some applications require visiting every vertex in the graph exactly once.

Graph n The application may require that vertices be visited in some special order based on graph topology. n Examples: n Artificial Intelligence Search (Breadth-first search, depth first search) n Shortest paths problems n Web sites containing a link to and from other websites. n Graph that represent courses and the prerequisites.

Graph Directed and undirected graph

Network n Network is a directed graph. n Can be used to represent a route. n Example : n A route for an airline. n A route for delivery vehicles.

Network Weighted network that represents a route for a delivery truck. The route shows all cities in Johor for the truck to deliver items and the time taken for a journey from one city to another.

Programming Paradigm

Phases of Software Development n Provide a very systematic and organized approach for developing software.

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

Phases of Software Development n System Requirements Generally, this phase provide planning for the project. Identify objectives, job scope, resources such as cost, people and equipments for the project and provide schedule for the work plan. n Analysis Conduct preliminary investigation, study the current system, determine the user requirements and provide solution to the problem.

Phases of Software Development n Design Develop details of the system by dividing into modules. Prepare algorithms for each modules. n Coding Transfer from design (algorithms) to computer source codes. n System Testing To ensure that the system can work properly and free from errors, either syntax or logic errors. 3 types of testing: system testing, integration ti testing ti and acceptance test. t n Maintenance Monitor system performance; identify errors not detected during system testing, and enhancement to the system.

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 n Modularity has a favorable impact on n Constructing programs small/large modules n Debugging programs task of debugging large programis reduced to small modular program. n Reading gprograms- easier to understand compared to large program n Modifying programs reduce large modification by concentrating on modules n 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. n Modifiability is easier through the use of n Named constants const int number = 200; int scores[number]; n 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 t should be well labeled l 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 n Levels n Unit testing: ti Test methods, then classes n Integration testing: Test interactions among modules n System testing: Test entire program n Acceptance testing: Show that system complies with requirements

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

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

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