Build a computer simulation or a mobile robot

Assignment Help PL-SQL Programming
Reference no: EM133353326

Question 1 Use SQL

There is a blood bank which maintains two tables; DONOR that contains information on the people who are willing to donate blood and ACCEPTOR, the people who are in need of blood. The bank wants to conduct a survey and find out the city that has the best and the worst donor sum amount/accepter sum amount ratio. Both ratios are unique. That is, exactly one city has worse ratio.

The donor sum amount is the total amount of blood, regardless of blood group, that people are ready to donate. The acceptor sum amount is the total amount of blood needed by that city.

There must be exactly two rows that donate the best and the worst ratios. The order of the rows does not matter.
Each row must contain the following attributes.
1. The city's name (CITY)
2. The ratio (donor sum / acceptor sum amount) corrects to 4 decimal places

The schema of two tables is given below:

Donor

Name

Type

Description

ID

integer

It is the id of the donor

Name

String

It is the name of the donor

Gender

Character

It is the gender of the donor

city

string

It is the city where the donor lives

BLOOD_GROUP

String

It is the blood group of the donor

AMOUNT

Integer

It is the amount of blood in pints, which the donator can donate

Acceptor

Name

Type

Description

ID

integer

It is the id of the Acceptor

Name

String

It is the name of the Acceptor

Gender

Character

It is the gender of the Acceptor

city

string

It is the city where the Acceptor lives

BLOOD_GROUP

String

It is the blood group of the Acceptor

ACCEPTER

 

 

ID

NAME

GENDER

CITY

BLOOD_GROUP

AMOUNT

 

1

LINDA

F

Warne, NH

A+

9

 

2

CHARLES

M

Warne, NH

AB+

8

 

3

RICHARD

M

East Natchitoches, PA

AB+

3

 

4

LINDA

F

East Natchitoches, PA

A+

1

 

5

PATRICIA

F

Warne, NH

A+

5

 

Question 2 Please us Python or other language
Delete Nodes Greater Than X > coding Easy List Data structure algorithm problem solving

Question description
Given a singly link list and an integer, x, remove nodes greater than x
Example:
List = 100 -> 105 -> 50
X = 100
List becomes 100 -> 50
Return a reference to the root node of the list after removing 105
Function Description
Complete the function removeNodes in the editor below the function must return a reference to the root node of the final list.
removeNodes has the following parameter(s);
node listHead: a reference to the root node of the singly-linked list
int x: integer, the maximum value to be included in the return singly-linked list
Return a reference to the root node of the list

Constraints
• 1 <= n, x <= 10^5
• 1 <=SinglylinkedListNode values <= 10^5

Input format for custom testing
Input from stdin will be processed as follows and passed to the function
The first line contains an integer n, the number of nodes in the linked list
The next n lines each contain an element to insert into the linked list
The last line contains x, the maximum value allowable in the link list

Question 3 Please use python for this question.
Customer support for an e-commerce business uses a computerized algorithm for evaluation if support tickets are still open. Open and closed tickets are represented by different by different open and closed braces respectively. For example, each of the braces '( [ { represent an open ticket and need matching braces }])' in that order to close them.
The braces in a string are balanced if the following conditions are met.
• All open braces must be closed
• Each closed braces must have a matching open brace
• Any set of nested braces must be closed before its surrounding braces

Given a 2-dimentiaonal array of strings comprised of braces, verify that the braces in each string are balanced.
Return ‘YES' if the braces are balanced and ‘NO' otherwise
Example
Braces = [‘[{}]', ‘[{]}']
• The braces in the first string ‘[{}]' are balanced, because all braces are closed and all nested are closed in order.
• The braces in the second string ‘[{]}' are not balanced, because the nested brace "{ was not closed before its surrounding "[ ]', so the order was not respected.
• The result is [‘Yes', ‘NO']
Function description matchBraces in the editor below
matchingBraces has the following parameter(s);
string braces[n]; an array of strings to analyze
returns:
string[]; an array of strings, either ‘YES' or ‘NO' where the string at each index i denotes whether the braces are balanced[i].
Constraints
• 1 <= n <=15
• 1 <= length of each braces [i] <= 100
• Each braces[i] consists of (, ), {, }, [ and ] only,
Input format for custom testing
Input from stdin will be processed as follows and passed to the function
The first line contains an integer n, the number of elements in braces.
Each of the next n lines contains a string that describes braces[i] where 0 <=i< n
Sample input
STDIN Function
-------- -----------
2 ---> braces [ ]size n =2
[} [ ] ( ) --> braces = [ ‘ { } [ ] ( ) ‘ , ‘{ [ } ] } ‘ ]
{ [ } ] }
Sample Output
YES
NO
Explanation
• The braces in the first string ‘{} [] ()' are balanced, because all braces are closed.

Question 4 Used python for this or other language.
Build a computer simulation or a mobile robot. The robot moves on an infinite plane, starting from position (0, 0), its movements are described by a command string consisting of one or more of the following three letters
• G instructs the robot to move forward one step.
• L instructs the robot to turn left in place
• R instructs the robot to turn right in place
The robot performs the instruction in command sequence in an infinite loop. Determine whether there exists some circle such that the robot always moves within the circle.
Consider the commands R and G executed infinitely. A diagram of the robot's movement looks like;
RG ---> RG,

RG <---- RG
The robot will never leave the circle.
Function description
Complete the function doesCircleExist in the editor below. The function must return an array of n strings either YES or NO based on whether the robot is bound within the circle or not. In order of test results.

doesCircleExist has the following parameter(s);
commands[commands[0]...commands[n-1]]: An array of n commands[1] where each represents a list of commands to test.

Constraints
• 1 <= |commands[i]| <= 2500
• 1 <= n <= 10
• Each command consists of G, L, and R only
Input format for custom testing
Input from Stdin will be processed as follows and passed to the function.
The first line contains an integer n,the number of elements in commands.
The next n lines each contain a string describing commands[i] where 0 <= I < n.
Sample Case 0
3
G
L
RGRG

Sample output
If they are in the circle
NO
YES
YES
Explanation 1
Consider the robot's initial orientation to be facing north toward the positive y direction. The robot performs the following four steps in a loop:
1. Go forward one step. The robot moves from (0, 0) to (0, 1).
2. Turn right. The robot turns eastward, facing the positive x direction.
3. Go forward one step. The robot moves from (0, 1) to (1, 1).
4. Turn left. The robot turns northward, facing the positive y direction again.

RG -----> LG

RG ----> LG

G
The robots than repeats these steps infinitely, following an endless zig-zag path in the north-easterly direction. Because the robot will never turn in such a way it would be restricted to a circle. Set index 0 of the return array to NO.
Hint 1
If it is not required to perform the commands infinitely. Performing the commands 4 times in a row is sufficient to check if it forms a circle.
Hint 2
Duplicate the command 4 times and start from (0, 0). Update the x and y coordinates based on the particular instruction (‘L', ‘R' or ‘G'), if the final coordinates is again (0, 0) it forms a circle

Question 5. Use SQL

There is a database that contains a website's traffic data over a period of 30 days. The first table contains user's information including the user type (user, crawler, admin). The second table consists of the time of each visit to the website, the id of the visitor, time spent on the website for users.user_type = ‘user'.
Note: avg time spent must have 4 decimals digits and rounded off(example: 5/3 = 16667, 5/2 = 2.5000 and 1/3 = 0.3333)

Schema
There are two tables : users, traffic

Users

Name

Type

Description

Id

INTEGER

The user's unique id, it is the primary key

Name

VARCHAR

his is the second column and the name of the user

User_type

VARCHAR

Type of user

Traffic

Name

Type

description

User_id

INTEGER

Id of the user from the users table

Visited_on

DATE

Date on which the user visited the website

Time_spent

INTEGER

Time spent on website in seconds

Sample Data tables

USERS

Id

Name

User_type

1

Matt

user

2

John

user

3

Louis

admin

Traffic

Id

Type

description

1

2019-03-01

15

2

2019-03-02

20

3

2019-03-03

10

Sample output
Visited_onavg_time_spent
2019-03-01 15.0000
2019-03-02 17.0000
2019-03-03 15.0000
Expalnation
Row 1: 15/1 = 15.0000
Row 2: (15+20)/2 = 17.0000
Row 3: (15+20+10)/3 = 15.0000

Question 6 you can use python or other language
In the challenge, write a program to analyze a log file and summarize the results. Given a text file of an http requests log, list the number of requests from each host. Output should be directed to a file as described in program description below.
The format of the log file, a text file with .txt extension, follows. Each line contains a single log record with the following column (in order):
1. The hostname of the host making the request.
2. This column's value is missing and were replace by a hyphen.
3. This column's value is missing and were replace by a hyphen.
4. A timestamp enclosed in square brackets following the format [DD/mmm/YYYY:HH:MM:SS -0400], where dd is the day of the month, mmm is the name of the name of the month, YYYY is the year, HH:MM:SS is the time in 24-hour format, and -o4000 is the time zone.
5. The request, enclosed in quotes (e.g. "GET /images/NASA-logosmall.gif[ HTTP/1.0").
6. The HTTP response code
7. The total number of bytes sent in the response
Given the following log record:

Unicomp6.unicomp.net - - [01/jul/1995:00:00:06 -4000] "GET/shuttle/countdown/ HTTP/1.0" 200 3985
We can label each column in the record like this

Hostname - - Timestamp Request HTTP Response Bytes sent
Unicomp6.unicomp.net - - [01/jul/1995:00:00:06 -0400] "GET/shuttle/countdown/ HTTP/1.0" 200 3985

Function description
Your function must create a unique list of hostnames with their number of requests output to a file named records_filename where filename is replaced with the input filename. Each hostname should be followed by a space, the number of requests, and a newline. Order doesn't matter.
Constraints
• The log file has a maximum of 2 x 10^5 times records.
Input format
There is one line of input which contains the string filename read from STDIN.
Sample input 0
Hosts_access_log_00.txt
Sample Output 0
Given filename = "hosts_access_log_00.txt" process the records in hosts_access_log_00.txt and create an output file name records_hosts_access_log_00.yxt which contains the following rows:
Burger.letters.com 3
D104.aa.net 3
Unicomp6.unicomp.net 4.

Explanation 0
Unicomp6.unicomp.net - - [01/jul/1995:00:00:06 -0400]"GET/shuttle/countdown/ HTTP/1.0" 200 3985
Burger.letters.com - - [01/jul/1995:00:00:06 -0400] "GET/shuttle/countdown/liftoff.html HTTP/1.0" 304 0
Burger.letters.com - - [01/jul/1995:00:00:12 -0400] "GET/images/NASA-logosmaill.gif HTTP/1.0" 304 0
Burger.letters.com - - [01/jul/1995:00:00:12 -0400] "GET/shuttle/countdown/video/livevideo.gif HTTP/1.0" 200 0
D104.aa.net - - [01/jul/1995:00:00:13 -0400] "GET/shuttle/countdown/ HTTP/1.0" 200 3985
Unicomp6.unicomp.net - - [01/jul/1995:00:00:14 -0400] "GET/shuttle/countdown/count.gif HTTP/1.0" 200 40310
Unicomp6.unicomp.net - - [01/jul/1995:00:00:14 -0400] "GET/images/NASA-logosmaill.gif HTTP/1.0" 200 786
Unicomp6.unicomp.net - - [01/jul/1995:00:00:14 -0400] "GET/images/KSC-logosmall.gif HTTP/1.0" 200 1204
D104.aa.net - - [01/jul/1995:00:00:15 -0400] "GET/shuttle/countdown/count.gif HTTP/1.0" 200 40310

D104.aa.net - - [01/jul/1995:00:00:15 -0400] "GET/images/NASA-logosmaill.gif HTTP/1.0" 200 786

When the data is consolidated, it confirms the following:
• The host Unicomp6.unicomp.net made 4 requests
• The host Burger.letters.com made 3 requests
• The host D104.aa.net made 3 requests

Reference no: EM133353326

Questions Cloud

What were some ah-ha moments that arose : What were some "ah-ha!" moments that arose? Is there anything that challenged your own personal views or opinions? Why were these topics important to discuss
Concept of a tyranny of the majority : Let's discuss Tocqueville's concept of a "tyranny of the majority." Discuss your feelings regarding this concept.
How have healthcare disparities among people of color : How have healthcare disparities among people of Color/Ethnic groups in urban populations affected the life expectancy of people of color?
What is the narrative about the role of native americans : David Treuer Lane Lecture: Modern Native America and Environmental Justice: Changing the Narrative (first 60 minutes) What is the narrative about the role
Build a computer simulation or a mobile robot : Build a computer simulation or a mobile robot. The robot moves on an infinite plane, starting from position (0, 0), its movements are described by a command
Describe race, class or gender inequality : what they observe. Use a functionalist perspective to describe race, class or gender inequality. Then do the same from the viewpoint of a conflict theorist
Why is important to exercise plans as an emergency manager : Explain why that incident response needed better testing, training, and exercise plans by emergency management.
Describe how you have grown personally and professionally : Explain Person in Environment. What can we learn about clients using Persons in Environment? Reflect back to the concepts of the textbook that were significant
How does their racial identity restrict theirchoices : Describing the city's continually reinforced segregation, Desmond notes "Most Milwaukeeansbelieved their city was racially segregated because people preferred

Reviews

Write a Review

PL-SQL Programming Questions & Answers

  Create a database model

Create a database model and Submit the table creation statements for the Database Model.

  Write pl-sql procedures and functions

Write PL/SQL procedures and functions to populate and query that database

  Sql questions

Write a query to display using the employees table the EMPLOYEE_ID, FIRST_NAME, LAST_NAME and HIRE_DATE of every employee who was hired after to 1 January, 1995.

  Run the lab_03_01.sql script

Run the lab_03_01.sql script in the attached file to create the SAL_HISTORY table. Display the structure of the SAL_HISTORY table.

  Write sql queries

Write a query to display the last name, department number, and salary of any employee whose department number and salary both match the department number and salary of any employee who earns a commission.

  Explaining sql insert statement to insert new row in cds

Write down a SQL insert statement to insert new row in "CDS" table.

  Write down name of actors in ascending order

Write down actors (or actress, your choice, but not both) who have won at least two (2) Academy Awards for best actor/actress. Provide the actor name, movie title & year. Order the result by actor name."

  What is an sql injection attack

What is an SQL injection attack? Explain how it works, and what precautions must be taken to prevent SQL injection attacks.What are two advantages of encrypting data stored in the database?

  Determine resonant frequency in series rlc resonant circuit

Given the series RLC resonant circuit in the figure, operating at variable frequency, determine: The resonant frequency ω o ,  The circuit’s quality factor Q , The cut-off frequencies, f 1  & f 2  and the bandwidth BW

  Query that uses cube operator to return lineitemsum

Write summary query which uses CUBE operator to return LineItemSum (which is the sum of InvoiceLineItemAmount) group by Account(an alias for AccountDesciption).

  Query to show customers were missing for existing orders

As DBA, your manager called a meeting and asked why there are so many orders for customers that don't exist in the customer table. Write query which would shows which customers were missing for existing orders. Use a join or a subquery.

  Sql query into a relational algebra statement

Turn this SQL query into a relational algebra statement? SELECT Request.reqfor, Ordering.invamt, Ordering.invnbr, Ordering.invdat

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd