computer-science

What is Big O Notation? [duplicate]

流过昼夜 提交于 2020-01-12 18:45:44
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: Plain English explanation of Big O I know Big O notation is used to assess how efficient an algorithm is, but I do not understand how you read Big O notation or what exactly how efficient an algorithm is. Can somebody perhaps explain the basics of Big O notation? Thanks. 回答1: What is a plain English explanation of "Big O" notation? is a good explanation of what Big-O notation is and how to use it. 回答2: This page

What is Big O Notation? [duplicate]

落爺英雄遲暮 提交于 2020-01-12 18:45:11
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: Plain English explanation of Big O I know Big O notation is used to assess how efficient an algorithm is, but I do not understand how you read Big O notation or what exactly how efficient an algorithm is. Can somebody perhaps explain the basics of Big O notation? Thanks. 回答1: What is a plain English explanation of "Big O" notation? is a good explanation of what Big-O notation is and how to use it. 回答2: This page

Creating a java program that given 3 terms as input(a,b,c) in that order prints their roots

女生的网名这么多〃 提交于 2020-01-07 23:59:12
问题 Wrie a method printRoots that given 3 terms as input(a,b,c) in that order prints their roots We have the following given information If b²-4ac is a positive number , your program should print “The two roots are X and Y” where X is the larger root and Y is the smaller root If b²-4ac * equals 0 * , the program should print. “The equation has one X” where X is the only root If b²-4ac is a negative number , the program should print.” The equation has two roots(-X1 + Y1i) and (-X2 and Y2i) The

Solving quadratic equation USING METHODS, java

你。 提交于 2020-01-07 07:37:08
问题 I have a java program written for solving the quadratic equation but the assignment requires me to have methods for each of the tasks: displaying the equation, determining if the equation has real solutions, calculating a solution, and displaying the solutions if they exist. I have methods for everything except for checking if the solutions are real except my methods are saying that they are undefined. Can someone please help me format my methods, I don't quite know how to implement them?

How does the computer recognise that a a given number is in its Two's comeplent form?

不羁岁月 提交于 2020-01-07 03:36:09
问题 I understand what the Two's complement is and what it is useful for. What I'd like to know is how does the computer decide that the number is in its Two's complement form? How and when does it decide that 1111 1110 is -2 and not 254? Is it at the OS level of processing? 回答1: The computer will already be expecting the data to be in (or not in) two's complement form (otherwise there wouldn't be a way of telling if it is - 2 or 254). And yes, that would probably be decided at the OS-level. You

Speed of C++ operators/ simple math

拜拜、爱过 提交于 2020-01-06 05:00:09
问题 I'm working on a physics engine and feel it would help having a better understanding of the speed and performance effects of performing many simple or complex math operations. A large part of a physics engine is weeding out the unnecessary computations, but at what point are the computations small enough that a comparative checks aren't necessary? eg: Testing if two line segments intersect. Should there be check on if they're near each other before just going straight into the simple math, or

When does type binding happen in Rust?

筅森魡賤 提交于 2020-01-05 07:50:11
问题 From what I know: In C language, the "type" of a variable is bound during compile time and the value of that variable is bound during run time. For example, in int a = 10; , the type int is bound to the variable a during compile time and the actual value 10 is bound (or assigned) to it during run time. But in Rust, we have let a = 2; . Here, when does the type (say i32 from any of the integer types in Rust) get bound to a ? I am building a front-end Rust compiler and am currently writing the

How do I make my squares generate behind each other rather than on top of eachother without using recursion?

天涯浪子 提交于 2020-01-05 03:59:07
问题 I've gotten some help in another one of my questions to get me this far but I'd like to know how to make my squares generate behind one another rather than on top of each other. The below code is what I've got so far. This is the code that places them behind each other recursively: import java.awt.image.*; import java.awt.Color; import java.io.*; import javax.imageio.*; import java.util.*; public class FractalDriver { static final int SIDE = 1000; // image is SIDE X SIDE static BufferedImage

How to rotate a section of a 1d array in C?

蹲街弑〆低调 提交于 2020-01-04 09:58:05
问题 I printed out a 6x6 1d array but want to rotate counter-clockwise the top left 3x3 section. Is there an algorithm for this? In the future I also want to rotate like the bottom right 3x3 section or the top right 3x3 section or the bottom left 3x3 section. a[0] a[1] a[2] a[3] a[4] a[5] a[1] a[2] a[8] a[3] a[4] a[5] a[6] a[7] a[8] a[9] a[10] a[11] a[0] a[7] a[14] a[9] a[10] a[11] a[12] a[13] a[14] a[15] a[16] a[17] ---> a[6] a[12] a[13] a[18] a[19] a[20] a[18] a[19] a[20] a[21] a[22] a[23] a[18]

How to rotate a section of a 1d array in C?

白昼怎懂夜的黑 提交于 2020-01-04 09:56:31
问题 I printed out a 6x6 1d array but want to rotate counter-clockwise the top left 3x3 section. Is there an algorithm for this? In the future I also want to rotate like the bottom right 3x3 section or the top right 3x3 section or the bottom left 3x3 section. a[0] a[1] a[2] a[3] a[4] a[5] a[1] a[2] a[8] a[3] a[4] a[5] a[6] a[7] a[8] a[9] a[10] a[11] a[0] a[7] a[14] a[9] a[10] a[11] a[12] a[13] a[14] a[15] a[16] a[17] ---> a[6] a[12] a[13] a[18] a[19] a[20] a[18] a[19] a[20] a[21] a[22] a[23] a[18]