Questions
Important: you are required to use only the functional features of Scheme; functions with an exclama-...

Important: you are required to use only the functional features of Scheme; functions with an exclama- tion point in their names (e.g., set!) and input/output mechanisms other than load and the regular read-eval-print loop are not allowed. (You may find imperative features useful for debugging. That’s ok, but get them out of your code before you hand anything in.)

1. (10 pts) Write a function atLeast that returns true if a list is at least as long as the argument value, and false otherwise. Use predicate functions and recursion, and assume that the length given is at least 0 (i.e., the first parameter cannot be negative).
> (atLeast 5 ’(1 2 3 4))
#f
> (atLeast 5 ’(2 4 6 8 10))
#t


using the programming language scheme

In: Computer Science

Add a copy constructor for the linked list implementation below: ---------------------------------------------------------------------------------------------------------------------------------------------------- // list.cpp file #include <string>

Add a copy constructor for the linked list implementation below:

----------------------------------------------------------------------------------------------------------------------------------------------------

// list.cpp file

#include <string>
#include "list.h"

using namespace std;

Node::Node(string element)
{
data = element;
previous = nullptr;
next = nullptr;
}

List::List()
{
first = nullptr;
last = nullptr;
}

List::List(const List& rhs) // Copy constructor - homework
{
// Your code here
  
}

void List::push_back(string element)
{
Node* new_node = new Node(element);
if (last == nullptr) // List is empty
{
first = new_node;
last = new_node;
}
else
{
new_node->previous = last;
last->next = new_node;
last = new_node;
}
}

void List::insert(Iterator iter, string element)
{
if (iter.position == nullptr)
{
push_back(element);
return;
}

Node* after = iter.position;
Node* before = after->previous;
Node* new_node = new Node(element);
new_node->previous = before;
new_node->next = after;
after->previous = new_node;
if (before == nullptr) // Insert at beginning
{
first = new_node;
}
else
{
before->next = new_node;
}
}

Iterator List::erase(Iterator iter)
{
Node* remove = iter.position;
Node* before = remove->previous;
Node* after = remove->next;
if (remove == first)
{
first = after;
}
else
{
before->next = after;
}
if (remove == last)
{
last = before;
}
else
{
after->previous = before;
}
delete remove;
Iterator r;
r.position = after;
r.container = this;
return r;
}

Iterator List::begin()
{
Iterator iter;
iter.position = first;
iter.container = this;
return iter;
}

Iterator List::end()
{
Iterator iter;
iter.position = nullptr;
iter.container = this;
return iter;
}

Iterator::Iterator()
{
position = nullptr;
container = nullptr;
}

string Iterator::get() const
{
return position->data;
}

void Iterator::next()
{
position = position->next;
}

void Iterator::previous()
{
if (position == nullptr)
{
position = container->last;
}
else
{
position = position->previous;
}
}

bool Iterator::equals(Iterator other) const
{
return position == other.position;
}

----------------------------------------------------------------------------------------------------------------------------------------------------------------

Use the following header file, and test program (not to be modified) to verify that the copy constructor works correctly:

----------------------------------------------------------------------------------------------------------------------------------------------------------------

// list.h file

#ifndef LIST_H
#define LIST_H

#include <string>

using namespace std;

class List;
class Iterator;
//template <typename T>
class Node
{
public:
/**
Constructs a node with a given data value.
@param element the data to store in this node
*/
Node(string element); // Node(T element)
// Node(T data, Node<T>* n, Node<T>* n);
private:
string data; // T data;
Node* previous;
Node* next;
friend class List;
friend class Iterator;
};

class List
{
public:
/**
Constructs an empty list.
*/
List();
List(const List& rhs); // Homework
/*
Appends an element to the list.
@param element the value to append
*/
void push_back(string element);
/**
Inserts an element into the list.
@param iter the position before which to insert
@param element the value to insert
*/
void insert(Iterator iter, string element);
/**
Removes an element from the list.
@param iter the position to remove
@return an iterator pointing to the element after the
erased element
*/
Iterator erase(Iterator iter);
/**
Gets the beginning position of the list.
@return an iterator pointing to the beginning of the list
*/
Iterator begin();
/**
Gets the past-the-end position of the list.
@return an iterator pointing past the end of the list
*/
Iterator end();
private:
Node* first;
Node* last;
friend class Iterator;
};

class Iterator
{
public:
/**
Constructs an iterator that does not point into any list.
*/
Iterator();
/**
Looks up the value at a position.
@return the value of the node to which the iterator points
*/
string get() const;
/**
Advances the iterator to the next node.
*/
void next();
/**
Moves the iterator to the previous node.
*/
void previous();
/**
Compares two iterators.
@param other the iterator to compare with this iterator
@return true if this iterator and other are equal
*/
bool equals(Iterator other) const;
private:
Node* position;
List* container;
friend class List;
};

#endif

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

// list_test .cpp file

#include <string>
#include <iostream>
#include "list.h"

using namespace std;

int main()
{
List names;

names.push_back("Tom");
names.push_back("Diana");
names.push_back("Harry");
names.push_back("Juliet");

// Add a value in fourth place

Iterator pos = names.begin();
pos.next();
pos.next();
pos.next();

names.insert(pos, "Romeo");

// Remove the value in second place

pos = names.begin();
pos.next();

names.erase(pos);

List names_copy(names); //Copy constructor - homework
names_copy.push_back("Shakespeare");
// Verify that Shakespeare was inserted.
cout << "Printing new list" << endl;
for (pos = names_copy.begin(); !pos.equals(names.end()); pos.next())
{
cout << pos.get() << endl; //
}
cout << "Printing original list " << endl;
for (pos = names.begin(); !pos.equals(names.end()); pos.next())
{
cout << pos.get() << endl;
}

return 0;
}


---------------------------------------------------------------------------------------------------------------------------------------------------------------

Thank you for your time and help!

In: Computer Science

The following equation can be used to compute values of y as a function of x:...

The following equation can be used to compute values of y as a function of x: ? = ?? −??sin(??)(0.012? 4 − 0.15? 3 + 0.075? 2 + 2.5?) where a and b are parameters. Write a Matlab script file (m file) with the following steps: Step 1: Define scalars a = 2, b = 5. Step 2: Define vector x holding values from 0 to π/2 in increments of Δx = π/40. Step 3: generate the vector y using element-wise product (dot product). Step 4. Compute the vector z = y 2 where each element holds the square of each element of y. Step 5: Combine x, y, and z into a matrix w, where each column holds one of the variables, and display w using the short g format. Step 6: Generate plots of y and z versus x using dashed lines. Step 7: Include legends for each plot (for y vs. x plot, use “y” as legend; for z vs. x plot, use “z” as legend).

In: Computer Science

Given the following numbers in the given order, show the red black tree              100, 200,...

Given the following numbers in the given order, show the red black tree

             100, 200, 150, 170, 165, 180, 220, 163, 164

Show the pre-order traversal of this red black tree while showing the color of each node in the pre-order traversal.

Write (C++) the red black tree code and insert the above numbers. Show the screen shot of the pre-order traversal of the resulting tree. Distinguish the colors by writing a * next to the black color values. Compare the result with the previous question.

In: Computer Science

Write a C-based language program in visual studio that uses an array of structs that stores...

Write a C-based language program in visual studio that uses an array of structs that stores student information including name, age, GPA as a float, and grade level as a string (e.g., “freshmen,”).

Write the same program in the same language without using structs.

In: Computer Science

Who is (or are) the main protagonists in - Business Intelligence Software at SYSCO case? These...

Who is (or are) the main protagonists in - Business Intelligence Software at SYSCO case? These are people/stakeholders (not systems)

In: Computer Science

If F2F meetings become rare, what additional impacts do you see on the travel industry? Describe...

If F2F meetings become rare, what additional impacts do you see on the travel industry? Describe travel industry investments that make sense and those that do not.

In: Computer Science

Suppose that a and b are integers. (a) (5 pts) Use a proof by contradiction to...

Suppose that a and b are integers.

(a) (5 pts) Use a proof by contradiction to prove the statement ”If a − b is even, then a and b have the same parity (that is, they are both even or both odd).” Carefully show your algebra.

(b) (5 pts) Show that any odd integer cubed is also an odd integer. Carefully show your algebra.

(c) (5 pts) Use your results from parts (a-c) in a direct proof to show that ”If a − b is even, then a 3 − b 3 is even.”

(5) (a) (2.5 pts) In your own words what is a base case and why is it important?

(b) (2.5 pts) In your own words what is an inductive hypothesis and how is it used?

(c) (10 pts) Prove that P(n) : 1+24+34+44+· · ·+n 4 = n 30 (n+1)(2n+1)(3n 2+3n−1), ∀n ≥

1. (i) What is P(1)? (ii) Show that P(1) is true. (iii) What do you need to prove in the inductive step? (iv) Complete the inductive step, identifying where you use the inductive hypothesis. (v) Explain why these steps show that this formula is true whenever n ≥ 1.

In: Computer Science

Case Project 3-3: Hardware Overheating The university is having some problems with the desktop computer that...

Case Project 3-3: Hardware Overheating The university is having some problems with the desktop computer that runs the Intel Core Duo CPU. The computers will suddenly scramble the display screens and freeze. Because of this, the university wants to stay away from having desktops running any of the Intel CPUs. What would you recommend to address the problem? Research some of the causes of overheating hardware and suggest possible remedies. In addition, what desktop CPUs would you recommend for replacing their older hardware? Provide an explanation for your recommendation and what the university should do in the future.

In: Computer Science

5. Write a program that prints all numbers between 27 and 78, one number per line....

5. Write a program that prints all numbers between 27 and 78, one number per line.

6. In questions 6,7 the following list is used: [1,2,5,6,3,77,9,0,3,23,0.4,-12.4,-3.12]

7. Using “for” loop, write program that finds the smallest number in the list.

8. Using “for” loops, calculate arithmetic mean of all numbers in the list. Do not use built-in function in Python.

9. For this question envision you are creating a dummy alert to help the doctor determine if patient needs a mammogram or not: Ask the user to answer the following questions:

• "What is your patient’s gender? Please answer F for female, M for male " and store it in a variable "gender".

• "What is your patient’s age? " store it in a variable "age"

• "Does your patient have family history of breast cancer? Please answer with True or False " store it in a variable name "history" The program should display the following alert messages based on conditions:

• If patient is female and over 40 the system should alert the doctor to "consider ordering mammogram”

• If the patient is female but younger than 40 the program should go to next step and consider patient family history to determine if mammogram is recommended. If patient has family history of breast cancer the program should display a message "consider mammogram because of family history". If not just display "my not need mammogram" • In any other case the alert should say "no mammogram order recommended". Suggestion: Attention to the variable types when you input and compare.

In: Computer Science

Case Project 3-2: Desktop Computing The director has evaluated your server recommendations and asks you to...

Case Project 3-2: Desktop Computing The director has evaluated your server recommendations and asks you to design a strategy for upgrading the desktop hardware. He feels that most of the university’s desktop computers need to be replaced. You should explain your strategy.

In: Computer Science

Write a recursive a c++ code that checks if a number is Palindrome. A palindrome number...

Write a recursive a c++ code that checks if a number is Palindrome. A palindrome number is a number that reads the same from beginning to end and from end to beginning, in other words, a palindrome number remains the same when its digits are reversed. For example, 13431 is a palindrome number. 2332 is another one. (Note: Your algorithm should define and work with an integer number) The functionality of your code should be commented to explain what you do in each part of the code. You need to run your code for the following test cases and show the result:

1) 0 (output: yes)

2) 1234554321 (output: yes)

3) 123454321 (output: yes)

4) 1221 (output: yes)

5) 1234 (output: no)

6) 7676 (output: no)

7) -121 (output: yes)

8) -456 (output: no)

What is the time complexity of your algorithm? Cleary justify your answer.

In: Computer Science

How does the Business Intelligence Software at SYSCO case align with the BI perspective?

How does the Business Intelligence Software at SYSCO case align with the BI perspective?

In: Computer Science

Write a program in java to determine whether a given function F from the set {0,1,2,3,...,m}...

Write a program in java to determine whether a given function F from the set {0,1,2,3,...,m} to (0,1,2,3,...,n} is one-to-one and/or onto. The inputs to your program will be:

- an integer m

- an integer n, and

- a two dimensional boolean array F of size (m+1) x (n+1), where F[ i , j ] = 1 if F(i) = j.

In: Computer Science

java program You are required to implement a Patient Information System for a clinic according to...

java program

You are required to implement a Patient Information System for a clinic according to the following specifications:

  • Class #1 PatientRecords (Tester class with main):

This class contains a full list of patients (array list) and it provides the following functionalities:

  • Add patient by ID-Number

  • Print all records

  • Print the number of patients based on specific attributes such as: disease name, gender.

***** See examples below for the input format (use console)

  • Class #2 Patient:

This class contains personal information about each patient. It consists of the following fields (private):

  • Patient’s name

  • Patient’s age

  • Patient’s gender

  • Patient’s date of last visit

  • Patient’s disease and syndromes.

  • Patient’s status (waiting-for-analysis-results, on-medication, healed)

    The class should provide a printRecord method for each patient.

  • Class #3 Disease:

This class describes the basic information of a disease. It consists of the following fields:

  • Disease’s name

  • Array List of syndromes (such as fever, general weakness, …)

Examples of commands:

  • add ID-Number                          ex:add 89548856
    This command adds a new patient with ID = 89548856 to the record. (If the ID is already in the list, print an error message).

  • SetInfo ID-Number name, gender, age           ex:setInfo 89548856 “Ali”, “male”, 35

  • Set ID-Number attribute value                      ex:set 89548856 date “16/10/2020"
                                                                            set 89548856 disease “flu”                                                                         set 89548856 status “healed”

  • Adds ID-Number value                                ex:adds 89548856 “fever”
    -- Adds means add syndrome

  • Print-record ID-Number                              ex:print-record 89548856

  • This command prints the full details of the patient (in a clear format of your choice).

  • Print-all

This command prints a table of all patients in the list (names, age and date of last visit)

  • Print-all attribute value   ex:print-all gender “male”
    This command prints the count of all male patients in the list

print-all disease “flu”
Print-all status “on-medication”

General Notes:

  • All commands are case insensitive.

  • You are responsible for building a user-friendly console application (error messages, clear menu, input validation, ...)

  • Use any suitable and useful OOP techniques (composition, enum, inheritance, ...)

In: Computer Science