Today’s Topics O-Notation Testing/Debugging Data Structures Next Class: Writing correct programs:Column 4.

Slides:



Advertisements
Similar presentations
Algorithms (and Datastructures) Lecture 3 MAS 714 part 2 Hartmut Klauck.
Advertisements

Advanced Programming 15 Feb The “OI” Programming Process Reading the problem statement Thinking Coding + Compiling Testing + Debugging Finalizing.
Sorting Really Big Files Sorting Part 3. Using K Temporary Files Given  N records in file F  M records will fit into internal memory  Use K temp files,
White Box and Black Box Testing Tor Stålhane. What is White Box testing White box testing is testing where we use the info available from the code of.
Order Statistics Sorted
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
FIT FIT1002 Computer Programming Unit 19 Testing and Debugging.
Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
ISOM MIS 215 Module 7 – Sorting. ISOM Where are we? 2 Intro to Java, Course Java lang. basics Arrays Introduction NewbieProgrammersDevelopersProfessionalsDesigners.
Data Structures Data Structures Topic #13. Today’s Agenda Sorting Algorithms: Recursive –mergesort –quicksort As we learn about each sorting algorithm,
Unit Testing CSSE 376, Software Quality Assurance Rose-Hulman Institute of Technology March 27, 2007.
Fall 2006CENG 7071 Algorithm Analysis. Fall 2006CENG 7072 Algorithmic Performance There are two aspects of algorithmic performance: Time Instructions.
CPSC 231 Organizing Files for Performance (D.H.) 1 LEARNING OBJECTIVES Data compression. Reclaiming space in files. Compaction. Searching. Sorting, Keysorting.
Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
Concept of Basic Time Complexity Problem size (Input size) Time complexity analysis.
Testing an individual module
Advanced Topics in Algorithms and Data Structures 1 Two parallel list ranking algorithms An O (log n ) time and O ( n log n ) work list ranking algorithm.
Data Structures Introduction Phil Tayco Slide version 1.0 Jan 26, 2015.
Dr. Pedro Mejia Alvarez Software Testing Slide 1 Software Testing: Building Test Cases.
SIGCSE Tradeoffs, intuition analysis, understanding big-Oh aka O-notation Owen Astrachan
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Data Structures Trees.
1 Data Structures and Algorithms Sorting. 2  Sorting is the process of arranging a list of items into a particular order  There must be some value on.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 15: Linked data structures.
1 Debugging and Testing Overview Defensive Programming The goal is to prevent failures Debugging The goal is to find cause of failures and fix it Testing.
Chapter 19: Binary Trees. Objectives In this chapter, you will: – Learn about binary trees – Explore various binary tree traversal algorithms – Organize.
Basic Concepts 2014, Fall Pusan National University Ki-Joune Li.
CSCA48 Course Summary.
Introduction. 2COMPSCI Computer Science Fundamentals.
 200 Total Points ◦ 74 Points Writing Programs ◦ 60 Points Tracing Algorithms and determining results ◦ 36 Points Short Answer ◦ 30 Points Multiple Choice.
Chapter 9 Priority Queues, Heaps, Graphs, and Sets.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 19: Searching and Sorting.
1 Software Testing. 2 Path Testing 3 Structural Testing Also known as glass box, structural, clear box and white box testing. A software testing technique.
Linked Structures See Section 3.2 of the text.. First, notice that Java allows classes to be recursive, in the sense that a class can have an element.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Targil 6 Notes This week: –Linear time Sort – continue: Radix Sort Some Cormen Questions –Sparse Matrix representation & usage. Bucket sort Counting sort.
CS162 - Topic #11 Lecture: Recursion –Problem solving with recursion –Work through examples to get used to the recursive process Programming Project –Any.
Testing Testing Techniques to Design Tests. Testing:Example Problem: Find a mode and its frequency given an ordered list (array) of with one or more integer.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
Testing and Debugging Session 9 LBSC 790 / INFM 718B Building the Human-Computer Interface.
CSC 211 Data Structures Lecture 13
Week 9 Data structures / collections. Vladimir Misic Week 9 Monday, 4:20:52 PM2 Data structures (informally:) By size: –Static (e.g. arrays)
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
What is Testing? Testing is the process of finding errors in the system implementation. –The intent of testing is to find problems with the system.
ITI 1120 Lab #5 Contributors: S. Boyd, R. Plesa, A. Felty, D. Inkpen, A. Williams, D. Amyot.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Testing Chapter 23 IB103 Week 12 (part 3). Verify that a complex (any) program works correctly, that the program meets specifications The chapter reviews.
HKOI Programming HKOI Training Team (Intermediate) Alan, Tam Siu Lung Unu, Tse Chi Yung.
Heaps and basic data structures David Kauchak cs161 Summer 2009.
(c) , University of Washington18a-1 CSC 143 Java Searching and Recursion N&H Chapters 13, 17.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 23 Algorithm Efficiency.
Theory and Practice of Software Testing
CompSci 100E 18.1 Testing and Debugging Robert A Wagner.
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: Graphs Data Structures.
Chapter 3: Sorting and Searching Algorithms 3.1 Searching Algorithms.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 17: Linked Lists.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 18: Linked Lists.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Sorts, CompareTo Method and Strings
Top 50 Data Structures Interview Questions
Contest strategy.
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
CSE 403 Lecture 18 Debugging.
CSE 403 Lecture 17 Coding.
Chapter 15 Debugging.
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
CPSC 315 – Programming Studio
An Introduction to Debugging
CSE 1020:Software Development
Presentation transcript:

Today’s Topics O-Notation Testing/Debugging Data Structures Next Class: Writing correct programs:Column 4

O-Notation Running times (number of operations) in terms of the input size Best-case, worst-case, expected (average) case Example: quicksort has worst-case of n 2 but best/average case of n log n.

Cases NotationNameExample O(1) constantarray index O(log n) logarithmicbinary search O(n) linearstring comparison O(n log n) n log nquicksort O(n 2 ) quadraticsimple sorting O(n 3 ) cubicmatrix multiplication O(2 n ) exponentialset partitioning

So what? CaseN = 16N=64N=256N=1024N=4096 O(1)11111 O(log n) O(n) O(n log n) O(n 2 ) O(n 3 ) O(2 n )65536

Testing/Debugging Testing – Does my program do what it is supposed to do?? Debugging – Why does my program do that!!??!!

Testing Formal discipline Focus on informal approach Goal: Make the program fail! Testing can only show bugs, not verify their absence Why test? Increase confidence in the correctness of the code

Testing Approaches Specification based – test input derived from the formal or informal problem description (black box) Implementation based – test input derived from the structure of the code (white box) There are hybrid approaches as well

General Testing Strategies Test incrementally Test simple parts first Know what output you expect Program defensively – check pre- and post- conditions, check cases even if unlikely. Regression testing – save your test cases

Test Case Strategies Test at boundaries – empty case, input limit, limit + 1 Special cases Classes of inputs Exercising code –Statement level –Branch (choice level) –Function level

Debugging Less of a formal discipline – backwards reasoning When you find a problem (during your incremental testing!): –Look for familiar patterns – Have I seen this bug before? –Examine the most recent change –Look for multiple occurrences of the bug –Debug now, not later –Read the code –Explain the code to someone else

Finding reproducible bugs Display output Stack trace Assertions to check pre and post conditions Draw a picture Use a debugger

Non-reproducible bugs On a given input, sometimes the problem occurs, sometimes not –Uninitialized variables –Memory allocation problems –Dangling pointers –External environment (file characteristics, environment variables,…)

Data Structures Choice of data structures key to success Array/matrix Linked lists Linked structures – trees, graphs, …

A Node Too Far: Data Structures Unordered graph – can represent with an array of links per node or a 2D matrix array[30] with name and marker 2D matrix of connections between node i and j

A Node Too Far: Algorithm For node k and TTL n, DFS from k of length n, marking nodes as visited DFS_to_n(int k, int n){ if (n > 0) { mark node k for (i=0;i<MAX_NODES;++i) if (matrix(k,i) == 1) DFS_to_n(i,n-1) } After DFS, count the number of unmarked nodes: