Algorithm Verification

In: Computers and Technology

Submitted By heimdall
Words 305
Pages 2
What will be printed if the input is 0?
- "You Fail"
What will be printed if the input is 100?
- "You did great"
What will be printed if the input is 51?
- "You did ok"
What will be printed if the user enters Wingding? "
- "Invalid input, Wingding is not a value between 0-100".
Is this design robust? If so, explain why. If not, explain what you can do to make it robust.
- The design is fine, in my opinion, however there is no specification on what the output should be if there is a non-numeric value inputted.
How many levels of nesting are there in this design?
- From what I can see there are four.
Provide a set of values that will test the normal operation of this program segment. Defend your choices.
- If 0 ≤ x and x ≤ 19 = "You Fail" If 0 ≤ x and x ≤ 61 = "You did ok " If 0 ≤ x and x ≤ 81 = "You did well" If 0 ≤ x and x ≤ 98 = "You did great "
Output "Valid Grade"
End IF

Provide a set of test values that will cause each branch to be executed.
- If 0 ≥ x and x ≤ 21 = "You Fail" If 45 ≥ x and x ≤ 68 = "You did ok " If 100 ≥ x and x ≤ 103 = "How did you do?" If 81 ≥ x and x ≤ 91 = "You did great "
Output "Invalid Grade"
End IF

Provide a set of test values that test the abnormal operation of this program segment.
- If 0 ≤ x and x ≤ Guess = "Invalid input, Guess is not a value between 0-100". If 0 ≤ x and x ≤ 122 = "How did you do?" If 0 ≤ x and x ≤ -50 = "How did you do?" If 0 ≤ x and x ≤ Hello = "Invalid input, Hello is not a value between 0-100".
Output "Invalid Grade"

Similar Documents

Introduction to Algorithms

... Introduction to Algorithms Second Edition This page intentionally left blank Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Clifford Stein Introduction to Algorithms Second Edition The MIT Press Cambridge, Massachusetts London, England Dubuque, IA St. Louis Montr´ al e Madison, WI Toronto McGraw-Hill Book Company Boston Burr Ridge, IL New York San Francisco This book is one of a series of texts written by faculty of the Electrical Engineering and Computer Science Department at the Massachusetts Institute of Technology. It was edited and produced by The MIT Press under a joint production-distribution agreement with the McGraw-Hill Book Company. Ordering Information: North America Text orders should be addressed to the McGraw-Hill Book Company. All other orders should be addressed to The MIT Press. Outside North America All orders should be addressed to The MIT Press or its local distributor. Third printing, 2002 c 2001 by The Massachusetts Institute of Technology First edition 1990 All rights reserved. No part of this book may be reproduced in any form or by any electronic or mechanical means (including photocopying, recording, or information storage and retrieval) without permission in writing from the publisher. This book was printed and bound in the United States of America. Library of Congress Cataloging-in-Publication Data Introduction to algorithms / Thomas H. Cormen . . . [et al.].—2nd ed. p. cm. Includes bibliographical references and...

Words: 426328 - Pages: 1706

Verification Letter for Credit

...Date Your Name Your Address City, State Zip Collection Agency Collection Agency Address City, State Zip Re: Acct # XXXX-XXXX-XXXX-XXXX To Whom It May Concern: I am sending this letter to you in response to a notice I received from you on (date of letter). Be advised, this is not a refusal to pay, but a notice sent pursuant to the Fair Debt Collection Practices Act, 15 USC 1692g Sec. 809 (b) that your claim is disputed and validation is requested. This is NOT a request for "verification" or proof of my mailing address, but a request for VALIDATION made pursuant to the above named Title and Section. I respectfully request that your office provide me with competent evidence that I have any legal obligation to pay you. Please provide me with the following: * What the money you say I owe is for; * Explain and show me how you calculated what you say I owe; * Provide me with copies of any papers that show I agreed to pay what you say I owe; * Provide a verification or copy of any judgment if applicable; * Identify the original creditor; * Prove the Statute of Limitations has not expired on this account; * Show me that you are licensed to collect in my state; and * Provide me with your license numbers and Registered Agent. If your offices have reported invalidated information to any of the three major Credit Bureau's (Equifax, Experian or TransUnion), said action might constitute fraud under both Federal and State Laws. Due to......

Words: 554 - Pages: 3

Advanced Algorithms

...Approximation Algorithms Springer Berlin Heidelberg NewYork Barcelona Hong Kong London Milan Paris Singapore Tokyo To my parents Preface Although this may seem a paradox, all exact science is dominated by the idea of approximation. Bertrand Russell (1872–1970) Most natural optimization problems, including those arising in important application areas, are NP-hard. Therefore, under the widely believed conjecture that P = NP, their exact solution is prohibitively time consuming. Charting the landscape of approximability of these problems, via polynomial time algorithms, therefore becomes a compelling subject of scientific inquiry in computer science and mathematics. This book presents the theory of approximation algorithms as it stands today. It is reasonable to expect the picture to change with time. The book is divided into three parts. In Part I we cover a combinatorial algorithms for a number of important problems, using a wide variety of algorithm design techniques. The latter may give Part I a non-cohesive appearance. However, this is to be expected – nature is very rich, and we cannot expect a few tricks to help solve the diverse collection of NP-hard problems. Indeed, in this part, we have purposely refrained from tightly categorizing algorithmic techniques so as not to trivialize matters. Instead, we have attempted to capture, as accurately as possible, the individual character of each problem, and point out connections between problems and algorithms for solving......

Words: 140657 - Pages: 563

Planning Algorithm

...Module 9 Planning Version 2 CSE IIT,Kharagpur Lesson 25 Planning algorithm - II Version 2 CSE IIT,Kharagpur 9.4.5 Partial-Order Planning Total-Order vs. Partial-Order Planners Any planner that maintains a partial solution as a totally ordered list of steps found so far is called a total-order planner, or a linear planner. Alternatively, if we only represent partial-order constraints on steps, then we have a partial-order planner, which is also called a non-linear planner. In this case, we specify a set of temporal constraints between pairs of steps of the form S1 < S2 meaning that step S1 comes before, but not necessarily immediately before, step S2. We also show this temporal constraint in graph form as S1 +++++++++> S2 STRIPS is a total-order planner, as are situation-space progression and regression planners Partial-order planners exhibit the property of least commitment because constraints ordering steps will only be inserted when necessary. On the other hand, situation-space progression planners make commitments about the order of steps as they try to find a solution and therefore may make mistakes from poor guesses about the right order of steps. Representing a Partial-Order Plan A partial-order plan will be represented as a graph that describes the temporal constraints between plan steps selected so far. That is, each node will represent a single step in the plan (i.e., an instance of one of the operators), and an arc will designate a temporal......

Words: 3041 - Pages: 13

Valuation and Verification

...* VERIFICATION AND VALUATION OF ASSETS AND LIABILITIES Spicer and Pegler have defined verification as “it implies an inquiry into the value, ownership and title, existence and possession and the presence of any charge on the assets”. Thus, verification includes verifying :- * The existence of the assets * Legal ownership and possession of the assets * Ascertaining that the asset is free from any charge, and * Correct valuation * auditor’s object According to the `statement of auditing practices’ issued by ICAI, “the auditor’s object in regard to assets generally is to satisfy that :- * They exist. * They belong to the client. * They are in the possession of the client or the persons authorized by him. * auditor’s object * They are not subject to undisclosed encumbrances or lien. * They are stated in the balance sheet at proper amounts in accordance with sound accounting principles, and * They are recorded in the accounts. POINTS TO BE CONSIDERED Existence : The auditor should confirm that all the assets of the company are physically existing on the date of balance sheet. Possession : The auditor has to verify that the assets are in the possession of the company on the date of balance sheet. Ownership : The auditor should confirm that the asset is legally owned by the company. Charge or lien : The auditor has to verify whether the asset is subject to any charge or lien. Record : The auditor should......

Words: 5789 - Pages: 24

Algorithms Notes

...DAG Topological Sort O(V+E) -performed on directed acyclic graph Linear ordering of all its vertices such that if G contains an edge (u,v) then u appears before v in the order. 1. call DFS(G) to compute finishing times v.f for each vertex v 2. as each vertex is finished insert it onto the front of a linked list 3. return the linked list of vertices 4. Lecture 5 (01/28) Posted on: Monday, January 28, 2013 Topics: Strongly Connected Components, Activity Selection Reading: CLRS (22.5, 16.1), KT (4.1) Scheduling Probelem Set of n activities which can be served only one at a time, each with start time s and finish time f Selecct a maximum-size subset of mutually compatible activities (meaning no overlap) GREEDY ALGORITHM Note that putting the job with the earliest finish time allows for the most amount of jobs to follow, because it allows the machine to have the most possible time to get to other jobs Take job with lowest finish time, then reduce set to all job that don’t overlap, then choose lowest finishing time, recursively. * Lecture 6 (01/30) Posted on: Wednesday, January 30, 2013 Topics: Activity Selection, Coloring Interval Graphs, Scheduling Reading: CLRS (16.1, 16.2), KT (4.1, 4.2) * Lecture 07 (02/04) Posted on: Wednesday, February 6, 2013 Topics: Minimizing Maximum Lateness, Sorting (Insertion Sort, Merge Sort, Quick Sort) Reading: CLRS (Chp 2, 7.1, 7.2), KT (4.2) Insertion sort Starting from the second element as key......

Words: 5019 - Pages: 21


...Algorithms Assignment 1 Kent Vuong Table of Contents Question 1 3 Machine Code (First Generation or 1GL) 3 Assembler (Second Generation or 2GL) 3 Procedural (Third Generation or 3GL) 3 Non-Procedural (Fourth Generation or 4GL) 4 Object Orientated 4 Describe the purpose and functions of an OS with the following terms 4 Scheduling 4 Managing Concurrency 4 Managing Memory 4 Managing Devices 5 File Systems 5 Describe the purpose of each of the following utility software programs. 5 File Compression 5 Defragmenter 5 Anti-Virus 5 Anti-Malware 5 What is application software, give three examples 5 What are the software licensing requirements for the following types of software 6 Freeware 6 Open Source 6 Shareware 6 Question 1 Machine Code (First Generation or 1GL) Machine Code is the Language that the Computer understands and reads, following the precise instructions, which is sometimes the problem with computers and the relaxed non-procedural human brain. The MIPS architecture provides a specific example for a machine code whose instructions are always 32 bits long. The general type of instruction is given by the op (operation) field, the highest 6 bits. J-type (jump) and I-type (immediate) instructions are fully specified by op. R-type (register) instructions include an additional field function to determine the exact operation. Assembler (Second Generation or 2GL) Assembler is a program which makes object codes by encoding...

Words: 1019 - Pages: 5

382 Algorithms

...CSC 382, Analysis of Algorithms Group Project For this project you need to make groups of 3-6 people and choose one of the following topics. Most of these topics require you to write a short paper and present it in class (20 points). For those you have the option to just submit a paper and not present for only 10 points. A list of topics: 1. Linear Programming 2. Approximation Algorithms 3. Max-Flow Min-Cut 4. Cryptography: Asymmetric Encryption 5. Complexity Theory 6. Programming Project: Implementing Algorithms, Comparing Running times (10 points, no presentation) For some topics you can find information in the course textbooks (and other textbooks). For the rest, you must research on your own - but I am willing to give suggestions if I have any. You may suggest another topic as well, but I need to approve it. Requirements Each paper is expected to be 3-5 pages long (single-spaced and at 11pt) and it should include references to your sources (which should be more than just Wikipedia). As long as the paper is complete and well-written, the length requirements should not be too important. However, more than 5 pages would be an overkill and less than 3 might not let you give the necessary information and explanations. As for the actual contents of the paper, you should address your classmates, who will receive a copy of the paper in class and before your presentation. You should explain the topic you have selected and give an appropriate 1 2 example. The specifics may differ...

Words: 796 - Pages: 4

Gnetic Algorithms

...Genetic Algorithms Basic Genetic Algorithm – Flow Chart 1. Initial Population 1. Initial Population ON ON | | GENERATE RANDOM POPULATION (POSSIBLE SOLUTIONS) | 2. Fitness Evaluation 2. Fitness Evaluation 3. Selection 3. Selection | | EVALUATE THE FITNESS OF EACH (BASED ON THE FITNESS FUNCTION) | | | CHOOSE PARENT FACTORS (BETTER FITNESS = BETTER CHANCE) | 4. Crossover 4. Crossover 5. Mutation 5. Mutation | | CROSSOVER THE PARENT TRAITS TO FORM NEW CHILDREN. (PROBABILITY) | | | MUTATION PROBABILITY APPLIED (MAINTAINS GENETIC DIVERSITY) | Acceptable? Acceptable? | | IF OPTIMIZATION CONDITIONS ARE NOT MET(REPEAT STEPS 2-5) * OR | Yes Yes End Process End Process | | IF THE MAXIMUM GENERATIONS ARE MET (TERMINATE) * OR | | | IF SATISFACTORY FITNESS LEVEL IS REACHED (END THE PROCESS) | KEY TERMS * INDIVIDUAL Any possible solution to the problem at hand, usually expressed in binary code * POPULATION Group of all individuals * CHROMOSOME Blueprint for an individual usually expressed in binary code. (Ex: 011011) * GENE An individual value in a chromosome, usually expressed as a “1” or “0” * PARENTS An original “individual” solution in the GA process that has passed the fitness function * CHILDREN A new solution to the problem formed through crossover and mutation from the parent solutions * SEARCH SPACE All possible solutions to the......

Words: 261 - Pages: 2

Kolmogorov Algorithm

...CSC 435 DESIGN AND ANALYSIS OF ALGORITHM GROUP THREE(3) ASSIGNMENT THE KOLMOGOROV COMPLEXITY ALGORITHM Computer Science: FMS/0704/11 FMS/0707/11 FMS/0720/11 FMS/0721/11 FMS/0728/11 Computing-with-Accounting: FMS/0818/11 FMS/0643/11 FMS/0749/11 FMS/0722/11 FMS/0729/11 FMS/0741/11 FMS/0829/11 FMS/0784/11 FMS/0812/11 FMS/0652/11 Kolmogorov complexity In algorithmic information theory (a subfield of computer science and mathematics), the Kolmogorov complexity (also known as descriptive complexity, Kolmogorov–Chaitin complexity, algorithmic entropy, or program-size complexity) of an object, such as a piece of text, is a measure of the computability resources needed to specify the object. It is named after Andrey Kolmogorov, who first published on the subject in 1963. For example, consider the following two strings of 32 lowercase letters and digits: abababababababababababababababab 4c1j5b2p0cv4w1x8rx2y39umgw5q85s7 The first string has a short English-language description, namely "ab 16 times", which consists of 11 characters. The second one has no obvious simple description (using the same character set) other than writing down the string itself, which has 32 characters. More formally, the complexity of a string is the length of the shortest possible description of the string in some fixed universal description language (the sensitivity of complexity relative to the choice of description language is discussed below)...

Words: 3373 - Pages: 14


...Design and Analysis of Computer Algorithm Assignment 2 Name: Boyu Zhang UTD-ID: 2021226566 Contents Problem 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Problem 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Problem 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Problem 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Problem 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Problem 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Problem 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Problem 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Problem1 This problem can solution by Dial’s algorithm in the lesson six. We can set up W+2 buckets with the labels of 0, 1, …, W, . Then we carry out the following steps: (a). Initial the buckets with node S be in the bucket 0 and all other nodes be in the bucket . (b). then select the node with the minimum temporary distance label. For the first time, it should be the source node S in the bucket 0. (c). Update the buckets information. Then some node should be moved from the bucket  to the corresponding distance bucket. (d). Remove the selected node from the bucket. Then repeat step 2 and 3 until there is no non-empty bucket.......

Words: 726 - Pages: 3

Introduction to Algorithms

...T C L I F F O R D STEIN INTRODUCTION TO ALGORITHMS T H I R D E D I T I O N Introduction to Algorithms Third Edition Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Clifford Stein Introduction to Algorithms Third Edition The MIT Press Cambridge, Massachusetts London, England c 2009 Massachusetts Institute of Technology All rights reserved. No part of this book may be reproduced in any form or by any electronic or mechanical means (including photocopying, recording, or information storage and retrieval) without permission in writing from the publisher. For information about special quantity discounts, please email special This book was set in Times Roman and Mathtime Pro 2 by the authors. Printed and bound in the United States of America. Library of Congress Cataloging-in-Publication Data Introduction to algorithms / Thomas H. Cormen . . . [et al.].—3rd ed. p. cm. Includes bibliographical references and index. ISBN 978-0-262-03384-8 (hardcover : alk. paper)—ISBN 978-0-262-53305-8 (pbk. : alk. paper) 1. Computer programming. 2. Computer algorithms. I. Cormen, Thomas H. QA76.6.I5858 2009 005.1—dc22 10 9 8 7 6 5 4 3 2 2009008593 Contents Preface xiii I Foundations 1 2 Introduction The Role of Algorithms in Computing 5 1.1 Algorithms 5 1.2 Algorithms as a technology 11 Getting Started 16 2.1 Insertion sort 16 2.2 Analyzing algorithms 23 2.3 Designing algorithms 29 3 3 4 Growth of Functions 43 3.1......

Words: 387342 - Pages: 1550

Vwap Algorithm

...Competitive Algorithms for VWAP and Limit Order Trading Sham M. Kakade Michael Kearns Computer and Information Science University of Pennsylvania Computer and Information Science University of Pennsylvania Yishay Mansour Luis E. Ortiz Computer Science Tel Aviv University Computer and Information Science University of Pennsylvania ABSTRACT We introduce new online models for two important aspects of modern financial markets: Volume Weighted Average Price trading and limit order books. We provide an extensive study of competitive algorithms in these models and relate them to earlier online algorithms for stock trading. Categories and Subject Descriptors F.2 [Analysis of Algorithms and Problem Complexity]: Miscellaneous; J.4 [Social and Behavioral Sciences]: Economics General Terms Algorithms, Economics Keywords Online Trading, Competitive Analysis, VWAP 1. INTRODUCTION While popular images of Wall Street often depict swashbuckling traders boldly making large gambles on just their market intuitions, the vast majority of trading is actually considerably more technical and constrained. The constraints often derive from a complex combination of business, regulatory and institutional issues, and result in certain kinds of “standard” trading strategies or criteria that invite algorithmic analysis. One of the most......

Words: 9064 - Pages: 37


...1. Illustrate the operation of Radix_sort on the following list of English words: cow, dog, seq, rug, row, mob, box tab, bar ear, tar, dig, big, tea, now, fox. ANSWER: It is a sorting algorithm that is used to sort numbers. We sort numbers from least significant digit to most significant digit. In the following array of words, three is the maximum number of digits a word has, hence the number of passes will be three. In pass 1, sort the words alphabetically using first letter from the right. For eg, tea has “a” as the last letter, hence it comes first, similarly mob which has “b” as the last letter comes second. In this way the remaining words are sorted. In pass 2, sort the words alphabetically using second letter from the right. For eg, tab has “a” as its middle letter which comes first, then comes bar and so on. In pass 3, sort the words alphabetically using third letter from the right. For eg, bar has “b” as its first letter from left and since no word starts with “a”, bar will appear first. Similarly, big, box, cow and so on. UNSORTED ARRAY | PASS 1 | PASS 2 | PASS 3(SORTED ARRAY) | cow | tea | tab | bar | dog | mob | bar | big | seq | tab | ear | box | rug | rug | tar | cow | row | dog | tea | dig | mob | dig | seq | dog | box | big | dig | ear | tab | seq | big | fox | bar | bar | mob | mob | ear | ear | dog | now | tar | tar | cow | row | dig | cow | row | rug | ...

Words: 1470 - Pages: 6

Certification and Verification

...Week 6 Assignment 4:Certification and Verification   TO: Information Technology Team FROM: Management DATE: August 9, 2012 TOPIC: Education and Certification Verification The purpose of this report is to make sure that our employees have the most up to date certifications and training available so that we can continue to provide our customers with the top notch service they are used to. By verifying this information we will be able to stay above out competition and remain a Fortune 500 Business. After a review of our records regarding education and certifications, it became apparent that an update was in order. The review revealed that we might not have accurate information regarding education and certifications, and in some cases, no information was on file at all. In order to maintain accurate records, it is necessary for each member of IT to validate their education and certifications. A spreadsheet has been developed that will be used to capture the accurate information for each member of the team. Please stop by the secretary’s desk to validate your information. If it is not correct, please provide the correct information. If your information is correct, then please let the secretary know that no changes are required. She will update the spreadsheet with the information you provide. Confidentiality will be maintained by only revealing your personal information to you. No one will be able to obtain information about someone else’s education or......

Words: 281 - Pages: 2