Suppose the football coach for the Anteaters has heard about your abilities to solve challenging problems and has hired you to write a computer program that can decide which of their many trophies to...
Show that every language L in P is polynomial-time reducible to the language M = {5}, that is, the language that simply asks whether the binary encoding of the input is equal to 5.
Show how to construct a Boolean circuit C such that, if we create variables only for the inputs of C and then try to build a Boolean formula that is equivalent to C, then we will create a formula...
Consider the problem DNF-DISSAT, which takes a Boolean formula S in disjunctive normal form (DNF) as input and asks whether S is dissatisfiable, that is, there is an assignment of Boolean values to...
Draw an example of a graph with 10 vertices and 15 edges that has a clique of size 6.
Given a set P of n points, design an efficient algorithm for constructing a simple polygon whose vertices are the points of P.
Show how to modify the KMP string pattern matching algorithm so as to find every occurrence of a pattern string P that appears as a substring in T, while still running in O(n + m) time. (Be sure to...
Using only the instructions shown in Figure 1-10, create an algorithm that displays the average of four numbers. Be sure to indent the instructions appropriately. calculate the average by dividing...
A program uses a char variable named department and two double variables named salary and raise. The department variable contains one of the following letters (entered in either uppercase or...
How many times will the computer process the cout statement in the following code? for (int numTimes = 1; numTimes < 10; numTimes += 2) cout < < numTimes < < endl; //end for a. 0 b. 5 c. 6 d. 9
Write an assignment statement that updates an accumulator variable named totalPay by the value in the grossPay variable.
Write an assignment statement that updates a counter variable named quantity by 5.
Which of the following updates the total accumulator variable by the value in the sales variable? a. total = total + sales; b. total = sales + total; c. total += sales; d. All of the above
Write the C++ code to display the integers 15, 12, 9, 6, 3, and 0 on separate lines on the computer screen. Use the for statement and an int variable named num.
Figure 5-35 shows the MifflinSt Jeor formulas for calculating a persons basal metabolic rate (BMR), which is the minimum number of calories needed to keep his or her body functioning while resting...
As you learned in the chapter, you must be careful when comparing two real numbers for either equality or inequality because some real numbers cannot be stored precisely in memory. To determine...
If necessary, create a new project named Intermediate25 Project and save it in the Cpp8\Chap13 folder. Also create a new source file named Intermediate25.cpp. Write a program that accepts a string of...
Allenton Water Department wants a program that calculates a customers monthly water bill. The clerk will enter the current and previous meter readings. The program should calculate and display the...
If necessary, create a new project named Introductory21 Project and save it in the Cpp8\Chap13 folder. Also create a new source file named Introductory21.cpp. Write a program that allows the user to...
Follow the instructions for starting C++ and viewing the Advanced20.cpp file, which is contained in either the Cpp8\Chap08\Advanced20 Project folder or the Cpp8\Chap08 folder. (Depending on your C++...
Use the nums array to answer. The array was declared using the int nums[4] = {10, 5, 7, 2}; statement. The x and total variables are int variables and are initialized to 0. The avg variable is a...
Draw a flowchart for the bubble sort program shown in Figure 11-34. 1 //Bubble Sort.cpp - uses the bubble sort to sort the 2 //contents of a one-dimensional array in ascending order 3...
If necessary, create a new project named Advanced26 Project and save it in the Cpp8\Chap11 folder. Also create a new source file named Advanced26.cpp. Declare a 12-element int array named days....
Follow the instructions for starting C++ and viewing the Advanced27.cpp file, which is contained in either the Cpp8\Chap11\Advanced27 Project folder or the Cpp8\Chap11 folder. (Depending on your C++...
In this exercise, you modify the program from Computer Exercise 31. The modified program will allow the user to change the grading scale while the program is running. If necessary, create a new...
Follow the instructions for starting C++ and viewing the ModifyThis18.cpp file, which is contained in either the Cpp8\Chap12\ModifyThis18 Project folder or the Cpp8\Chap12 folder. (Depending on your...
If necessary, create a new project named ModifyThis19 Project and save it in the Cpp8\Chap12 folder. Enter the C++ instructions shown earlier in Figure 12-10 into a new source file named...
In this exercise, you will create a program that allows the user to enter an employees gross pay amount as well as his or her filing status and number of withholding allowances. The program should...
A message that asks a user for input is a(n) ___________. a. Eomment b. Echo c. Prompt d. Declaration
Draw a typical hierarchy chart for a program that produces a monthly bill for a cell phone customer. Try to think of at least 10 separate modules that might be included. For example, one module might...
Your downloadable files for Chapter 2 include a file named DEBUG02-04.jpg that contains a flowchart with syntax and/or logical errors. Examine the flowchart and then find and correct all the bugs.
A sequence structure can contain _____________. a. Only one task b. Exactly three tasks c. No more than three tasks d. Any number of tasks
A ______________expression has one of two values: true or false. a. Georgian b. Boolean c. Barbarian d. Selective
If j k is true, then ______________. a. j = k is true b. j > k might be true c. j < k might be true d. Both b and c are true.
Which of the following must always be true? a. g < 12 AND g < 18 b. g = 12 OR h = 17 c. g 12 OR g 15 d. g > 12 AND g < 21
When you use a range check, you always compare a variable to ______________ value in the range. a. The lowest b. The highest c. An end-of-range value d. The average
If sales = 100, rate = 0.10, and expenses = 50, which of the following expressions is true? a. Sales >= expenses AND rate < 1 b. Sales < 200 OR expenses < 100 c. Expenses = rate OR sales = rate d....
If a is true, b is true, and c is false, which of the following expressions is true? a. a OR b AND c b. a AND b AND c c. a AND b OR c d. Two of the above
Computer programs also are known as____________. a. Data b. Hardware c. Software d. Information
The major computer operations include ____________. a. Input, processing, and output b. Hardware and software c. Sequence and looping d. Spreadsheets, word processing, and data communications
Visual Basic, C++, and Java are all examples of computer ____________. a. Operating systems b. Programming languages c. Hardware d. Machine languages
A programming languages rules are its ____________. a. Syntax b. Logic c. Format d. Options
Draw a flowchart or write pseudocode to represent the logic of a program that allows the user to enter a value for one edge of a cube. The program calculates the surface area of one side of the cube,...
Draw a flowchart or write pseudocode to represent the logic of a program that allows the user to enter values for the current year and the users birth year. The program outputs the age of the user...
Match the definition with the appropriate term. 1. Computer system devices a. compiler 2. Another word for program b. syntax 3. Language rules c. logic 4. Order of instructions d. hardware 5....
Your downloadable files for Chapter 5 include DEBUG05-01.txt, DEBUG05-02.txt, and DEBUG05-03.txt. Each file starts with some comments that describe the problem. Comments are lines that begin with two...
Your downloadable files for Chapter 6 include a file named DEBUG06-04.jpg that contains a flowchart with syntax and/or logical errors. Examine the flowchart, and then find and correct all the bugs.
Which of the following is true regarding the data hierarchy? a. Fields contain records. b. Characters contain fields. c. Fields contain files. d. Files contain records.
In this exercise, you modify the Rectangle class from Lab 15-2 so that it includes an overloaded method. a. If necessary, create a new project named Advanced20 Project and save it in the Cpp8\Chap15...
A file named MAINTENANCE07-01.txt is included with your downloadable student files. Assume that this program is a working program in your organization and that it needs modifications as described in...
Three-dimensional arrays _____. a. Are supported in many modern programming languages b. Always contain at least nine elements c. Are used only in object-oriented languages d. All of the above
Student records are stored in ID number order, but accessed by grade point average for a report. Grade point average order is a(n) _____ order. a. Imaginary b. Physical c. Logical d. Illogical
When you store a list of key fields paired with the storage address for the corresponding data record, you are creating _____. a. A directory b. A three-dimensional array c. A linked list d. An index
Assume you have written a method with the header void myMethod(num a, string b). Which of the following is a correct method call? a. MyMethod(12) b. MyMethod("Goodbye") c. MyMethod(12, "Hello") d. It...
Assume you have written a method with the header num yourMethod(string name, num code). The methods type is _____. a. Num b. String c. Num and string d. Void
Your downloadable files for Chapter 9 include DEBUG09-01.txt, DEBUG09-02.txt, and DEBUG09-03.txt. Each file starts with some comments that describe the problem. Comments are lines that begin with two...
A file named MAINTENANCE10-01.txt is included with your downloadable student files. Assume that this program is a working program in your organization and that it needs modifications as described in...
Employing inheritance reduces errors because _________. a. The new classes have access to fewer data fields b. The new classes have access to fewer methods c. You can copy and paste methods that you...
Which of the following is true? a. A classs methods usually are public. b. A classs data fields usually are public. c. Both of the above d. None of the above
Write a formal description of the following graph. 1 4 2 3 6
Let = {a,b}. Give a CFG generating the language of strings with twice as many as as bs. Prove that your grammar is correct.
Let = {1, 2, 3, 4} and C = {w * | in w, the number of 1s equals the number of 2s, and the number of 3s equals the number of 4s}. Show that C is not context free.
Say that a language is prefix-closed if all prefixes of every string in the language are also in the language. Let C be an infinite, prefix-closed, context-free language. Show that C contains an...
Modify the proof of Theorem 3.16 to obtain Corollary 3.19, showing that a language is decidable iff some nondeterministic Turing machine decides it. (You may assume the following theorem about trees....
Use the construction in the proof of Theorem 1.47 to give the state diagrams of NFAs recognizing the concatenation of the languages described in a. Exercises 1.6g and 1.6i. b. Exercises 1.6b and...
Use the construction in the proof of Theorem 1.49 to give the state diagrams of NFAs recognizing the star of the languages described in a. Exercise 1.6b. b. Exercise 1.6j. c. Exercise 1.6m. Exercise...
Review the way that we define sets to be the same size inDefinition 4.12 (page 203). Show that is the same size is an equivalence relation.
This exercise concerns TM M 2 , whose description and state diagram appear in Example 3.7. In each of the parts, give the sequence of configurations that M 2 enters when started on the indicated...
Show that EQ CFG is undecidable.
Consider the problem of determining whether a two-tape Turing machine ever writes a nonblank symbol on its second tape when it is run on input w. Formulate this problem as a language and show that it...
Read the informal definition of the finite state transducer given in Exercise 1.24. Give a formal definition of this model, following the pattern in Definition 1.5. Assume that an FST has an input...
Prove that there exists an undecidable subset of {1} * .
Show that P is closed under union, concatenation, and complement.
Using the solution you gave to Exercise 1.25, give a formal description of the machines T 1 and T 2 depicted in Exercise 1.24. Exercise 1.24. A finite state transducer (FST) is a type of...
In Theorem 3.21, we showed that a language is Turing-recognizable iff some enumerator enumerates it. Why didnt we use the following simpler algorithm for the forward direction of the proof? As...
Show that NP is closed under union and concatenation.
Show that ALL DFA is in P.
Create a program that allows the user to enter the ages (in years) of five people. The program should display the average age. Use the for statement. Display the average age with one decimal place....
Jacob Weinstein wants a program that displays his savings account balance at the end of the month, given the beginning balance, total deposits, and total withdrawals. a. Using the chart shown earlier...
Rewrite the code from Pencil and Paper Exercise 4 using the do while statement in the outer loop and the while statement in the nested loop.
Rewrite the code from Pencil and Paper Exercise 2 using the replace function.
In this exercise, you will modify the program from Lab 5-1. If necessary, create a new project named ModifyThis10 Project, and save it in the Cpp8\Chap05 folder. Enter the instructions shown earlier...
What is the output of the following code? b = 1; while(b < 4) { System.out.print(b + " "); b = b + 1; } a. 1 b. 1 2 3 c. 1 2 3 4 d. 1 1 1 1 1...
What does the following statement output? for(a = 0; a < 5; ++a) System.out.print(a + " "); a. 0 0 0 0 0 b. 0 1 2 3 4 c. 0 1 2 3 4 5 d. Nothing
What does the following statement output? for(b = 1; b > 3; ++b) System.out.print(b + " "); a. 1 1 1 b. 1 2 3 c. 1 2 3 4 d. Nothing
A third-grade teacher at Potter Elementary School wants a program that allows a student to enter the amount of money a customer owes and the amount of money the customer paid. The program should...
Figure 6-40 shows a partially completed chart for a program that displays the amount of a salespersons commission. The commission is based on the salespersons sales amount, as indicated in the...
The owner of Harrys Car Sales pays each salesperson a commission based on his or her quarterly sales. The sales ranges and corresponding commission rates are shown in Figure 6-43. The program should...
In this exercise, you will modify the tip program shown earlier in Figure 7-31. Follow the instructions for starting C++ and viewing the ModifyThis16.cpp file, which is contained in either the...
Create a JFrame that holds five buttons with the names of five different fonts. Include a sixth button that the user can click to make a font larger or smaller. Display a demonstration JLabel using...
Which of the following is true in a standard menu application? a. A JMenuItem holds a JMenu. b. A JMenuItem holds a JMenuBar. c. A JMenuBar holds a JMenu. d. A JMenu holds a JMenuBar
In this exercise, you will modify the program from Lab10-2. If necessary, create a new project named Intermediate20 Project, and save it in the Cpp8\Chap10 folder. Copy the instructions from the...
You developed an interactive GUI application for Carlys Catering. Now, design a JPanel that uses graphics to display a logo for the company, and modify the GUI application to include it. Save the...
Write an application that extends JPanel and uses the Graphics2D environment to create a GeneralPath object. Use the GeneralPath object to create the outline of your favorite state. Display the...
a. Create aMine Field game in which the user attempts to click 10 panels of a grid before hitting the bomb. Set up a JFrame using BorderLayout, use the NORTH region for a congratulatory message, and...
Suppose that you want to implement a bag class to hold non-negative integers, and you know that the biggest number in the bag will never be more than a few thousand. One approach for implementing...
What is meant by the term prompt?
Which operator do you use to read into a variable?
Suppose that you have created a program with only the following variables. int a = 5; int b = 6; Suppose that you also have a method with the following header: public static void mathMethod(int a)...
Specify, design, and implement a class that can be used to keep track of the position of a location in three-dimensional space. For exampleex, acmonpslieder this location: The location shown in the...