Discuss the concept of data independence and explain its importance in a database environment.
In: Computer Science
please do all parts
a.For resizable array based implementation, what is the time complexity in the worst and base case scenario? Explain.
b. For linked implementation of a list, what is the time complexity in the wort and best case scenario? Explain.
remove(givenPosition: integer)
In: Computer Science
Original C code please.
Part 1:
You can do A, B, and C in one program with multiple loops (not nested) or each one in a small program, it doesn’t matter.
A. Create a loop that will output all the positive multiples of 9 that are less than 99.
9 18 27 36 45 ….
B. Create a loop that will output all the positive numbers less than 200 that are evenly divisible by both 2 and 7.
14 28 42 …
C. Create a loop that will calculate the sum of the positive multiples of 8 that are between 100 and 500. Output the sum.
Part 2:
You’re the teacher now! You need to count how many passing grades are entered. We don’t know how many grades there will be. Use a sentinel controlled while loop that will ask the user to enter student grades until a value of -1 is entered. Use a counter variable to count all the grades that are passing grades, where 70 is the minimum passing grade (I know, you’re a tough grader!) If there are any grades that are out of the valid range (0 through 100), present an error message to the user, and do not count that grade as passing (or valid). We also would like to see what percentage of the valid grades are passing.
Create 3 test cases. Use this as one of them:
Grades Entered: Expected Results
45
90
70
87
123 That is not a valid grade!
100
-1 You entered 4 passing grades.
80.0% of the valid grades are passing.
Create two more sets of test data of your own, and include screenshots of your program running them. Demonstrate all program functionality.
In: Computer Science
You will be inserting values into a generic tree, then printing the values inorder, as well as printing the minimum and maximum values in the tree. Given main(), write the methods in the 'BSTree' class specified by the // TODO: sections. There are 5 TODOs in all to complete.
Ex: If the input is
like ferment bought tasty can making apples super improving juice wine -1
the output should be:
Enter the words on separate lines to insert into the tree, enter -1 to stop The Elements Inorder: apples - bought - can - ferment - improving - juice - like - making - super - tasty - wine - The minimum element in the tree is apples The maximum element in the tree is wine
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
BSTree<String> tree = new
BSTree<String>();
Scanner scrn = new
Scanner(System.in);
System.out.println("Enter the words
on separate lines to insert into the tree, enter -1 to
stop");
String word =
scrn.nextLine();
while(!word.equals("-1")) {
tree.addElement(word);
word =
scrn.nextLine();
}
System.out.println();
tree.printElements();
System.out.println("\nThe minimum
element in the tree is " + tree.findMin());
System.out.println("\nThe maximum
element in the tree is " + tree.findMax());
}
}
public class BSTreeNode<T> {
private T element;
private BSTreeNode<T> left, right;
public BSTreeNode(T element) {
this.element = element;
this.left = null;
this.right = null;
}
public T getElement() {
return element;
}
public void setElement(T element) {
this.element = element;
}
public BSTreeNode<T> getLeft() {
return left;
}
public void setLeft(BSTreeNode<T> left)
{
this.left = left;
}
public BSTreeNode<T> getRight() {
return right;
}
public void setRight(BSTreeNode<T> right)
{
this.right = right;
}
}
public class BSTree<T> {
private BSTreeNode<T> root = null;
// TODO: Write an addElement method that inserts
generic Nodes into
// the generic tree. You will need to use a Comparable
Object
// TODO: write the method printElements
// It should check that the tree
isn't empty
// and prints "The Tree is empty"
if it is
// otherwise prints "The Elements
Inorder: "
// and calls the inorder method
// TODO: write the inorder method that traverses
// the generic tree and prints the
data inorder
// TODO: write the findMin method that returns
the
// minimum value element in the
tree
// TODO: write the findMin method that returns
the
// maximum value element in the
tree
}
In: Computer Science
An international conference for Java programmers was held last month. The event organizers wish to distribute a series of prizes by post to the event attendees. For this they have decided that the winners will be those pairs of people whose ages add up to a given S number. During the event, all the attendees registered their full name and age in a computer system. For this reason, the organizers have a text-type file, where the names and ages of all the attendees are found, ordered in decreasing order with respect to ages. It is also known that the ages of all the attendees are different from each other (there are no repeated ages). Example 1: Suppose we want to find the pairs of participants whose age adds up to S = 51, and we have the following series of participants: Carlos Perez, 40 Karla Ortiz, 38 Jose Lopez, 35 Claudia Ruiz, 13 Luis Diaz, 11 So the output would be: Carlos Perez (40), Luis Diaz (11) Karla Ortiz (38), Claudia Ruíz (13) Total Winners: 2 Example 2: Suppose we want to find the pairs of participants whose age adds up to S = 10, and we have the following series of participants: Carlos Perez, 40 Karla Ortiz, 38 Jose Lopez, 35 Claudia Ruiz, 13 Luis Diaz, 11 So the output would be: There are no winners.
Develop a Java program that allows organizers to find the winning pairs. Said program must comply with the following functionality: It contains a main class called Winner.java
It contains a class Participant.java that is used to represent objects in memory with the data of the participants (name and age).
The main method, of the main Winner.java class, receives the file with the data of the conference attendees via command line redirection. For example, java Winner <attendees01.csv. This file has the following format: The first line contains an integer that represents the sum S of ages sought. The following lines each contain the name and age of a participant, separated by a comma.
There is a DataReading method that receives as a parameter an object of the Scanner class that allows receiving data from standard input (System.in) and loading it into a data structure that allows solving the problem.
There is a search for Winners method that receives as a parameter an integer that represents the sum S of ages searched and prints on the screen: If there are winners, the data (name and age) of the pairs of people (one pair per line) using the following format: Name1 Surname1 (Age1), Name2 Surname2 (Age2) The total X of winning pairs using the format: "Total winners: X", or the message "There are no winners".
In: Computer Science
Hello, I need this is C++. Thank you! (1B)
Write a Fraction class whose objects will represent Fractions.
Note: this is the first part of a multi-part assignment. For this week you should not simplify (reduce) fractions, you should not use "const," and all of your code should be in a single file. In this single file, the class declaration will come first, followed by the definitions of the class member functions, followed by the client program.
You must provide the following member functions:
Your class should have exactly two data members, one to represent the numerator of the Fraction being represented, and one to represent the denominator of the Fraction being represented.
Here's a hint for how you will set up your arithmetic operation functions: You need two Fractions. One is the parameter, one is the calling object. The function multiplies the calling object times the parameter and returns the result. In some ways it is similar to the comesBefore() function from the lesson. That function also needs two Fractions, and one is the calling object and one is the parameter.
When adding or subtracting Fractions, remember that you must first find the common denominator. The easy way to do this is to multiply the denominators together and use that product as the common denominator.
I am providing a client program for you below. You should copy and paste this and use it as your client program. The output that should be produced when the provided client program is run with your class is also given below, so that you can check your results.
I strongly suggest that you design your class incrementally. For example, you should first implement only the set function and the output function, and then test what you have so far. Once this code has been thoroughly debugged, you should add additional member functions, testing each one thoroughly as it is added. You might do this by creating your own client program to test the code at each stage; however, it would probably be better to use the provided client program and comment out code that relates to member functions that you have not yet implemented.
As you can see from the sample output given below, you are not required to reduce Fractions or change improper Fractions into mixed numbers for printing. Just print it as an improper Fraction. You are also not required to deal with negative numbers, either in the numerator or the denominator.
Here is the client program.
#include <iostream>
using namespace std;
int main()
{
Fraction f1;
Fraction f2;
Fraction result;
f1.set(9, 8);
f2.set(2, 3);
cout<<"\nArithmetic operations with fraction objects stored in the results class object\n";
cout<<"------------------------------------------------------------------------------\n\n";
cout << "The product of ";
f1.print();
cout << " and ";
f2.print();
cout << " is ";
result = f1.multipliedBy(f2);
result.print();
cout << endl;
cout << "The quotient of ";
f1.print();
cout << " and ";
f2.print();
cout << " is ";
result = f1.dividedBy(f2);
result.print();
cout << endl;
cout << "The sum of ";
f1.print();
cout << " and ";
f2.print();
cout << " is ";
result = f1.addedTo(f2);
result.print();
cout << endl;
cout << "The difference of ";
f1.print();
cout << " and ";
f2.print();
cout << " is ";
result = f1.subtract(f2);
result.print();
cout << endl;
if (f1.isEqualTo(f2)){
cout << "The two Fractions are equal." << endl;
} else {
cout << "The two Fractions are not equal." << endl;
}
cout<<"\n---------------------------------------------------------\n";
cout<<"\nFraction class implementation test now successfully concluded\n";
// system ("PAUSE");
return 0;
}
This client should produce the output shown here:
C++ CLASS SINGLE-FILE PROJECT Client.cpp - testing a Fraction class implementation
----------------------------------------------------
Arithmetic operations with Fraction objects stored in the result class object
------------------------------------------------------------------------------
The product of 9/8 and 2/3 is 18/24
The quotient of 9/8 and 2/3 is 27/16
The sum of 9/8 and 2/3 is 43/24
The difference of 9/8 and 2/3 is 11/24
The two Fractions are not equal.
---------------------------------------------------------
Fraction class implementation test now successfully concluded
Process returned 0 (0x0) execution time : 10.546 s Press any key to continue.
In: Computer Science
Explain What is being executed in this code. State all changes in values when traversing loops.
#include <stdio.h>
#define NUM_PRODUCTS 2
#define NUM_CATEGORIES 2
#define NUM_DIGITS 2
struct ProductInfo
{
int prodID;
int numberInStock;
double unitPrice;
};
int main(void)
{
struct ProductInfo productList[NUM_PRODUCTS] =
{
{78, 8, 19.95},
{95, 14, 22.98}
};
int categoryCount[NUM_CATEGORIES] = { 0 };
int i, j, sum, id, divisors[] = { 10, 1 };
for (i = 0; i < NUM_PRODUCTS; i++)
{
sum = 1;
id = productList[i].prodID;
for (j = 0; j < 2; j++)
{
sum *= id / divisors[j];
id = id % divisors[j];
}
categoryCount[sum % NUM_CATEGORIES] += productList[i].numberInStock;
}
for (i = 0; i < NUM_CATEGORIES; i++)
{
if (categoryCount[i] % 2 == 0)
{
printf("Category %d has %d items\n", i, categoryCount[i]);
}
}
return 0;
}
In: Computer Science
In constraint satisfaction, local search is a method for solving the problem. Is this an example of a hill climbing search or gradient decent search? Why? How would you convert the algorithm between the two?
In: Computer Science
Using Python
Write a GUI program that converts a distance in Meters to the equivalent distance in Feet. The user should be able to enter a distance in Meters, click a button, and then see the equivalent distance in feet. Use the following formula to make the conversion:
Meters = Feet x 0.304
For example, 1 Meter is 3.28 Feet.
In: Computer Science
Write a C++ program that reads a string from a text file and determines if the string is a palindrome or not using stacks and queue
In: Computer Science
The systems requirements in a software project includes the categories of primary requirements, derived requirements, design constraints, and design goals. Briefly explain each category and how it is different from the other categories.
In: Computer Science
Suppose k is any natural number, k >= 0. Prove that the number of nodes in any binomial tree of height k is exactly 2^k.
In: Computer Science
Give a worst-case input sequence of 6 numbers for Insertion Sort, containing the numbers
68, 12, 43, 13, 58, and 21.
No explanation/proof required.
In: Computer Science
Explain the strengths and weaknesses of each of the following firewall deployment scenarios in defending servers, desktop machines, and laptops against network threats.
a. A firewall at the network perimeter.
b. Firewalls on every end-host machine.
c. A network perimeter firewall and firewalls on every end-host machine.
In: Computer Science
4.24 LAB*: Program: Drawing a half arrow
This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width.
(1) Modify the given program to use a loop to output an arrow base of height arrowBaseHeight. (1 pt)
(2) Modify the given program to use a loop to output an arrow base of width arrowBaseWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow base. (1 pt)
(3) Modify the given program to use a loop to output an arrow head of width arrowHeadWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow head. (2 pts)
(4) Modify the given program to only accept an arrow head width that is larger than the arrow base width. Use a loop to continue prompting the user for an arrow head width until the value is larger than the arrow base width. (1 pt)
while (arrowHeadWidth <= arrowBaseWidth) { // Prompt user for a valid arrow head value }
Example output for arrowBaseHeight = 5, arrowBaseWidth = 2, and arrowHeadWidth = 4:
Enter arrow base height: 5 Enter arrow base width: 2 Enter arrow head width: 4 ** ** ** ** ** **** *** ** *
In: Computer Science