1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kumpel [21]
2 years ago
6

Suppose for the worst case, given input size n: Algorithm 1 performs f(n) = n2 + n/2 steps Algorithm 2 performs f(n) = 12n + 500

steps What is the smallest value of n for which algorithm 2 will be faster than algorithm 1?
Computers and Technology
1 answer:
melomori [17]2 years ago
6 0

Answer:

29

Explanation:

for n=28:

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

Algorithm 1 performs f(n) = n2 + n/2 = 28*28 + 28/2 = 798

Algorithm 2 performs f(n) = 12*28 + 500 = 836

for n=29

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

Algorithm 1 performs f(n) = n2 + n/2 = 29*29 + 29/2 = 855.5

Algorithm 2 performs f(n) = 12*29 + 500 = 848

so, for n=29, algorithm 2 will be faster than algorithm 1

You might be interested in
. A Worker in Microworkers can also be an Employe
bija089 [108]

Answer:

A Worker in Microworkers can also be an Employer: After reaching $25 in earnings. After placing an initial deposit of $10, and launching a valid campaign. If success rate is maintained at 75% before launching a campaign. After creating a separate Employer account.

Explanation:

6 0
2 years ago
Write a class called Course that represents a course taken at a school. Represent each student using the modified Student class
Vinvika [58]

Answer:

The code is given below with its appropriate output

Explanation:

//Student.java

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

import java.util.Scanner;

public class Student {

public String firstName;

public String lastName;

public float[] marks;

Scanner scanner = new Scanner(System.in);

public Student(String firstName, String lastName) {

this.firstName = firstName;

this.lastName = lastName;

}

public void getdetail() {

System.out.println("enter only five marks");

marks = new float[5];

int count = 0;

for (int i = 0; i < 5; i++) {

float mark = 0;

++count;

if (count <= 5) {

System.out.println("enter score " + count);

mark = scanner.nextFloat();

if (mark >= 0.0 && mark <= 100.0)

marks[i] = mark;

else {

System.out.println("you entered mark is invalid");

marks[i] = 0;

}

} else

System.out.println(" maximum is five only");

}

}

public void tostring() {

System.out.println("firstname :" + "\t" + firstName + "\t" + "lastname :"

+ "\t" + lastName + "\n" + "the marks are");

int count = 0;

for (float mark : marks) {

count++;

System.out.println("the mark of " + count + " is " + mark);

}

}

public void Averagecal() {

float sum = 0.0f;

for (float mark : marks) {

sum = sum + mark;

}

float avg = sum / 5;

System.out.println("average of a student is " + avg);

}

}

//Course.java

import java.io.*;

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

import java.util.Scanner;

public class Course {

public String courseName;

public int number;

Student[] students;

Scanner scanner = new Scanner(System.in);

public Course(String courseName) {

this.courseName = courseName;

}

public void addStudents() {

System.out

.println("how many no of students you want to add for this particular course");

int count = scanner.nextInt();

students = new Student[count];

for (int i = 0; i < count; i++) {

System.out.println("enter the first name");

String fname = scanner.next();

System.out.println("enter the last name");

String lname = scanner.next();

Student s = new Student(fname, lname);

s.getdetail();

s.tostring();

s.Averagecal();

students[i] = s;

}

}

public void roll() {

int count = 0;

for (Student stud : students) {

count++;

}

System.out.println("the no of students in this " + courseName

+ " course is " + count);

}

}

//Driver.java

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

import java.util.Scanner;

public class Driver {

public static void main(String[] args) {

Course course = new Course("java");

course.addStudents();

course.roll();

}

}

<u>output: </u>

C:\Users\Daniel\Desktop\New folder>javac Student.java

C:\Users\Danie;\Desktop\New folder>javac Course.java

C:\Users\Daniel\Desktop\New folder>javac Driver.java

C:\Users\Daniel\Desktop\New folder>java Driver

how many no of students you want to add for this particular course ?

1

enter the first name

john

enter the last name

rich

enter only five marks

enter score 1

89

enter score 2

91

enter score 3

85

enter score 4

78

enter score 5

96

firstname : john lastname : rich

the marks are

the mark of 1 is 89.0

the mark of 2 is 91.0

the mark of 3 is 85.0

the mark of 4 is 78.0

the mark of 5 is 96.0

average of a student is 87.8

the no of students in this java course is 1

C:\Users\Ravi\Desktop\New folder>

3 0
3 years ago
Role of computers in everyday life​
Simora [160]

Answer:

In modern word everything around us like GPS, ATM machines, cell phones, petrol pumps, portable play stations and all other modern devices use computer controlling units to conduct their featured operations. Surely computers have very elaborated role in daily day life of humans.

Explanation:

hope it helps thxs

8 0
3 years ago
Anti-bullying laws in most states are designed to provide
Vera_Pavlovna [14]

Answer:

to protect children enrolled in kindergarten, elementary, and secondary schools and learning centers ( from being bullied. It requires Schools to adopt policies to address the existence of bullying in their respective institutions.

Explanation:Hope this helps pls mark brainliest!

6 0
2 years ago
The function below takes a string argument sentence. Complete the function to return the second word of the sentence. You can as
Soloha48 [4]

Answer:

Following are the program in the Python Programming Language.

# define function.

def return_second_word(sentence):

 #remove all the spaces from the sentence

 sentence=' '.join(sentence.split())

 #the list is split from spaces

 my_list = sentence.split(" ")

 #return the list

 return my_list[1]

#define main function

def main():

 #get input from the user

 se = input("Enter the sentence: ")

 #print and call the function

 print(return_second_word(se))

#condition to execute the main function

if __name__ == "__main__":

 #call main function

 main()

<u>Output:</u>

Enter the sentence: I love python

love

Explanation:

Here, we define the function i.e., "return_second_word()" and pass an argument "sentence", inside the function.

  • Remove all the spaces from the variable "sentence" and again store in the variable "sentence".
  • Set the variable "my_list" that store the split value of the variable "sentence".
  • Return the list and close the function.

Finally, we define the main function and inside the main function.

  • Get input from the user in the variable "se"
  • And pass the variable "se" in the argument list during the calling of the function "return_second_word()".
  • Then, print and call the function "return_second_word()".
  • Set the if statement to call the main function then, call the main function.
4 0
3 years ago
Other questions:
  • Complete the following method named replaceEvens that receives the parameter numbers which is an array of integers. The method m
    5·1 answer
  • Hard drives have the largest capacity of any storage device. <br> a. True <br> b. False
    6·2 answers
  • Rank these three account types in order of decreasing liquidity. Start by picking the most liquid account type first
    13·2 answers
  • 3. Assume a disk drive from the late 1990s is configured as follows. The total storage is approximately 675MB divided among 15 s
    11·1 answer
  • Traditional methods of business communication tend to mean paper-based messages such as formal letters, brochures, reports, prop
    10·1 answer
  • A laptop computer communicates with a router wirelessly, by means of radio signals. the router is connected by cable directly to
    10·1 answer
  • Which line in the following program will cause a compiler error? 1 #include 2 using namespace std; 3 int main() 4 { 5 int number
    12·1 answer
  • What would happen without satellites???
    12·2 answers
  • A*=++a/6+b++ 3 if a=3,b=4​
    13·1 answer
  • Mathematics and computer science share many concepts, such as recursion.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!