Questions
Exercise 1. Suppose that vehicles taking a particular freeway exit can turn right R, turn left (L), or go straight (S). Consider observing the direction for each of three successive vehicles.

Exercise 1. Suppose that vehicles taking a particular freeway exit can turn right R, turn left (L), or go straight (S). Consider observing the direction for each of three successive vehicles.

(a) List all outcomes in the event A that all three vehicles go in the same direction.

(b) List all outcomes in the event B that all three vehicles take diffierent directions.i

(c) List all outcomes in the event C that exactly two of the three vehicles turn right.

(d) List all outcomes in the event D that exactly two vehicles go in the same direction.

(e) List outcomes in D' ,C, and C \cap D.

 

In: Advanced Math

C++ language or Python. Linked Lists You are given a linked list that contains N integers....

C++ language or Python.

Linked Lists

You are given a linked list that contains N integers. You are to perform the following reverse operation on the list:

  • Select all the subparts of the list that contain only even integers. For example, if the list is {1,2,8,9,12,16}, then the selected subparts will be {2,8}, {12,16}.

  • Reverse the selected subpart such as {8,2} and {16,12}.

  • The list should now be {1,8,2,9,16,12}.

Your node definition should consist of 2 elements: the integer value and a pointer to a node.

Sample Input

9 2 18 24 3 5 7 9 6 12

Sample Output:

24 18 2 3 5 7 9 12 6

In: Computer Science

In Python, write a program to get a positive integer n from keyboard first (your program...

In Python, write a program to get a positive integer n from keyboard first (your program must be able to check the validation of n being positive), and then get n integers from keyboard and store these n integers in a list. Do some processing, and print out average of the elements in the list at end of your program.

For example, suppose user enters 3 first (n = 3), which means we get another three integers from the user. Suppose these three integers are 1, 2, -6. Store them in a list. It is easy to see the list is [1, 2, -6], and average of the elements in the list is (1 + 2 - 6) / 3 = -1.

In: Computer Science

Using Python def specialAverage():    Print the number of 0s and then return the average of...

Using Python

def specialAverage():
  
Print the number of 0s and then return the average of either the positive
values in the list (if the optional parameter has value 1) or the negative
values in the list (if the optional parameter has value 0).
  
Arguments:
a list of numbers : the list can contain any numeric values
an integer : this integer is an optional parameter and only takes value
0 or 1, and defaults to 1 if the user does not specify the value
when calling the function.
  
Return:
a number : the computed average of either positive or negative numbers
rounded to 1 decimal place
  
>>> specialAverage([1,2,3,4,-1,-2,-3,-4],0)
-2.5
and also prints "There are 0 zeros in the list"

In: Computer Science

Linked List-Based Queue Sketches In this section you will sketch several linked list-based queues. Hint: Recall...

Linked List-Based Queue Sketches

In this section you will sketch several linked list-based queues. Hint: Recall that a proper sketch of a linked list-based queue is just a series of boxes with elements inside.

2, 3, 4

Sketch the linked list-based queue that results from the following operations:

  1. Default constructor (create empty)

  2. Add(2)

  3. Add(3)

  4. Add(4)

? Replace this with your sketch

Add and Remove

Sketch the linked list-based queue that results from the following operations:

  1. Default constructor (create empty)

  2. Add(2)

  3. Add(3)

  4. Add(4)

  5. Remove()

? Replace this with your sketch


In: Computer Science

CODE USING LISP... No other language please trim-to (symbol list) Write a function named trim-to that...

CODE USING LISP... No other language please

trim-to (symbol list) Write a function named trim-to that takes a symbol and list as parameters. Return a new list starting from the first occurrence of the input symbol in the input list. If there is no occurrence of the symbol, return nil. For example: (trim-to ‘c ‘(a b c d e)) This should return the following list: ‘(c d e)

ackermann (number number)

Write a function named ackermann that takes two integers. Use the following function definition: (Note: due to this function’s complexity it may not finish for inputs larger than 3)

?(?,?)={?+1 ?? ?=0?(?−1,1) ?? ?=0?(?−1,?(?,?−1)) ??ℎ??????

In: Computer Science

C# Programming; Create a Windows Form Application that displays a scrollable list of 10 random integers...

C# Programming;

Create a Windows Form Application that displays a scrollable list of 10 random integers in the range of 1 to 100. The form should also have (1) an Add button (and input textbox) for the user to add a new number to the list, (2) a Delete button to delete the current selected integer, (3) a Sort button to sort the list, (4) a Reverse button to display the list in reverse order, and (5) Display Multiple (and input textbox) for the user to only display multiples of a particular input value from the list.

Can you help me with the instruction above to do the coding. can you give me example code for the instruction given.

In: Computer Science

Garden Glory is a partnership that provides gardening and yard maintenance services to individuals and organizations....

Garden Glory is a partnership that provides gardening and yard maintenance services to individuals and organizations. Garden Glory is owned by two partners. They employ two office administrators and a number of full- and part-time gardeners. Garden Glory will provide one-time garden services, but it specializes in ongoing service and maintenance. Many of its customers have multiple buildings, apartments, and rental houses that require gardening and lawn maintenance services.

  1. Create a sample list of owners and properties. Your list will be similar in structure to that in Figure 1-34, but it will concern owners and properties rather than owners and pets. Your list should include, at a minimum, owner name, phone, and billing address, as well as property name, type, and address.
  2. Describe modification problems that are likely to occur if Garden Glory attempts to maintain the list in a spreadsheet.
  3. Split the list into tables such that each has only one theme. Create appropriate ID columns. Use a linking column to represent the relationship between a property and an owner. Demonstrate that the modification problems you identified in part B have been eliminated.
  4. Create a sample list of owners, properties, and services. Your list will be similar to that in Figure 1-35. Your list should include the data items from part A as well as the date, description, and amount charged for each service.
  5. Illustrate modification problems that are likely to occur if Garden Glory attempts to maintain the list from part D in a spreadsheet.
  6. Split the list from part D into tables such that each has only one theme. Create appropriate ID columns. Use linking columns to represent relationships. Demonstrate that the modification problems you identified in part E have been eliminated.

In: Operations Management

Create a report that lists customers with the total value of their orders from the database....

Create a report that lists customers with the total value of their orders from the database. Each row of the table should list the customer name and the total value of all orders. Rows should be in descending order according to the total. Just list the first 5 customers, those with the highest total orders.

This part is more complex and, so, can be approached in many ways. You may decide to use simple queries and put the information together using Python code. Alternatively, you might create a single SQL command that will produce the data needed.

Just one strategy will be outlined here, then some variants will be mentioned.

  • Start an empty list for all customers
  • Get a list of customers
    • For each customer get a list of invoices for that customer
      • initialize a variable to get the total of all invoices for the customer
      • For each invoice get a list of pizzas on that invoice
        • For each pizza, get a list of toppings on the pizza
          • Add up the costs of the toppings and add to the customer total
          • Add the crust price and sauce price to the customer total
      • Make a list of data about that customer and add to the list for all customers
  • Sort the list for all customers
  • Print the data

pizza_service.py

import sqlite3

class PizzaServices:

    def __init__(self):
        self.connection = sqlite3.connect("pizza-190807A.sqlite")

    def __enter__(self):
        return self

    def __exit__(self, exe_type, exc_val, exl_tb):
        crs = self.connection.cursor()

    def do_query(self, query, parameters=None):
        crs = self.connection.cursor()
        if parameters:
            crs.execute(query, parameters)
        else:
            crs.execute(query)

        return crs.fetchall()

    def customer(self):
        return self.do_query("select * from customer")

In: Computer Science

Problem Description: Using Python write a Singly‐Linked List (with only the Head pointer) that supports the...

Problem Description: Using Python write a Singly‐Linked List (with only the Head pointer) that supports the following operations: 1. Adding an element at the middle of the list. 2. Removing the middle element of the list (and return the data). 3. Adding an element at a given index. 4. Removing an element at a given index (and return the data). For #1 and #2, ignore the operations if the length of the list is an even number. For #3, if there is already an element at the specified index, it (and everything coming before it) should be shifted left. if the specified index is beyond the existing list, then add the new element at the end of the list. For #4, ignore the operation if there is no item at the specified index. For each of these operations, design appropriate test cases for exhaustively testing the operation, and show the contents of the list before and after executing each test by grouping test case inputoutputs for a given operation to ensure readability.

Note: You have to use the linked list skeleton code provided with this document as a starter code for your solution. You CANNOT use any of the other methods (such as addBefore(), removeAfter(), search(), etc.)

class Node:
"""Node class for a linked list"""
  
def __init__(self, item=None):
"""constructor for the Node class"""
self._item = item
self._next = None
  
def __str__(self):
return str(self._item)
  

class SLL_H:
  
def __init__(self):
self._head = None
  
def __str__(self):
"""overloaded function for converting the linked list to a string"""

str_rep = ""
curr = self._head
  
str_rep +="Head-> "

while(curr):
str_rep +=str(curr._item)
str_rep +=" -> "
curr = curr._next
str_rep +="None"
  
return str_rep

In: Computer Science