Computer Science: An Overview (12th Edition)
12th Edition
ISBN: 9780133760064
Author: Glenn Brookshear, Dennis Brylow
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 12, Problem 30CRP
Program Plan Intro
NP polynomial complexity:
A turning machine is used to solve an NP complexity. A problem comes under the category of NP polynomial complexity if it can be solved by the polynomial time with the use of turning machine.
Polynomial complexity:
It is faster in response as compared to non polynomial complexity. It contains almost all mathematical operations such as square root, powers and logarithmic functions. It is denoted as
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Correct answer will be upvoted else Multiple Downvoted. Computer science.
You are given an arrangement an of length n comprising of integers from 1 to n. The grouping may contain duplicates (for example a few components can be equal).
Track down the number of tuples of m=3 components with the end goal that the maximum number in the tuple varies from the base by close to k=2. Formally, you want to view as the number of triples of lists i<j<z with the end goal that
max(ai,aj,az)−min(ai,aj,az)≤2.
For example, on the off chance that n=4 and a=[1,2,4,3], there are two such triples (i=1,j=2,z=4 and i=2,j=3,z=4). In the event that n=4 and a=[1,1,1,1], all four potential triples are suitable.
Input
The principal line contains a solitary integer t (1≤t≤2⋅105) — the number of experiments. Then, at that point, t experiments follow.
The principal line of each experiment contains an integer n (1≤n≤2⋅105) — the length of the succession a.
The following line contains n…
In a company, there are several branches. Let us consider a branch of that company having N
employees, if the manager is allotted to that branch(s) then he is known to everyone else in that
branch. Note that the property of "known to everyone" is unique to a manager. Your task is to find
the manager in that branch. Input from the user in main (), the square matrix M where if an element
of row i and column j is set to 1 it means that ith person knows jth person. You need to write a
function managerId () which returns the id of the manager if present or else returns -1. The function
managerId () takes two arguments - the square matrix of N *N and its size N. Call managerId ()
from the main () output the information about the manager. Assume all diagonal elements to be 1
(as everyone knows him/herself) and there is at most one manager in the company.
A matrix's trace is equal to its trace transposed. The diag method of Numpy may be used to extract the elements along the diagonal of a square matrix. Retrieving data from diagonals above or below the primary diagonal is possible using the optional parameter k. The call trace, just like in Python programming, may be used to get a matrix's trace.
Chapter 12 Solutions
Computer Science: An Overview (12th Edition)
Ch. 12.1 - Prob. 1QECh. 12.1 - Prob. 2QECh. 12.1 - Prob. 3QECh. 12.1 - Prob. 4QECh. 12.2 - Prob. 1QECh. 12.2 - Prob. 2QECh. 12.2 - Prob. 3QECh. 12.2 - Prob. 4QECh. 12.2 - Prob. 5QECh. 12.3 - Prob. 1QE
Ch. 12.3 - Prob. 3QECh. 12.3 - Prob. 5QECh. 12.3 - Prob. 6QECh. 12.4 - Prob. 1QECh. 12.4 - Prob. 2QECh. 12.4 - Prob. 3QECh. 12.5 - Prob. 1QECh. 12.5 - Prob. 2QECh. 12.5 - Prob. 4QECh. 12.5 - Prob. 5QECh. 12.6 - Prob. 1QECh. 12.6 - Prob. 2QECh. 12.6 - Prob. 3QECh. 12.6 - Prob. 4QECh. 12 - Prob. 1CRPCh. 12 - Prob. 2CRPCh. 12 - Prob. 3CRPCh. 12 - In each of the following cases, write a program...Ch. 12 - Prob. 5CRPCh. 12 - Describe the function computed by the following...Ch. 12 - Describe the function computed by the following...Ch. 12 - Write a Bare Bones program that computes the...Ch. 12 - Prob. 9CRPCh. 12 - In this chapter we saw how the statement copy...Ch. 12 - Prob. 11CRPCh. 12 - Prob. 12CRPCh. 12 - Prob. 13CRPCh. 12 - Prob. 14CRPCh. 12 - Prob. 15CRPCh. 12 - Prob. 16CRPCh. 12 - Prob. 17CRPCh. 12 - Prob. 18CRPCh. 12 - Prob. 19CRPCh. 12 - Analyze the validity of the following pair of...Ch. 12 - Analyze the validity of the statement The cook on...Ch. 12 - Suppose you were in a country where each person...Ch. 12 - Prob. 23CRPCh. 12 - Prob. 24CRPCh. 12 - Suppose you needed to find out if anyone in a...Ch. 12 - Prob. 26CRPCh. 12 - Prob. 27CRPCh. 12 - Prob. 28CRPCh. 12 - Prob. 29CRPCh. 12 - Prob. 30CRPCh. 12 - Prob. 31CRPCh. 12 - Suppose a lottery is based on correctly picking...Ch. 12 - Is the following algorithm deterministic? Explain...Ch. 12 - Prob. 34CRPCh. 12 - Prob. 35CRPCh. 12 - Does the following algorithm have a polynomial or...Ch. 12 - Prob. 37CRPCh. 12 - Summarize the distinction between stating that a...Ch. 12 - Prob. 39CRPCh. 12 - Prob. 40CRPCh. 12 - Prob. 41CRPCh. 12 - Prob. 42CRPCh. 12 - Prob. 43CRPCh. 12 - Prob. 44CRPCh. 12 - Prob. 46CRPCh. 12 - Prob. 48CRPCh. 12 - Prob. 49CRPCh. 12 - Prob. 50CRPCh. 12 - Prob. 51CRPCh. 12 - Prob. 52CRPCh. 12 - Prob. 1SICh. 12 - Prob. 2SICh. 12 - Prob. 3SICh. 12 - Prob. 4SICh. 12 - Prob. 5SICh. 12 - Prob. 6SICh. 12 - Prob. 7SICh. 12 - Prob. 8SI
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- In this programming assignment, you are expected to design an experimental study for thecomparison between Hoare’s partitioning and Lomuto’s partitioning in Quicksort algorithm.You must implement the recursive Quicksort algorithm using two partitioning algorithms inJava. You must design the experiments for the comparison of two algorithms both theoreticallyand empirically. You must write a detailed report including the pseudo-code of the algorithms,the time complexity of the algorithms, the experimental design, and your results. You canprovide some plots (scatter, line etc.) to illustrate your results.arrow_forwardQ3 In a company, there are several branches. Let us consider a branch of that company having N employees, if the manager is allotted to that branch(s) then he is known to everyone else in that branch. Note that the property of "known to everyone" is unique to a manager. Your task is to find the manager in that branch. Input from the user in main (), the square matrix M where if an element of row i and column j is set to 1 it means that ith person knows jth person. You need to write a function managerId () which returns the id of the manager if present or else returns -1. The function managerId () takes two arguments - the square matrix of N *N and its size N. Call managerId () from the main () output the information about the manager. Assume all diagonal elements to be 1 (as everyone knows him/herself) and there is at most one manager in the company. Example: No of persons N = 3 Input matrix: 0 1 1 1 0 1 Output: manager is person 3 1 0 1arrow_forwardIN PYTHON A tridiagonal matrix is one where the only nonzero elements are the ones on the main diagonal and the ones immediately above and below it.Write a function that solves a linear system whose coefficient matrix is tridiag- onal. In this case, Gauss elimination can be made much more efficient because most elements are already zero and don't need to be modified or added. As an example, consider a linear system Ax = b with 100,000 unknowns and the same number of equations. The coefficient matrix A is tridiagonal, with all elements on the main diagonal equal to 3 and all elements on the diagonals above and below it equal to 1. The vector of constant terms b contains all ones, except that the first and last elements are zero. You can use td to find that x1= −0.10557. The following code format should help: def td(l, m, u, b): '''Solve a linear system Ax = b where A is tridiagonal Inputs: l, lower diagonal of A, n-1 vector m, main diagonal of A, n vector u,…arrow_forward
- Restructure Newton's method (Case Study: Approximating Square Roots) by decomposing it into three cooperating functions. The newton function can use either the recursive strategy of Project 2 or the iterative strategy of the Approximating Square Roots Case Study. The task of testing for the limit is assigned to a function named limitReached, whereas the task of computing a new approximation is assigned to a function named improveEstimate. Each function expects the relevant arguments and returns an appropriate value. An example of the program input and output is shown below: Enter a positive number or enter/return to quit: 2 The program's estimate is 1.4142135623746899 Python's estimate is 1.4142135623730951 Enter a positive number or enter/return to quitarrow_forwardA matrix is a rectangle of numbers in rows and columns. A 1xN matrix has one row and N columns. An NxN matrix has N rows and N columns. Multiplying a 1xN matrix A and an NxN matrix B produces a 1xN matrix C. To determine the Nth element of C multiply each element of A by each element of the Nth column of B and sum the results. Helpful information can be found at matrix multiplication. Write a program that reads a 1xN matrix A and an NxN matrix B from input and outputs the 1xN matrix product, C. The first integer input is N, followed by one row of N integers for matrix A and then N rows of N integers for matrix B. N can be of any size >= 2. For coding simplicity, follow each output integer by a space, even the last one. The output ends with a newline. Ex: If the input is: 2 2 3 1 2 3 4 A contains 2 and 3, the first row of B contains 1 and 2, and the second row of B contains 3 and 4. The first element of C is (2 * 1) + (3 * 3), and the second element of C is (2 * 2) + (3 * 4). The…arrow_forwardThe size of a colony of blue bacteria growing in a petri dish is modeled by the equation where t is time in days. The size of a colony of green bacteria is modeled by the equation where t is again time in days. Both colony sizes are measured in square centimeters. Part A: Graph the growth of both colonies on the same plot over the course of 6 days in one hour increments. One way to get one hour increments is to use a step size of 1/24. Another way is to use linspace and specify that it should create 6days x 24hours evenly spaced values. In either case, make sure you start at 0 days, not 1 day. Make the color of the curve match the color of the bacteria it represents. Give your graph a title and axis labels. Part B: How large is the green bacteria colony when the blue colony reaches its maximum size. You must answer this question using Matlab calculations, not manually entering the answer. To check your work, the blue colony’s maximum size is 270.56 and when it reaches that…arrow_forward
- Pls Use Python Using NumPy, write the program that determines whether the A=({{1, 5, -2}, {1, 2, -1}, {3, 6, -3}}) matrix is nilpotent. Itro: Nilpotent Matrix: A square matrix A is called nilpotent matrix of order k provided it satisfies the relation, Ak = O and Ak-1≠O where k is a positive integer & O is a null matrix of order k and k is the order of the nilpotent matrix A . The following picture is an example of the intro: Ps: Please also explain step by step with " # "arrow_forwardYou are a computer research scientist at Tesla, and your task is to create a computer vision application for self-driving cars to detect object and avoid collision. You know that Graham's scan is a method of computing the convex hull of a finite set of points in the plane. You decide to apply this algorithm to achieve the goal of your task. a) Suppose Graham's scan executes n points, where n >= 3. Prove that, at the end of the program, the stack S consists of, from bottom to top, exactly the vertices of convex hull in counter-clockwise order.arrow_forwardThe goal of this problem is to walk from cell (0, 0) to cell (m, n) of a two-dimensional array. Each step must be either to the right or downward. So you can step from cell (1, 1) to cell (1, 2) or (2, 1). but not from (1, 1) to (0, 1) or (1,0). You are given a toll matrix, where each cell contains a toll that must be paid upon entry into that cell. The goal is to make it from cell (0, 0) to cell (m, n) while paying the smallest possible total toll. Does a greedy algorithm work? Think it out. Write a dynamic programming algorithm that finds the minimum possible total toll. It does not need to do reconstruction and say how to achieve that total toll.arrow_forward
- Python application creation The system call inv in the numpy.linalg library can be used to calculate the inverse of a matrix. A basic 2 by 2 matrix's inverse can be calculated using Python code. The identity matrix I is then generated by multiplying the inverse of A by itself for proof.arrow_forwardQ1 Dan has a list of problems suitable for the assignment. The difficulties of these problems are stored in a list of integers a. The i-th problem’s difficulty is represented by a[i] (the higher the integer, the more difficult the problem). Dan is too busy eating saltines to worry about assignment decisions, so he asks Michael to select at least two problems from the list for the assignment. Since there are many possible subsets of the problems to consider and Michael has a life, he decides to consider only sublists (definition follows) of the list of problems. To make grading the assignment easier, Michael wants to pick problems that don’t vary too much in difficulty. What is the smallest difference between the difficulties of the most difficult selected problem and the least difficult selected problem he can achieve by selecting a sublist of length at least 2 of the original list of problems? Definition: A sublist of a list a is any list you can obtain by removing some (possibly 0)…arrow_forwarduse my ID : 201909010 SOLVE ALL BY matlab Consider the graphs of the functions f(x) = m - 1x and g(x) = 2x² — n where m and n are the maximum and mean values of the digits in your student-ID number. a) Create a vector v whose elements are the digits of your student-ID number. b) Create a variable m and assign the maximum digit in v to it. Create a variable n and assign the mean value of the digits in v to it. d) Define the function f(x) and g(x) above as anonymous functions. Plot the graphs of f(x) and g(x) on the same figure using the MATLAB function ezplot. f) Find the exact values of the x-coordinates of the intersection points between the two graphs using the MATLAB function solve. g) Find the area bounded by the two graphs.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning