CS367 Intro to Data Structures

Slides:



Advertisements
Similar presentations
An Array-Based Implementation of the ADT List public class ListArrayBased implements ListInterface { private static final int MAX_LIST = 50; private Object.
Advertisements

CS 106 Introduction to Computer Science I 05 / 03 / 2010 Instructor: Michael Eckmann.
List Implementations That Use Arrays Chapter 5. 2 Chapter Contents Using a Fixed-Size Array to Implement the ADT List An Analogy The Java Implementation.
CS 307 Fundamentals of Computer Science 1 Lists and ArrayList many slides taken from Mike Scott, UT Austin.
Program Testing Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Queue, Deque, and Priority Queue Implementations Chapter 11 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Lecture 6 Software Testing and jUnit CS140 Dick Steflik.
Test plans CSCI102 - Systems ITCS905 - Systems MCS Systems.
Bags Chapter 1 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Chapter 10 – Testing and Debugging. Chapter Goals ► Learn techniques to test your code ► Learn to carry out unit tests ► Understand principles of test.
Abstract Data Types. What’s on the menu? What’s an abstract data type? How do you implement it? ADT List.
Testing Methods Carl Smith National Certificate Year 2 – Unit 4.
Black-box Testing.
Software Construction Lecture 18 Software Testing.
CS 106 Introduction to Computer Science I 04 / 25 / 2008 Instructor: Michael Eckmann.
1 Data Structures CSCI 132, Spring 2014 Lecture 20 Linked Lists.
(c) University of Washington16-1 CSC 143 Java Lists via Links Reading: Ch. 23.
Lists Chapter 4. 2 Chapter Contents Specifications for the ADT List Redefining the Specifications Using the ADT List Using a List Is Like Using a Vending.
Black Box Testing : The technique of testing without having any knowledge of the interior workings of the application is Black Box testing. The tester.
Chapter 3 Collections. Objectives  Define the concepts and terminology related to collections  Explore the basic structures of the Java Collections.
1 ArrayList Starring: Purse, Sr. Co-Starring: Purse, Jr. Poe Numbers.
CS 367 Introduction to Data Structures Lecture 2 Audio for Lecture 1 is available Homework 1 due Friday, September 18.
Collections Mrs. C. Furman April 21, Collection Classes ArrayList and LinkedList implements List HashSet implements Set TreeSet implements SortedSet.
Software Quality Assurance and Testing Fazal Rehman Shamil.
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 18 List ADT Animated Version.
ITEC 370 Lecture 18 Testing. Review Questions? Design document due W –System can be implemented just by following it Implementation –Methods (prototype,
1 CS162: Introduction to Computer Science II Abstract Data Types.
Chapter 3 Lists, Stacks, Queues. Abstract Data Types A set of items – Just items, not data types, nothing related to programming code A set of operations.
CSCI 62 Data Structures Dr. Joshua Stough September 23, 2008.
An Array-Based Implementation of the ADT List
Big-O notation Linked lists
Building Java Programs
CompSci 230 Software Construction
Efficiency of in Binary Trees
Week 3 - Friday CS221.
Data Structures Lakshmish Ramaswamy.
COP 3503 FALL 2012 Shayan Javed Lecture 8
Algorithm Analysis CSE 2011 Winter September 2018.
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.
Top Ten Words that Almost Rhyme with “Peas”
Prof. Neary Adapted from slides by Dr. Katherine Gibson
CMSC 341 Lecture 5 Stacks, Queues
Stacks.
Queues.
TCSS 143, Autumn 2004 Lecture Notes
Programming in Java Lecture 11: ArrayList
Lecture 3: Queues, Testing, and Working with Code
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Building Java Programs
CSE 143 Lecture 27: Advanced List Implementation
Adapted from Pearson Education, Inc.
Lecture 7: Linked List Basics reading: 16.2
Programming II (CS300) Chapter 07: Linked Lists and Iterators
Arrays and Collections
CS240: Advanced Programming Concepts
CSE 403 Lecture 13 Black/White-Box Testing Reading:
ArrayLists 22-Feb-19.
Collections Framework
Go to pollev.com/cse143.
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Building Java Programs
Programming II (CS300) Chapter 07: Linked Lists
Lecture 14: Testing Testing used to verify object behavior through designed test suites Can test Classes – “unit” testing Object interactions – “integration”
Lecture 7: Linked List Basics reading: 16.2
slides created by Ethan Apter and Marty Stepp
slides created by Marty Stepp
slides created by Marty Stepp
Java Generics & Iterators
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Presentation transcript:

CS367 Intro to Data Structures For Reading Assignments: See Syllabus Link http://www.cs.wisc.edu/~cs367-1 Vote Today! Should have completed JUnit Tutorial, TestDie and Die of A0. ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

This Lecture A0 Questions Testing List Be sure to read the FAQs Alternative to Array Implementation ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

Testing What should I test? How many tests are enough? Do I have to test my tests? How do I test my tests? How can I make my tests more understandable? How can I make my software easier to test? ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

Testing Level Design Strategy System (application) testing Unit (class) testing Design Strategy Black box (behavioral, functional, closed) White box (structural, clear box, open) ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

Black Box Testing Testing against the specification Tester does not examine the program source and does not need any further knowledge of the program other than its specifications. Internal workings are unknown ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

Black Box Testing Advantages: test is unbiased point of view of the user, not programmer. tests can be designed as soon as the specifications are complete. will discover if part of the specification has not been fulfilled. Advantages: The test is unbiased because the designer and the tester are independent of each other. The tester does not need knowledge of any specific programming languages. The test is done from the point of view of the user, not the designer. Test cases can be designed as soon as the specifications are complete. ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

Black Box Testing Disadvantages: redundant if the software designer has already run the test case. can be difficult to design. testing every possible input stream is unrealistic; therefore, many program paths will go untested. (undetected bugs) Disadvantages: The test can be redundant if the software designer has already run a test case. The test cases are difficult to design. Testing every possible input stream is unrealistic because it would take a inordinate amount of time; therefore, many program paths will go untested. ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

White Box Testing testing against the implementation use specific knowledge of code to design tests such that every line of source code is executed at least once. tests exception handling code. can include requiring every method to be individually tested. Example: int result = addition(2,2); if ( result == 4 ) System.out.print( "Pass: "); else System.out.print( "Fail: "); System.out.println( "addition(2,2)=" + result ); ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

White Box Testing Advantages Disadvantages will discover if any part of the implementation is faulty can test all paths (all lines of source). Disadvantages will not discover if part is missing works only if the tester knows what the program is supposed to do all visible (public) code must also be readable by tester. ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

Black Box vs White Box In order to fully test a software product both black and white box testing are required. ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

Back to List ADT Method prototype Method Description constructor void add(Object ob) add ob to end of list void add(int pos, Object ob) add ob to list at position pos boolean contains(Object ob) true if ob is in the list Object get(int pos) returns the object at position pos int size() returns the number of elements Object remove(int pos) returns the object at position pos and shifts the rest boolean isEmpty() returns true if there are no elements in the list ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

ListArray: Remove Operation Removing an element from an array leaves a hole! All remaining elements must be shifted to preserve the order of the elements and the efficiency of add and lookup operations. ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

ListADT Any disadvantages to array-based? initialize add access: unknown size: must guess add array may be full: must expand (how much?) to add at position: elements must be moved access: need to know position remove: to eliminate holes: elements must be moved ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

Alternate List Implementation Can we implement a List without using an array? YES Use a sequence of data and links to the next data to a ... LIST ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

Imagine a chain of links a train with linking cars a barrel of monkeys ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

Linked Implementation Each item has data and link to next element eggs bacon bread milk eggs bacon bread milk ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

How can I link data items? Design and implement a ListNode class, where each instance has: a reference to some data a link (a reference) to the next instance of ListNode. ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

Design of each Link (ListNode) Object data ListNode next ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

Link (ListNode) with data next String eggs null ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

add( "bacon" ) ListNode String eggs data next ListNode String bacon null next String bacon ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

add( 1, "milk" ) ListNode String eggs data ListNode String next milk null next String milk ListNode data null next String bacon ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

add( 1, "milk" ) ListNode String eggs data ListNode String next milk null next String bacon ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

1 2 add( 1, "milk" ) ListNode String eggs data ListNode String next 1 2 ListNode data next String milk ListNode data null next String bacon ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

Summary Testing Single-Linked List ADT Black box vs White Box ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018

Next Lecture More Linked List stuff Iterators & Big-O Read Chapter 7, 9 & 10 ©2004 Deb Deppeler. Some content based on work by Susan Horwitz ©2003. Used by permission. 12/7/2018