Questions
1. State and explain the definition of big-O. 2. Explain why we use big-O to compare...

1. State and explain the definition of big-O.
2. Explain why we use big-O to compare algorithms.
3. Explain why binary search runs in O(log n) time.
4. Under what conditions is it possible to sort a list in less than O(nlog n) time?
5. List and explain the worst-case and average-case running times for each Vector method below:
(a) insert(iterator here, Object item)

(b) insertAtHead

(c) insertAtTail (aka push back)

(d) get(iterator here)

(e) get(index i)

(f) remove(iterator here)

(g) remove(index i)

(h) splice(iterator place here, iterator from here, iterator to here)
(Be sure you understand when (and why) push back runs in constant average time.)

In: Computer Science

Define a function average_entries_for(integer) that takes in an integer than represents the number of times the...

Define a function average_entries_for(integer) that takes in an integer than represents the number of times the function will ask the user to input a number. The function will return the average of all the numbers entered. You must use a for loop to implement this function. (Hint: use range)

In: Computer Science

Assignment 8 – UML Diagram - Students Class Revised 9/2019 Throughout Chapters 9 & 10, there...

Assignment 8 – UML Diagram - Students Class Revised 9/2019

Throughout Chapters 9 & 10, there are UML class diagrams (Unified Modeling Language) which represent the data fields and methods in a class. From any class given to you, you should be able to design the UML diagram. Likewise, if given a UML, you should be able to define & implement the class.

Please do this in Java please, add comments so it's easy to understand and read so I know how to be able to do it myself.

For the assignment this week, you are given the UML diagram for a class named Students. You will define the Students class and then implement it with a driver program called StudentsDriver.

The StudentsDriver class with the main method should:

• Create an object of the Students class using the no-arg constructor

• get user input for student objects (see sample output below): first name, last name, student id, and birth year and then populate the object using setters (do not use constructors)

• create & initialize 2 objects of the Students class using the overloaded constructor as follows

o first name = Lisa Ann; last name = Larraby; student id = 54321; birth year = 1993 o first name = Karl; last name = Van der Hutten; student id = 54123; birth year = 1983

• call the class toString to display the output for each object as noted in sample output

Validation should be created in the Students class (not driver program):

• Range for student id is 54000 through 54999, inclusive

• Range for student age is from 13 years old to 100 years old, inclusive

• HINTS: in setters for studentID & for birthYear, move the assignment to the appropriate validation method. Then, in each setter, call the appropriate validation method.

*Note: for those already familiar with Java programming, please keep this simple: try/catch, exceptions, GUI, etc. Please use only the concepts discussed up to this point.

Before starting this lab, be sure to refer to the “How to Submit Assignments” document in eLearn for proper documentation, indention, naming conventions, etc. Points may be deducted if submitted incorrectly.

REMINDER: Any sources you use besides the textbook, class demo files, or the instructor must be documented in your program with details such as the scope of help received & URL.

Required project name: LastnameFirstname08 Required package name: chap10 Required class names: as noted above

Sample output. You’re encouraged to use valid, invalid, & boundary test cases. User input in green text:

Enter First Name: Juan Mateo Enter Last Name: Lopez

Enter Student ID: 53500 ID range is 54000 to 54999. Please try again: 53600 ID range is 54000 to 54999. Please try again: 53700 ID range is 54000 to 54999. Please try again: 55000 ID range is 54000 to 54999. Please try again: 56000 ID range is 54000 to 54999. Please try again: 54000

Enter 4-Digit Year of Birth: 1900 Range is 1919 to 2006. Please try again: 1910 Range is 1919 to 2006. Please try again: 1915 Range is 1919 to 2006. Please try again: 2010 Range is 1919 to 2006. Please try again: 2015 Range is 1919 to 2006. Please try again: 1960

Juan Mateo Lopez

Student ID: 54000 Age in 2019: 59 years old

Lisa Ann Larraby

Student ID: 54321 Age in 2019: 26 years old

Karl Van der Hutten Student ID: 54123 Age in 2019: 36 years old

Students

- firstName: String - lastName: String - studentID: int - birthYear: int - CURRENT_YEAR: int - YOUNGEST_AGE:int - OLDEST_AGE:int - LOW_ID:int - HIGH_ID:int

+ Students() + Students(first: String, last: String, studentID: int, birthYear: int)

+ getFirstName(): String + setFirstName (firstName: String): void + getLastName(): String + setLastName (lastName: String): void + getStudentID(): int + setStudentID (studentID: int): void + getBirthYear(): int + setBirthYear(birthYear: int): void + getCurrentYear(): int + getYoungestAge(): int + getOldestAge(): int + getLowId(): int + getHighId(): int

+ validateID(int id): int + validateYr(int yr): int + calcAge(): int + toString(): String <>

You will be graded according to the following rubric (each item is worth one point):

• The Students class is defined exactly & completely as indicated in the UML class diagram.

• Values for constants are used only in initialization and are not hard coded in the methods of the Students class.

• One object is initialized with user input using the Students class setters.

• Two objects are initialized using the Students class overloaded constructor.

• Validation is executed in 2 methods in the Students class.

• In all methods of the Students class, there are no hard coded values.

• Your program compiles & runs.

• You follow standard coding conventions (e.g. variable names, indentation, comments, etc.).

• File name, global comment, citations, etc. as indicated on How to Submit Assignments (Course Overview).

• Your Eclipse project was exported correctly (see Hello World Video Tutorial in Topic 1 Learning Activities).

In: Computer Science

What are some of the learning's and/or takeaways from studying "Networking Essentials and Security"? Why do...

What are some of the learning's and/or takeaways from studying "Networking Essentials and Security"? Why do you think this subject is important from an Executive MBA perspective? Give examples if any as necessary.

In: Computer Science

Database notation is not consistent; there are hundreds of types of database models. Each model or...

Database notation is not consistent; there are hundreds of types of database models. Each model or notation is good at selective situations. Visio uses notation and graphical shapes that are not the same as those in your text. If you look at some of the links to schemas, you will see a similar sort of thing. Research the web for data models and data notation and similar phrases. Provide your answer to the following questions:

1.Name some of the notations/models you find In your own words,

2.discuss why do these differences in modeling exist

3.What, if any, solution you would recommend.

In: Computer Science

Write a program in C which randomly generates two integers X and Y between 10 and...

Write a program in C which randomly generates two integers X and Y between 10 and 50, and then creates a dynamic array which can hold as many numbers as there are between those two random numbers. Fill the array with numbers between X and Y and print it on screen. Do not forget to free the allocated memory locations whenever they are no longer needed.

Example:

Randomly generated numbers are: 43 23

Expected Output :

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

In: Computer Science

I want to know the details interpretation of this code for my interview preperation on this...

I want to know the details interpretation of this code for my interview preperation on this code. This is A* algorithm in c++

#include<bits/stdc++.h>
using namespace std;
#define DISCONNECTED -1
int num_of_node,num_of_edge,graph[30][30],pathCost[30];
void init_Heuristic();

struct Node{
    int from,to;
    int cost;
};
struct CompareNode{
    bool operator()(Node& n1, Node& n2){
        if(n1.cost > n2.cost)return true;
        return false;
    }
};
map<int,int>Heuristic;
priority_queue<Node, vector<Node>, CompareNode> PQ;
vector<Node>path;
void AStarSearch(int source,int destination){

    init_Heuristic();
    for(int i = 1; i <= num_of_node; i++){
        if(graph[source][i] != DISCONNECTED){
            Node n;
            n.from = source;
            n.to = i;
            n.cost = graph[source][i] + Heuristic[i];
            pathCost[i] = graph[source][i];
            PQ.push(n);
        }
    }
    while(!PQ.empty()){
        Node tmp = PQ.top();
        path.push_back(tmp);
        if(tmp.to == destination)break;
        PQ.pop();
        for(int i = 1; i <= num_of_node; i++){
            if(graph[tmp.to][i] != DISCONNECTED){
                Node n;
                n.from = tmp.to;
                n.to = i;
                n.cost = pathCost[tmp.to] + graph[tmp.to][i] + Heuristic[i];
                pathCost[i] = pathCost[tmp.to] + graph[tmp.to][i];
                PQ.push(n);
            }
        }
    }
}
int main(){

    int a,b,c,source,destination;

    cout << "Enter Node: " << endl;
    cin >> num_of_node;
    cout << "Enter Edge: " << endl;
    cin >> num_of_edge;
    for(int i=1; i<=num_of_node; i++)
for(int j=1; j<=num_of_node; j++)
   graph[i][j] = DISCONNECTED;

    for(int i = 0; i < num_of_edge; i++){
        cin >> a >> b >> c;
        graph[a][b] = c;
    }
    cout << "Enter source: " << endl;
    cin >> source;
    cout << "Enter destination: " << endl;
    cin >> destination;
    AStarSearch(source,destination);
    for(int i = 0; i < path.size(); i++)
        cout << path.at(i).from << " -> " << path.at(i).to << " = " << path.at(i).cost << endl;
    return 0;
}
void init_Heuristic(){

    ///straight line distance ///

    Heuristic[1] = 10;
    Heuristic[2] = 5;
    Heuristic[3] = 0;
    Heuristic[4] = 13;

}

In: Computer Science

In what ways are user-level threads better/more efficient than kernel-level threads? In what ways are they...

In what ways are user-level threads better/more efficient than kernel-level threads?

  • In what ways are they less efficient?

In: Computer Science

write these programs in c++ using getch() function Write a program that reads 20 integers from...

write these programs in c++ using getch() function

Write a program that reads 20 integers from a user using a while loop and determines and prints whether each of those integers is an even number.

Write a program that uses a while statement to read integers from a user and prints the sum, average, and largest of these numbers. The input should terminate if the user enters -1.

In: Computer Science

In Java, a set of integers is given. write a function to find 2 integers in...

In Java, a set of integers is given. write a function to find 2 integers in this set that sums upto a target value.

i.e [1,5,2,0,11,3] target = 7

result [5,2]

i.e [1,5,4,0,14,-7] target = 9

result [5,4]

NOTE: THE SAME INTEGER CANNOT BE USED TWICE !!!

In: Computer Science

IN C++: Create sets of 1 Million integers with the following characteristics; Sets where no numbers...

IN C++:

Create sets of 1 Million integers with the following characteristics;
Sets where no numbers repeat
Sets where the range of numbers is 1% of the array size
Sets where no numbers repeat and each integer has 20 digits

In: Computer Science

consider the victoria university information technology department, department has setup a small library for NIT5130 students....

consider the victoria university information technology department, department has setup a small library for NIT5130 students. The department library maintains a checkout list ( CALL NO, USER ID, DATE REQUESTED) of all the books borrowed by students, Every student record consists of User ID, User name, Borrow limit, Number checked out, and fines. Suppose that the library will have multiple copies (CALL NO, AUTHOR NAME, PUBLISHER, ISBN, DATE PUBLISHED) can have multiple authors (AUTHOR NAME, DATE OF BIRTH, COUNTRY OF BIRTH, DECEASE BIRTH). You have volunteered to set up a database system for the library,

Draw an Entity relationship diagram for the IT department library

In: Computer Science

How can I return in a list all possible paths from a grid if I can...

How can I return in a list all possible paths from a grid if I can only go right and down?

For example consider the following table:

A B C

D E F

If I go right I need to insert in my list 'H' if I go down I need to insert in my list 'V'.

For example the path A - > B -> C -> F would be H - H - V

The path A -> D -> E -> F would be V - H - H

How would be the code for that? Please preference write in JAVA.

Thank you,

In: Computer Science

Please solve this problem, in c++ (algoritms) write code and explaination how to solve it! 1)...

Please solve this problem, in c++ (algoritms) write code and explaination how to solve it!

1) N numbers are given. The first K of them are sorted in ascending order, the remaining NK are also sorted in ascending order. Sort numbers in ascending order in O (N).

Input data format N - number of numbers, K - number of numbers in the first half (sorted).

Example input

10 6

1 2 5 6 8 9 3 4 7 12

Sample Output

1 2 3 4 5 6 7 8 9 12

In: Computer Science

6.5 The time taken by machines A, B, and C to execute a given task is...

6.5 The time taken by machines A, B, and C to execute a given task is

A 16m, 9s

B 14m, 12s

C 12m, 47s

What is the performance of each of these machines relative to machine A?

6.6 Why is clock rate a poor metric of computer performance? What are the relative strengths and weaknesses of clock speed as a performance metric?

6.7 What are the relative strengths and weaknesses of the MIPS as a metric of computer performance?

In: Computer Science