×
Log in to StudySoup
Get Full Access to Discrete Mathematics And Its Applications - 7 Edition - Chapter 4.1 - Problem 17e
Join StudySoup for FREE
Get Full Access to Discrete Mathematics And Its Applications - 7 Edition - Chapter 4.1 - Problem 17e

Already have an account? Login here
×
Reset your password

Show that if n and k are positive integers, then

Discrete Mathematics and Its Applications | 7th Edition | ISBN: 9780073383095 | Authors: Kenneth Rosen ISBN: 9780073383095 37

Solution for problem 17E Chapter 4.1

Discrete Mathematics and Its Applications | 7th Edition

  • Textbook Solutions
  • 2901 Step-by-step solutions solved by professors and subject experts
  • Get 24/7 help from StudySoup virtual teaching assistants
Discrete Mathematics and Its Applications | 7th Edition | ISBN: 9780073383095 | Authors: Kenneth Rosen

Discrete Mathematics and Its Applications | 7th Edition

4 5 1 267 Reviews
30
3
Problem 17E

Show that if n and k are positive integers, then

Step-by-Step Solution:
Step 1 of 3

Chapter 9: Principles of Computer Operations THERE’S AN APP FOR THAT  We are continually using computation The Usual Suspects The Processor: the device that does the actual computing  Other terms – computer, microprocessor, central processor, CPU, core  The processor does the work; that is, it follows the program’s instructions The Operating System: the software that makes the computer into a useful device  Performs operations common to all apps o Loading programs, sharing memory with multiple apps, locating files The Software  The “magic” of computing is revealed in apps (programs) for our devices  The hardware simply follows the program’s instructions so someone (the programmers) must write the instructions Instructions: very simple The Fetch/Execute Cycle: process of executing an instruction (doing what the instruction specifies)  Instruction execution is the proper term for what processors do Memory  Bits are a universal medium for information, and they are commonly referred to as 0 and 1  The memory stores the billions of 0s and 1s. Both programs and data are encoded in bits. As it is computing, the Fetch/Execute Cycle gets program and data bits from the memory, and puts data bits back into the memory Component Hardware  The most fundamental hardware are the transistors and the silicon chips that implement them SOFTWARE ISN’T SO HARD  When you get a new app, you get an extremely long sequence of bits— millions and millions of them  Splash screen: an image that displays before an application starts running, and this one fades in, fades out, and then goes on to the actual application  Although it doesn’t take much to type these “few” symbols, they are very, very specific. You cannot even make one typo or it will not work Deciding On What to Do  In the example, these instructions (fadeIn and fadeout) will be reused every few milliseconds, so the image fades in, becomes completely opaque, and then fades out  This is how programmers make computers test data, and based on the outcome, follow one of two alternate sets of instructions Software Layers  Millions and millions of other instructions will execute to make the app’s image fade in and out  The “layers” are only a conceptual grouping of software that performs similar activities. Because a given layer is built with code from the levels below, they are organized from more primitive (lower levels) to more general and sophisticated (upper levels)  Lists help the system find items or whole layers from the software stack  The splash screen illustrates two powerful ideas that explain why software keeps getting better and better: Shared Effort  By sharing libraries of programs that implement commonly needed operations, programmers can dramatically reduce their effort and leverage other programmers’ knowledge o These existing programs allow programmers to focus on their new and interesting apps rather than repeatedly writing the same code someone else has already written when they need to do the same operation Wide Use and Consistency  Software available in the stack can have wide dissemination  Users see it working the same way in each app because it’s the same code. If there is a bug in the code, or an improvement to be made, updating that single instance allows all apps to benefit at once INSTRUCTION EXECUTION ENGINE The Fetch/Execute Cycle  Instruction Fetch – IF  Instruction Decode – ID  Data Fetch – DF  Instruction Execute – EX  Result Return – RR Anatomy of a Computer  All computers, regardless of their implementing technology, have five basic parts or subsystems: the memory, the control unit, arithmetic/logic unit (ALU), input unit and output unit Memory: stores both the program while it is running and the data on which the program operates  Discrete locations: Memory is organized as a sequence of discrete locations, like apartment building mailboxes. In modern memory, each location is composed of 1 byte ( a sequence of 8 bits)  Addresses: every memory location has an address, like a mailbox, although computer memory address are whole numbers starting at 0  Values: Memory locations record or store values, like a mailbox holds a letter  Finite capacity: Memory locations have a finite capacity (limited size), so programmers must keep in mind that the data may not “fit” in the memory location Byte-Size Memory Location  The 1-byte size of a memory location is enough to store one ASCII character (letter, numeral, or punctuation symbol), or a whole number less than 256 Random Access Memory  “random access”  computer can refer to the memory locations in any order  RAM is measured in megabytes (MB) or gigabytes (GB)  Memory is like a sequence of labeled containers known as locations: The address is the location’s number in the sequence; the value or in the information stored at the location is the container’s contents; and only so much can fit in each container Control Unit  The hardware unit of a computer is the hardware implementation of the Fetch/Execute Cycle o Its circuitry fetches an instruction from memory and performs the other operations of the cycle on it Arithmetic/Logic Unit (ALU)  Does the “math”  The part of the computer that generally does the actual computation during the Instruction Execute step of the F/E Cycle Input Unit and Output Unit  Inverses of each other  The wires and circuits through which information moves into and out of a processor The Peripherals  Connect to the processor’s input/output (I/O) ports, providing it with input or receiving its output o Not considered part of the processor o They are specialized gadgets that encode or decode information between the processor and the physical world  Wires or a cable from the peripheral to the processor connects to the input unit or the output unit o These units handle the communication protocol with the peripherals. o As a general rule, think of the input unit as moving information from the peripheral into the memory, and the output unit as moving information from the memory and delivering it to the device Portable Memory, Hard Drives, Networking  Memory units (like USB flash drives) can both receive information from the processor and send information to it A Device Driver for Every Peripheral  Most peripheral devices are “dumb” because they provide only basic physical translation to or from binary signals. They rely on the computer for further processing, which is almost always required to make the peripheral operate in an “intelligent way”  Added processing by a piece of software called a device driver gives the keyboard its standard meaning and behavior Machine Instructions  Computer instructions are much more primitive than the commands Taylor gives the computer when he or she programs  Concept: computers encode the memory addresses of the numbers to be added(or subtracted or whatever), not the numbers themselves, and so they refer to the values indirectly o The indirection means that a single instruction can combine any two numbers simply by placing them in the referenced memory locations o Indirect reference: referring to a value by referring to the address in memory where it is stored—is fundamental to a computer’s versatility THE PROGRAM COUNTER: THE PC’s PC Address of the Next Instruction  Computers keep track of which instruction to execute next by its address. This address, stored in the control part of the computer, should probably be called the next instruction address, but for historic reasons it is actually known by the curious term program counter, abbreviated PC Branch and Jump Instructions Chapter 17: Fundamental Concepts Expressed in JavaScript OVERVIEW: PROGRAMMING CONCEPTS Programming: the act of formulating an algorithm or program  It entails developing a systematic means of solving a problem so that an agent—someone other than the programmer and usually a computer—can follow the instructions and produce the intended result for every input, every time. The agent must also be able to perform or execute the program without any intervention from the programmer. This means that all steps must be spelled out precisely and effectively, and all contingencies must be planned for JavaScript: a modern programming language that is especially effective for Web applications NAMES, VALUES, AND VARIABLES  Everyday life vs. Code Names Have Changing Values  Names and values are separable in programming o The best way to think of names and values in programming is to think of names as if they were offices or titles, or other designations purposely selected to have changing values  A program is a fixed description of a process o As the process evolves and the program transforms data to produce new values, the old names must refer to these new values, that is, the names change values. This is a natural result of the fixed description of the process Names in a Program Are Called Variables  Variables: a term that reminds us that their values vary  The most commonly used programming language operation is the command to change the value of a variable o Command = assignment Identifiers and Their Rules  Identifier: the letter sequence that makes up a variable’s name A Variable Declaration Statement  Programs are usually written “starting from scratch”  Declaring variables  command = declaration o var The Statement Terminator  A program is simply a list of statements  ; - semicolon o just like terminating sentences in English with a period, question mark, or exclamation point Rules for Declaring Variables  Every variable used in a program must be declared!!  Usually declare variables first Undefined Values  The name is declared but there is no value assigned yet  the value is undefined Initializing a Declaration  Often we know an initial value for the identifier we declare. So JavaScript allows us to set the initial value as a part of the declaration, that is, to initialize the variable  Don’t have to declare and initialize just 1 variable at a time in the var statement, you can do multiple at a time by separating them with commas THREE BASIC DATA TYPES OF JAVASCRIPT 1. Numbers 2. Strings 3. Booleans Rules for Writing Numbers  One “unusual” aspect of numbers In programming is that there are not “units” Strings  Most common kind of data  Strings: sequences of keyboard characters o always surrounded by single (‘) or doube (“) quotes Strings Can Initialize a Declaration  We need strings when manipulating text, as when we’re building Web pages, for example Rules for Writing Strings in JavaScript 1. Strings must be surrounded within quotes, either single (‘) or double (“), which are not curly 2. Most characters are allowed within quotes except the return character (Enter), backspace character, tab character, \, and two others (little used) 3. Double quoted strings can contain single quotes, and vice versa 4. The apostrophe (‘) is the same as the single quote 5. Any number of characters is allowed in a string 6. The minimum number of characters in a string is zero(“”), which is called the empty string Literals  the numbers and strings discussed are known as literals  The term literal conveys the idea that the characters are typed literally in the program o Rules about how to write these values explicitly in a computation o However, when literals become the values of variables and are stored in the computer, the representation changes slightly, especially for strings String Literals Stored in the Computer  First, because the surrounding quotes or double quotes are used only to delimit the string literal, they are removed when the literal is stored in the computer o That’s why the empty string “” has a length of 0, rather than 2  Second, any character can be stored in the computer’s memory o Specifically, although a prohibited character such as a tab character cannot be typed in as a literal, it can be the value of a string in the computer. To do this we used the “escape” mechanism, as follows  Escape symbol - \  The escape sequences are converted to the single characters they represent when they are stored in the computer’s memory Boolean Values  Unlike numbers and strings, there are only two Boolean values: true and false  Data types/Value types: The different kinds of values of a programming language THE ASSIGNMENT STATEMENT  If variables are to change values in an algorithm or program, there should be a command to do so. The assignment statement changes a variable’s value; it is the workhorse of programming o Has three parts that always occur in this order ; example: week = days/7 Assignment Symbol  Most common symbols for indicating an assignment o equal sign = o colon ; o equal sign pair := Interpreting an Assignment Statement  To understand how assignment works, you must think of a value flowing from the right side (expression side) of the assignment symbol to the left side (variable side) o Assignment symbol should be read as “is assigned” or “becomes” or “gets”  In an assignment statement, the expression is computed or evaluated first o If there are any variables used in the expression, their current values are used o This evaluation produces a value that then becomes the new value of the variable named on the left side Three Key Points About Assignment 1. All three of the components must be given; if anything is missing, the statement is meaningless 2. The flow of the value to the name is always right to left. Thus the two variable names in the assignment statement variable_receiving_new_value = newly_computed_value; 3. The values of any variables used in the expression are their values before the start of execution of the assignment AN EXPRESSION AND ITS SYNTAX  Expressions describe the means of performing the actual computation  Expressions are built out of variables and operators o Operator: standard arithmetic operators  Addition (+), Subtraction (-), multiplication (x), division(/)  Ones that one would find on a calculator o Symbols of basic arithmetic = arithmetic operators Arithmetic Operators  Multiplication * asterisk  Multiplication and division have higher precedence than addition and subtraction  Expressions must be typed on a single line so superscripts are prohibited o Some languages have an operator for exponents or power, but JavaScript does not  Operators like + and * are called binary operators because they operate on two values o The values they operate on are called operands o There are also unary operators, like negate (-), which have only one operand  Language parsers—the part of a compiler that “diagrams” programs so a computer can understand them—can easily figure out whether the minus means negate or subtract  One very useful operator  modulus (mod) operation (%) o It divides two integers and returns the remainder Relational Operators  Relational operators are used to make comparisons between numerical values—that is, to test the relationship between two numbers o The outcome of the comparison is a Boolean value, either true or false a < b  less than a <= b  less than or equal to a == b  equal a != b  not equal a >=  greater than or equal to a > b  greater Logical Operators  It is common to test two or more relationships together, requiring that relational expression results be combined Logical and  &&  logical and operator, playing the same role that AND plays in query expressions  The operands for relational expressions must be numeric, but the operands for logical expressions must be Boolean Logical or  ||  logical or operator Logical not  (!)  logical not operator is a unary operator—it takes a single operand—and its outcome is the opposite of the value of its operand Operator Overload  operator overload  “use of an operator with different data types” Concatenation  When we use + with strings, it joins the strings by the operation of concatenation A CONDITIONAL STATEMENT  A specific statement type, called a conditional statement or a conditional, has been invented to make testing numbers and strings simpler. The conditional statement of JavaScript, which differs from the IF() function of spreadsheets, has the form If () ;  The Boolean expression is any expression evaluating to a Boolean true or false outcome, such as relational expressions, and the is any JavaScript statement, such as an assignment statement if Statements and Their Flow of Control  In a conditional, the , called a predicate, is evaluated, producing a true or false outcome o If the outcome is true, the is performed o If the outcome is false, the is skipped Compound Statements  Compound statement  group the statements by surrounding them with “curly braces”, which collects them to become a single statement  The “exception proving the rule” that every statement must be terminated by a semicolon is the compound statement. The closing curly brace should not be followed by a semicolon if/else Statements if () ; else ;  The is evaluated first o If the outcome is true, the is executed and the is skipped o If the ’s outcome is false, the is skipped and the is executed Nested if/else Statements  The and the can contain an if/else, but you have to be careful, because it can be ambiguous which if an else goes with. The rule in JavaScript and most other programming language is that the else associates with the (immediately) preceding if Chapter 18: A JavaScript Program BACKGROUND FOR THE UI Interacting with a UI  The input facilities like buttons and check boxes are known as elements of forms Forms  Events and Event Handlers  When the UI inputs are used, such as clicking a button, they cause an event to occur. In case of a button, the event is called a “click event” o An event is an indication from the computer (operating system) that something just happened  We want our JavaScript program to respond to that click—that is, perform the operation corresponding to the button command. When JavaScript finds out about the event, the program that performs the operation that responds to an event. o An event handler is the program that performs the operation that responds to an event Three Input Elements  Text Box 1. Can be used to input or output numbers or words 2. General form:  Radio Button 1. Give a selection of preprogrammed settings 2. General form: label text  Button 1. Form: Chapter 19: Programming Functions Functions are packages for algorithms  3 parts 1. Name 2. Parameters 3. Definition Call a Function – Ask the computer to run or execute the statements of the function to produce the answer Pseudo-random numbers: an invention of computer science in which an algorithm produces a sequence of numbers that passes the statistical tests for randomness The scale variable, having been declared outside of any function or form, is a global variable Chapter 20: Iteration Principles Iteration: looping through a series of statements to repeat them The initialization sets the iteration variable’s value for the first (if any) iteration of the loop Indexing is the process of creating a sequence of names by associating a base name (“Apollo”) with a number (“13”) Element – base-named sequence Array reference: consists of the array name together with an index DOM – Document Object Model: browser’s representation for the page

Step 2 of 3

Chapter 4.1, Problem 17E is Solved
Step 3 of 3

Textbook: Discrete Mathematics and Its Applications
Edition: 7
Author: Kenneth Rosen
ISBN: 9780073383095

Other solutions

People also purchased

Related chapters

Unlock Textbook Solution

Enter your email below to unlock your verified solution to:

Show that if n and k are positive integers, then