Text UI. Data Store Ø Example of a backend to a real Could add a different user interface. Good judgment comes from experience

Similar documents
Lab 11: Pair Programming. Review: Pair Programming Roles

Designing a Social Network Prep for Lab 10. March 26, 2018 Sprenkle - CSCI Why classes and objects? How do we create new data types?

Review of Lab 9. Review Lab 9. Social Network Classes/Driver Data. Lab 10 Design

Coverage tools Eclipse Debugger Object-oriented Design Principles. Oct 26, 2016 Sprenkle - CSCI209 1

Objec&ves. Usability Project Discussion. May 9, 2016 Sprenkle - CSCI335 1

Comparison Sorts. EECS 2011 Prof. J. Elder - 1 -

Chapter 8: Recursion

CSCI211: Intro Objectives

Minimum Spanning Tree Union-Find Data Structure. Feb 28, 2018 CSCI211 - Sprenkle. Comcast wants to lay cable in a neighborhood. Neighborhood Layout

Proving correctness of Stable Matching algorithm Analyzing algorithms Asymptotic running times

Analyzing proofs Introduction to problem solving. Wiki: Everyone log in okay? Decide on either using a blog or wiki-style journal?

Maps, Hash Tables and Dictionaries

New features in Oracle 11g for PL/SQL code tuning.

Maps and Hash Tables. EECS 2011 Prof. J. Elder - 1 -

Objec&ves. Review. JUnit Coverage Collabora&on

Search Trees. Chapter 10. CSE 2011 Prof. J. Elder Last Updated: :51 PM

BMI for everyone. Compsci 6/101: PFTW. Accumulating a value. How to solve an APT. Review how APTs and Python work, run

Objec&ves. Review. So-ware Quality Metrics Sta&c Analysis Tools Refactoring for Extensibility

CS 5523: Operating Systems

11/15/13. Objectives. Review. Our Screen Saver Dependencies. Our Screen Saver Dependencies. Project Deliverables Timeline TEAM FINAL PROJECT

Overview. Ø Neural Networks are considered black-box models Ø They are complex and do not provide much insight into variable relationships

Midterm Review. EECS 2011 Prof. J. Elder - 1 -

Tie Breaking in STV. 1 Introduction. 3 The special case of ties with the Meek algorithm. 2 Ties in practice

Priority Queues & Heaps

CSCI 325: Distributed Systems. Objec?ves. Professor Sprenkle. Course overview Overview of distributed systems Introduc?on to reading research papers

Hoboken Public Schools. Project Lead The Way Curriculum Grade 8

Priority Queues & Heaps

Discourse Obligations in Dialogue Processing. Traum and Allen Anubha Kothari Meaning Machines, 10/13/04. Main Question

IBM Cognos Open Mic Cognos Analytics 11 Part nd June, IBM Corporation

TAFTW (Take Aways for the Week) APT Quiz and Markov Overview. Comparing objects and tradeoffs. From Comparable to TreeMap/Sort

Thinking Like a Computer Scien4st About Ancient Roman Graffi4

The Effectiveness of Receipt-Based Attacks on ThreeBallot

Support Vector Machines

Kjell-Einar Anderssen. Country Manager Norway - Nutanix

Priority Queues & Heaps

The HeLIx + inversion code Genetic algorithms. A. Lagg - Abisko Winter School 1

NEW YORK CITY COLLEGE OF TECHNOLOGY The City University of New York

Instructors: Tengyu Ma and Chris Re

General Framework of Electronic Voting and Implementation thereof at National Elections in Estonia

Tier 4 FAQs for Students

File Systems: Fundamentals

Hoboken Public Schools. AP Calculus Curriculum

Chapter 11. Weighted Voting Systems. For All Practical Purposes: Effective Teaching

WORLD INTELLECTUAL PROPERTY ORGANIZATION GENEVA SPECIAL UNION FOR THE INTERNATIONAL PATENT CLASSIFICATION (IPC UNION) AD HOC IPC REFORM WORKING GROUP

The Federal in Federalism STEP BY STEP

Review: SoBware Development

LPGPU. Low- Power Parallel Compu1ng on GPUs. Ben Juurlink. Technische Universität Berlin. EPoPPEA workshop

Evidence-Based Practices and Access to Justice

Hybrid and electric vehicle ac0vi0es in Latvia. 37 th IA- HEV ExCo mee0ng, October 2012

THE PREPARED CURRICULUM:

bitqy The official cryptocurrency of bitqyck, Inc. per valorem coeptis Whitepaper v1.0 bitqy The official cryptocurrency of bitqyck, Inc.

Hoboken Public Schools. PLTW Introduction to Computer Science Curriculum

Recommendations For Reddit Users Avideh Taalimanesh and Mohammad Aleagha Stanford University, December 2012

Quality of Service in Optical Telecommunication Networks

Review: Background on Bits. PFTD: What is Computer Science? Scale and Bits: Binary Digits. BIT: Binary Digit. Understanding scale, what does it mean?

CS388: Natural Language Processing Coreference Resolu8on. Greg Durrett

Please reach out to for a complete list of our GET::search method conditions. 3

Why Biometrics? Why Biometrics? Biometric Technologies: Security and Privacy 2/25/2014. Dr. Rigoberto Chinchilla School of Technology

Dynamic Results in Real-Time

Parliamentary Procedure for Meetings

Electronic Voting For Ghana, the Way Forward. (A Case Study in Ghana)

Elec%ons & Legisla%ve Session WAPA ANNUAL CONVENTION DECEMBER 2, 2014

Midterm Review. EECS 2011 Prof. J. Elder - 1 -

IMPLEMENTATION OF SECURE PLATFORM FOR E- VOTING SYSTEM

SUMMARY INTRODUCTION. xiii

ICCES Oversight Committee Minutes of Meeting

Egypt s Mubarak in landslide election win

ACCESSING GOVERNMENT INFORMATION IN. British Columbia

Selected ACE: Data Distributions Investigation 1: #13, 17 Investigation 2: #3, 7 Investigation 3: #8 Investigation 4: #2

THE LOUISIANA SURVEY 2018

NEW PERSPECTIVES ON THE LAW & ECONOMICS OF ELECTIONS

INTEGRITY APPLICATIONS, INC. (Exact name of registrant as specified in its charter)

Online Voting System Using Aadhar Card and Biometric

Influence in Social Networks

MSL. Mul'-Robot Manipula'on without Communica'on. Zijian Wang and Mac Schwager

Hoboken Public Schools. Environmental Science Honors Curriculum

ECE250: Algorithms and Data Structures Trees

Decentralised solutions for renewable energies and water in developing countries

Nicole Virga Bau3sta March 20, 2017

OPTIMIZING THE NEW CANADIAN EXPERIENCE SHAGUN FLAWSON AGOSH

Batch binary Edwards. D. J. Bernstein University of Illinois at Chicago NSF ITR

Case Study. MegaMatcher Accelerator

FREQUENTLY ASKED QUESTIONS (FAQs) ON AED WITH CERTIFICATE OF ORIGIN (CO)

Thinking back to the Presidential Election in 2016, do you recall if you supported ROTATE FIRST TWO, or someone else?

HASHGRAPH CONSENSUS: DETAILED EXAMPLES

Lab 3: Logistic regression models

Spurring Growth in the Global Economy A U.S. Perspective World Strategic Forum: Pioneering for Growth and Prosperity

Case: 1:16-cv Document #: 586 Filed: 01/03/18 Page 1 of 10 PageID #:10007 FOR THE NORTHERN DISTRICT OF ILLINOIS EASTERN DIVISION

Police Department. Mission: reduce crime and maintain safe neighborhoods in the City of Orlando

THE PREPARED CURRICULUM: FOR POST-SECONDARY AND CAREER READINESS

BUSI 2503 Section A BASIC FINANCIAL MANAGEMENT Summer, 2013(May & June)

Objec&ves. Tes&ng 11/8/16. by Frederick P. Brooks, Jr., 1986

SMS based Voting System

TAKING AND DEFENDING DEPOSITIONS

Residence Permit Extension

Clarification of apolitical codes in the party identification summary variable on ANES datasets

Third Grade, Unit 6 American Government Basics

TIPS FOR APPEALS: How to Persuade on Appeal. Elizabeth Lang Miers January 4, 2012 Dallas Bar Association: Solo and Small Firm Section

Inequality and Its Discontents: A Canadian Perspective

AADHAAR BASED VOTING SYSTEM USING FINGERPRINT SCANNER

Transcription:

Reviewing Lab 10 Text UI Created two classes Ø Used one class within another class Ø Tested them Graphical UI Backend Data Store Ø Example of a backend to a real applica@on Could add a different user interface Good judgment comes from experience Ø Test methods ager wri@ng method Ø Remember your data types Ø Refer to the data type s API What could you do to improve your development process? Mar 30, 2018 Sprenkle - CSCI111 1 Review We discussed two different search techniques: Ø What were they? Ø How do they compare? Mar 30, 2018 Sprenkle - CSCI111 2 1

Review: Search Using in Review Iterates through a list, checking if the element is found Known as linear search Implementa*on: def linearsearch(searchlist, key): for elem in searchlist: if elem == key: value return True return False pos 8 5 3 7 0 1 2 3 What are the strengths and weaknesses of implementing search this way? search.py Mar 30, 2018 Sprenkle - CSCI111 3 Review: Linear Search Overview: Iterates through a list, checking if the element is found Benefits: Ø Works on any list Drawbacks: Ø Slow, on average: needs to check each element of list if the element is not in the list Mar 30, 2018 Sprenkle - CSCI111 4 2

Review: Binary Search: Eliminate Half the Possibili@es Repeat un@l find value (or looked through all values) Ø Guess middle value of possibili@es (not middle posi,on) Ø If match, found! Ø Otherwise, find out too high or too low Ø Modify your possibili@es Eliminate the possibili@es from your number and higher/lower, as appropriate Known as Binary Search Mar 30, 2018 Sprenkle - CSCI111 5 Binary Search Implementa@on def search(searchlist, key): low=0 high = len(searchlist)-1 while low <= high : mid = (low+high)//2 if searchlist[mid] == key: return mid # return True elif key > searchlist[mid]: low = mid+1 else: high = mid-1 return -1 # return False If you just want to know if it s in the list search2.py Mar 30, 2018 Sprenkle - CSCI111 6 3

Binary Search Example of a Divide and Conquer algorithm Ø Break into smaller pieces that you can solve Benefits: Ø Faster to find elements (especially with larger lists) Drawbacks: Ø Requires that data can be compared lt, eq methods implemented by the class (or another solu@on) Ø List must be sorted before searching Takes @me to sort Mar 30, 2018 Sprenkle - CSCI111 7 Key Ques@ons in Computer Science How can we efficiently organize data? How can we efficiently search for data, given various constraints? Ø Example: data may or may not be sortable What are the tradeoffs? Mar 30, 2018 Sprenkle - CSCI111 8 4

Empirical Study of Search Techniques Goal: Determine which technique is better under various circumstances How long does it take to find various keys? Ø Measure by the number of comparisons Ø Vary the size of the list and the keys Ø What are good tests for the lists and the keys? search_compare.py Mar 30, 2018 Sprenkle - CSCI111 9 Empirical Study of Search Techniques Analyzing Results Ø By how much did the number of comparisons for linear search vary? Ø By how much did the number of comparisons for binary search vary? What conclusions can you draw from these results? search_compare.py Mar 30, 2018 Sprenkle - CSCI111 10 5

Search Strategies Summary Which search strategy should I use under the following circumstances? Ø I have a short list Ø I have a long list Ø I have a long sorted list Mar 30, 2018 Sprenkle - CSCI111 11 Search Strategies Summary Which search strategy should I use under the following circumstances? Ø I have a short list How short? How many searches? Linear (in) Ø I have a long list Linear (in) - because don t know if in order, comparable Alterna@vely, may want to sort the list and then perform binary search, if sor@ng first won t be more effort than just sor@ng. Ø I have a long sorted list Binary Mar 30, 2018 Sprenkle - CSCI111 12 6

Extensions to Search In FaceSpace, we want to find people who have a certain name. Consider what happens when searchlist is a list of s and key is a name (a str) We want to find a whose name matches the key and return the Mar 30, 2018 Sprenkle - CSCI111 13 List of objects 0 1 2 3 4 Id: 1 Gal Id: 2 Natalie Id: 3 Chris Id: 4 Ben Id: 5 Samuel Example: looking for a person with the name Chris Mar 30, 2018 Sprenkle - CSCI111 14 7

List of objects 0 1 2 3 4 Id: 1 Gal Id: 2 Natalie Id: 3 Chris Id: 4 Ben Id: 5 Samuel 0 1 2 3 4 Id: 4 Ben Id: 3 Chris Id: 1 Gal Id: 2 Natalie Id: 5 Samuel Sorted by name, e.g., personlist.sort(key=.getname) Mar 30, 2018 Sprenkle - CSCI111 15 Consider what happens when Extensions to Solu@on searchlist is a list of s, key is a str def search(searchlist, key): represen@ng a name low=0 Goal: find a person with a high = len(searchlist)-1 certain name while low <= high : mid = (low+high)//2 if searchlist[mid] == key: return mid elif key > searchlist[mid]: # look in upper half low = mid+1 else: # look in lower half high = mid-1 return -1 0 1 2 3 4 Id: 4 Id: 3 Id: 1 Id: 2 Id: 5 Mar 30, 2018 Sprenkle Ben - CSCI111 Chris Gal Natalie Samuel 16 8

Extensions to Solu@on def search(searchlist, key): Goal: find a with a certain name low=0 high = len(searchlist)-1 while low <= high : What should we do to make mid = (low+high)//2 search results more intui@ve? if searchlist[mid] == key: return mid elif key > searchlist[mid]: # look in upper half low = mid+1 else: # look in lower half high = mid-1 return -1 Consider what happens when searchlist is a list of s, key is a str represen@ng the name 0 1 2 3 4 Id: 4 Id: 3 Id: 1 Id: 2 Id: 5 Mar 30, 2018 Sprenkle Ben - CSCI111 Chris Gal Natalie Samuel 17 Summary of Extensions to Solu@on Check the name of the at the midpoint Represent, handle when no matches What could we do if more than one person has that name? Note: we re not implemen@ng name contains Ø How could we implement that? Mar 30, 2018 Sprenkle - CSCI111 18 9

How Does Sort Work? Several different ways we can sort One intui@ve way: break down the sort problem into smaller problems Ø Let s say we have a deck of cards that needs to be sorted Mar 30, 2018 Sprenkle - CSCI111 19 Algorithm: Merge Sort I have a list to sort Ø Break the list into two halves Ø Sort the first half Ø Sort the second half Ø Merge those sorted halves together Mar 30, 2018 Sprenkle - CSCI111 20 10

Algorithm: Merge Sort def mergesort( listofnumbers ): firsthalf = listofnumbers[:len(listofnumbers)//2 ] secondhalf = listofnumbers[len(listofnumbers)//2:] sortedfirst = mergesort( firsthalf ) sortedsecond = mergesort( secondhalf ) whole = merge( sortedfirst, sortedsecond ) return whole But when do we stop calling mergesort? Right now, it seems like we will keep calling mergesort repeatedly! Mar 30, 2018 Sprenkle - CSCI111 21 Algorithm: Merge Sort def mergesort( listofnumbers ): if len(listofnumbers) == 2: # base case # sort those two numbers if listofnumbers[0] > listofnumbers[1]: temp = listofnumbers[0] listofnumbers[0] = listofnumbers[1] listofnumbers[1] = temp return listofnumbers firsthalf = listofnumbers[:len(listofnumbers)//2 ] secondhalf = listofnumbers[len(listofnumbers)//2:] sortedfirst = mergesort( firsthalf ) sortedsecond = mergesort( secondhalf ) whole = merge( sortedfirst, sortedsecond ) return whole Mar 30, 2018 Sprenkle - CSCI111 22 11

Exam 2 Results Section Total A B C Average 82.20 78.46 84.80 82.78 Median 86.50 79.17 85.94 86.54 Problems with strings and dictionaries Mar 30, 2018 Sprenkle - CSCI111 23 Looking Ahead Lab 11 Mar 30, 2018 Sprenkle - CSCI111 24 12