Blog

Coursehelp
March 16, 2019
Assignments No Comments

Solved: 2. What’s Wrong With The Following Loop? Int X=0; … |

2. Whats wrong with the following loop? int x=0; while (x) cout << x << endl;2. What’s wrong with the following loop? int x=0; while (x) cout Show transcribed image text

Expert Answer


Attached . . .

READ MORE
Coursehelp
Assignments No Comments

2. For Each Query Shown In The Screen Clipping Bel… |

2. For each query shown in the screen clipping below, write aquestion that the return set of the query answers. See the notes atthe end of this assignment. Show evidence you successfully ran thequeries.

Queries I - b 1 Query SELECT ROUND (SUM (SALES),2) AS TOTAL SALES 3 FROM ORDER ITEMS WHERE CATEGORY =Furniture; Query 2 SELECT CATEGORY, ROUND (SUM (SALES),2) AS TOTAL SALES 7 FROM ORDER ITEMS GROUP BY CATEGORY: 10 -Query 3 12 13 14 15 16 17 18 19 20 21 SELECT CATEGORY, ROUND (SUM (SALES),2) AS TOTAL SALES FROM ORDER ITEMS GROUP BY ROLLUP (CATEGORY) Query 4 SELECT CATEGORY, SUB CATEGORY, ROUND (SUM (SALES),2) ASTOTAL SALES FROM ORDER ITEMS GROUP BY ROLLUP (CATEGORY, SUB_CATEGORY): Query 5 SELECT CUSTOMER_ID, CATEGORY, SUB_CATEGORY, ROUND (SUM (SALES),2) AS TOTAL SALES 23 24 25 26 FROM ORDER ITEMS 01, ORDERS O WHERE 01. ORDER ID = O. ORDER ID GROUP BY ROLLUP (CUSTOMER ID, CATEGORY, SUB CATEGORY) Query 6 SELECT CUSTOMER_ID, COUNT (DISTINCT ?.ORDER-ID) AS NUMBER OF ORDERS, ROUND (SUM (SALES) ,2) AS TOTAL SALES, 28 29 30 ROUND (SUM (PROFIT),2) AS TOTAL PROFIT FROM ORDER ITEMS OI, ORDERS O WHERE OI.ORDER IDO.ORDER ID GROUP BY ROLLUP (CUSTOMER ID) ORDER BY NUMBER OF ORDERS

Queries I – b 1 Query SELECT ROUND (SUM (SALES),2) AS “TOTAL SALES” 3 FROM ORDER ITEMS WHERE CATEGORY =’Furniture’; Query 2 SELECT CATEGORY, ROUND (SUM (SALES),2) AS “TOTAL SALES” 7 FROM ORDER ITEMS GROUP BY CATEGORY: 10 -Query 3 12 13 14 15 16 17 18 19 20 21 SELECT CATEGORY, ROUND (SUM (SALES),2) AS “TOTAL SALES” FROM ORDER ITEMS GROUP BY ROLLUP (CATEGORY) Query 4 SELECT CATEGORY, SUB CATEGORY, ROUND (SUM (SALES),2) AS”TOTAL SALES” FROM ORDER ITEMS GROUP BY ROLLUP (CATEGORY, SUB_CATEGORY): Query 5 SELECT CUSTOMER_ID, CATEGORY, SUB_CATEGORY, ROUND (SUM (SALES),2) AS “TOTAL SALES” 23 24 25 26 FROM ORDER ITEMS 01, ORDERS O WHERE 01. ORDER ID = O. ORDER ID GROUP BY ROLLUP (CUSTOMER ID, CATEGORY, SUB CATEGORY) Query 6 SELECT CUSTOMER_ID, COUNT (DISTINCT ?.ORDER-ID) AS “NUMBER OF ORDERS”, ROUND (SUM (SALES) ,2) AS “TOTAL SALES”, 28 29 30 ROUND (SUM (PROFIT),2) AS “TOTAL PROFIT” FROM ORDER ITEMS OI, ORDERS O WHERE OI.ORDER IDO.ORDER ID GROUP BY ROLLUP (CUSTOMER ID) ORDER BY “NUMBER OF ORDERS” Show transcribed image text

Expert Answer


Attached . . .

READ MORE
Coursehelp
Assignments No Comments

Solved: 2 Questions: Python Code For Beginner. Need Help W… |

2 Questions: Python Code for beginner. Need help writing acode

https://docs.google.com/document/d/1f8UIatB005yXOIio20HiZe4V-WiM0HmKUfOGysDbp44/edit?usp=sharing

Expert Answer


Attached . . .

READ MORE
Coursehelp
Assignments No Comments

Solved: 2. What Does The Queue Contain At Points (a), (b) … |

2. What does the queue contain at points (a), (b) and (c)? queuecint>q stack<ints for (int i-; i <10; 1) q-push (1) front back for (int ?.l; i <-10; i++) { int x -q front) popo if (x2-0)pushx) else q.push(x) // (b) q= ron back while (s.empty)) q-push (s.top)) s.pop) front back

2. What does the queue contain at points (a), (b) and (c)? queuecint>q stackShow transcribed image text

Expert Answer


Attached . . .

READ MORE
Coursehelp
Assignments No Comments

Solved: 2.) In Randomized Selection We Are Told That The E… |

2.) In randomized selection we are told that the expected value of randomly choosing a number in the middle 50% percentile is

2.) In randomized selection we are told that the expected value of randomly choosing a number in the middle 50% percentile is 2. (a) Analyze the randomized selection given that the expected value of getting a number in the middle 50% percentile is 3 (b) Analyze given that your expected value of getting a number in the middle 60% is a where a is some constant integer Show transcribed image text 2.) In randomized selection we are told that the expected value of randomly choosing a number in the middle 50% percentile is 2. (a) Analyze the randomized selection given that the expected value of getting a number in the middle 50% percentile is 3 (b) Analyze given that your expected value of getting a number in the middle 60% is a where a is some constant integer

Expert Answer


Attached . . .

READ MORE
Coursehelp
Assignments No Comments

Solved: 2) Read C_part1.pptx And/or Text Section 1.4.2 Mac… |

2) Read C_part1.pptx and/or text section 1.4.2

Macros are available in most high-levelprogramming languages. The body of a macro is simply used toreplace a macro-call during the preprocessing stage. A macrointroduces a “true inline” function that is normally more efficientthan an “out-line” function. However, macros suffer from theside-effect, unwanted, or unexpected modifications tovariables.

Macros should be used cautiously. The main purpose of thefollowing programs are to demonstrate the differences between afunction and a macro.

Other purposes include demonstrating the differences betweendifferent programming environments, and learning different ways ofwriting comments, formatted input and output, variable declarationand initialization, unary operation ++, macro definition/call,function definition/call, if-then-else and loop structures,etc.

Observe each of the functions below and understand theirfunctionality. You can use either GNU gcc under Unix or VisualStudio to implement the code in this question.

int subf(int a, int b) {

return a-b;

}

int cubef(int a) {

return a * a * a;

}

int minf(int a, int b) {

if (a<=b) {

return a;

} else {

return b;

} }

int oddf(int a) {

if ( a % 2 == 0) {

return 0;

} else {

return 1;

} }

2.1 Writefourmacrostore-implementthegivenfourfunctions.Namethem: subm, cubem, minm, and oddm, respectively. [8 points]

2.2 Writethemainfunctiontotestthefunctionsandmacros.Usethefollowing test cases in the main function to call yourmacros:
[5 points]

int a = 5, b = 7; subf(a, b); subm(a, b); subf(a++, b–); subm(a++, b–); cubef(a); cubem(a); cubef(–a); cubem(–a); minf(a, b); minm(a, b); minf(–a, –b); minm(–a, –b); oddf(a); oddm(a); oddf(a++); oddm(a++);

Your main function must print the results of the test run.

For questions 2.1 and 2.2, submit your program labeledas hw02q2.c

2.3 Observeandcomparewiththeoutputsofthefunctionsandthe macros.Do the functions and macros generate the same results? Submit yourshort answer and the screenshots of the test run and label the filehw02q2.pdf [2 points]

Programming Portion:

3. You are given a file named hw02q3.c. All instructions aregiven in the form of comments in the file. You are to again run thefile in both Visual Studio and in GCC and observe the outputs andmake changes as requested. Please read all instructions verycarefully, then complete and submit the updated file as hw02q3.c.[25 points]

THE FILE –

#include <stdio.h>#pragma warning(disable : 4996) // CSE 240 Fall 2016 Homework 2 Question 3 (25 points)// Note: You may notice some warnings for variables when you compile in GCC, that is okay.#define macro_1(x) ((x > 0) ? x : 0)#define macro_2(a, b) (3*a – 3*b*b + 4*a * b – a*b * 10)int function_1(int a, int b) { return (3*a – 3*b*b + 4*a * b – a*b * 10); }// Part 1:// It appears that the result of macro_1 should be 5, why is the result 6? Correct the error. (5 points)void part1(int x) { int m = x, result; result = macro_1(++m); printf(“macro_1(%d) = %dnn”, (++x), result); // Why did this error occur? Please provide the answer in your own words below following “Explanation: ” printf(“Explanation: __________________________________________________________________nnn”); // (5 points)}// Part 2:// Run this program in Visual Studio and then again in GCC. Take note of the output values for function_1(x,y) and macro_2(x,y).void part2(int x, int y) { int i, j, s, t; s = i = x; // initialize variables with value from x t = j = y; // initialize variables with value from y printf(“function_1(x, y) = %dnmacro_2(x, y) = %dnn”, function_1(++i, ++j), macro_2(++s, ++t)); // Replace the 4 ‘__’ spaces below with the actual output observed when running the code in VS and GCC. printf(“In VS : the result of function_1(x, y) = __ and macro_2(x, y) = __ n”); // (5 points) printf(“In GCC: the result of function_1(x, y) = __ and macro_2(x, y) = __ nn”); // (5 points) // Explain why Visual Studio and GCC programming environments could possibly produce a different value for the same program and for the same input. printf(“Explanation: __________________________________________________________________nn”); // (5 points)}// Do not edit any of the following code int main(){ int x = 4, y = 5; printf(“Part 1:nn”); part1(x); printf(“Part 2:nn”); part2(x, y); return 0;}

Expert Answer


Attached . . .

READ MORE
Coursehelp
Assignments No Comments

Solved: 2) Reduce The Following State Table To Minimum Num… |

2) Reduce the following state table to minimum number of states using Implication chart method (20 points) Next State Output Present State X-0 X-1 X-0 X-12) Reduce the following state table to minimum number of states using Implication chart method (20 points) Next State Output Present State X-0 X-1 X-0 X-1 Show transcribed image text

Expert Answer


Attached . . .

READ MORE
Coursehelp
Assignments No Comments

Solved: 2. The Reflection Of A Language L Over An Alphabet… |

2. The reflection of a language L over an alphabet A is defined as: (a) Find a regular language L for which the reflection of L is also a regular language. (b) Show that in general the reflection of a regular language is a context-free language Hint: Use a right-linear grammar G defining L and observe that the reflection of L is defined by a grammar which is a modification of g.

2. The reflection of a language L over an alphabet A is defined as: (a) Find a regular language L for which the reflection of L is also a regular language. (b) Show that in general the reflection of a regular language is a context-free language Hint: Use a right-linear grammar G defining L and observe that the reflection of L is defined by a grammar which is a modification of g. Show transcribed image text 2. The reflection of a language L over an alphabet A is defined as: (a) Find a regular language L for which the reflection of L is also a regular language. (b) Show that in general the reflection of a regular language is a context-free language Hint: Use a right-linear grammar G defining L and observe that the reflection of L is defined by a grammar which is a modification of g.

Expert Answer


Attached . . .

READ MORE
Coursehelp
Assignments No Comments

2. Relational Algebra And MySQL You Are To Use The… |

2. Relational Algebra and mySQL

You are to use the following relational database schema, primarykeys are indicated in bold face. The purpose of this database is tohelp understand how the flow of money and political alliancesaffect the“causes” championed by our legislature.

Senator Business RichPerson Cause Contribution Alliance

(SID, name, netWorth, state, party)
(BID, name, netWorth, ceo-ssn)
(SSN, name, netWorth, actualTaxRate,party) (cause-name,politicalAlignment, type) (SID, SSN, amount, cause-name)
(SID1, SID2, cause-name)

Each of the relational attributes is as follows:

Senator.SID: The unique ID of a Senator

Senator.name: The name of a Senator

Senator.netWorth: The total monetary assets of a Senator

Senator.state: The home state of a Senator

Senator.party: The party affiliation (democrat,republican,other)of a Senator

Business.BID: The unique ID of a business

Business.name: The name of a business

Business.netWorth: Total assets of the business

Business.ceo-ssn: The unique social security number of thecompany’s CEO

RichPerson.SSN: SSN of a rich person

RichPerson.name: name of a rich person

RichPerson.netWorth: netWorth of a rich person

RichPerson.actualTaxRate: The real percentage rate of taxes thisperson paid once

all deductions accounted for.

RichPerson.party: The party affiliation of this person, i.e.Republican or Democrat

Cause.cause-name: name of the cause (example: “farmsubsidies”)

Cause.politicalAlignment: group aligned with (left, right,mixed)

Cause.type-name: one of (environment, business law,international, social)

Contribution.SID: The senator the money was give to

Contribution.SSN: The SSN of the person giving the money

Contribution.amount: The amount of the donation

Contribution.cause-name: The cause that is being supported bythe money

Alliance.SID1: First senator in the alliance

Alliance.SID2: Second senator in the alliance

Alliance.cause-name: The cause the senators are working on

For the database schema described above create the queriesdescribed using the Rela- tional Algebra or SQL queries asspecified.

For the Relational Algebra queries you may not use Cartesianproducts. For the SQL queries you are not allowed to createtemporary relations.

2.1. Names of Senators (5 points). Using the Relational Algebra,write a query which finds the names of the republican senators whohave received contributions of more than $100,000 from a richperson who is a democrat.

2.2. Contributions from CEOs (5 points). Using the RelationalAlgebra, write a query which finds the names of senators who havereceived contributions from the CEOs of every business.

2.3. Names of CEOs (5 points). Using the Relational Algebra,write a query which find the names of rich people that are the CEOof some company and have an actualTaxRate of less then 10%.

2.4. Names of Senators (5 points). Using SQL, write a querywhich finds the names of the republican senators who have receivedcontributions of more than $100,000 from a rich person who is ademocrat.

2.5. Supporting a Cause (5 points). Using SQL, write a querywhich finds the pairs of names of senators where one of them is ademocrat and they have formed an alliance for a cause whosealignment is “right”.

2.6. Total Contribution to a Cause (5 points). Using SQL, writea query that for each cause that has a total of $1,000,000 or morein contributions, reports the cause name and total amount ofcontributions for that cause.

Expert Answer


Attached . . .

READ MORE
Coursehelp
Assignments No Comments

Solved: 2. Replicate The Following Plots. A) 5 Bar, At X L… |

MATLAB
2. Replicate the following plots. a) 5 bar, at x locations [3 1 764], heights [10 5 62 9] b) Define y as a 2x4 matrix: y [1 2 3 4:4 3 2 11; Take the transpose of y (y becomes 4x2): 35 Define x as a 1x4 vector: x [11 21 31 41]: Plot the 4 pairs of bar using bar (x, y): 05 21 31 c) The function fx) x2+ 2x + 3, from -5 to 5, with step size 1 Plot the markers (o) and the line altogether 10 -15 .30 352. Replicate the following plots. a) 5 bar, at x locations [3 1 764], heights [10 5 62 9] b) Define y as a 2×4 matrix: y [1 2 3 4:4 3 2 11; Take the transpose of y (y becomes 4×2): 35 Define x as a 1×4 vector: x [11 21 31 41]: Plot the 4 pairs of bar using bar (x, y): 05 21 31 c) The function fx) x2+ 2x + 3, from -5 to 5, with step size 1 Plot the markers (“o”) and the line altogether 10 -15 .30 35 Show transcribed image text 2. Replicate the following plots. a) 5 bar, at x locations [3 1 764], heights [10 5 62 9] b) Define y as a 2×4 matrix: y [1 2 3 4:4 3 2 11; Take the transpose of y (y becomes 4×2): 35 Define x as a 1×4 vector: x [11 21 31 41]: Plot the 4 pairs of bar using bar (x, y): 05 21 31 c) The function fx) x2+ 2x + 3, from -5 to 5, with step size 1 Plot the markers (“o”) and the line altogether 10 -15 .30 35

Expert Answer


Attached . . .

READ MORE