What Is Big O Notation In Java
Mar 6, 2015
What is Big O notation in java, what all things we need to remember before choosing a collection framework's class.
What each terms in big O notation means, Is there any blog or site that explain big O for java.
View Replies
ADVERTISEMENT
Apr 14, 2014
I've to create a program to get user input in scientific notation. Now i'm confused that how can i check that how user have used the scientific notation. For example there are many ways to write a number in scientific notation. Also a user can either write a number as:
6.7E2 OR 6.7*10^2
How to handle this input and further convert it to double?
View Replies
View Related
Apr 12, 2014
Compute the total number of operations for each of the following algorithm and define the value of Big Oh in its worst-case.
i.int jum = 0;
for (int x = 1; x<= n; x++) {
for (int y = 1 ; y <= 10; y++) {
for (int k = 0; k<= n*n; k++) {
jum = jum * x + y;
[Code] .....
What it actually means by compute the total number of operation ? My answer is
(i) 2 assignment , 1 addition and 1 multiplication
(ii) 4 assignment , 1 multiplication , 2 addition
The value of Big O is
(i) 10n^3 , so the answer is n^3
(ii) n^4+1 , so the answer is n^4
May i know is my answer is correct ??
View Replies
View Related
Nov 5, 2014
I've been trying to learn more about Big O Notation and I've gotten stuck on a few pieces of code. What is the computational complexity for the following pieces of code?
1:
for(int i = n; i > 0; i /= 2) {
for(int j = 1; j < n; j *= 2) {
for(int k = 0; k < n; k += 2) {
// constant number of operations
[Code] .....
5 : Determine the average processing time of the recursive algorithm. (int n) spends one time unit to return a random integer value uniformly distributed in the range [0,n] whereas all other instructions spend a negligibly small time(e.g., T(0) = 0)
int myTest(int n) {
if(n <= 0) return 0;
else {
int i = random(n - 1);
return myTest(i) + myTest(n - 1 - i);
6 : Assume array a contains n values, the method randomValue takes a constant number c of computational steps to produce each output value, and that the method goodSort takes n log n computational steps to sort the array.
for(i = 0; i < n; i++) {
for(j = 0; j < n; j++)
a[j] = randomValue(i);
goodSort(a);
}
View Replies
View Related
Aug 12, 2014
So recently I began Data Structures as core subject and the tutorials in this forum are great.
Right now, I seem to have trouble with Big Oh Notation algorithm and what is the mathematical side to it. "f(n) <= c.g(n), for n>=0.
The question I am working on is: Suppose we are maintaining a collection C of elements such that, each time we add a new element to the collection, we copy the contents of C into a new array list of just the right size. What is the running time of adding n elements to an initially empty collection C in this case?
View Replies
View Related
May 20, 2014
I'm having trouble figuring out the Big-O notation for this loop. For now I only have it in pseudocode. I hope you understand it anyway
for i = 1 to n do
j = 1
while j <= n/2 do
print "*"
j = j + 1
end while
end for
View Replies
View Related
May 23, 2015
Java Code:
public class MountainBike extends Bicycle {
// the MountainBike subclass has
// one field
public int seatHeight;
// the MountainBike subclass has
// one constructor
public MountainBike(int startHeight, int startCadence,
[Code] ....
At first,
Java Code: public int seatHeight; mh_sh_highlight_all('java');
tells us that seatHeight is NOT a static field (because of the absence of static keyword).
Whereas in the constructor, the absence of dot notation (like something like this.seatHeight) in
Java Code: seatHeight = newValue; mh_sh_highlight_all('java');
shows that it IS a non-member/static variable.
How does this make sense?
View Replies
View Related
Oct 24, 2014
My question is to evaluate a Postfix notation entered from keyboard. I have no errors in my code but it prints only :
Exception in thread "main"
java.util.NoSuchElementException
at ArrayStack.pop(PostFixEvaluation.java:72)
at PostFixEvaluation.evaluatePostfix(PostFixEvaluatio n.java:107)
at PostFixEvaluation.main(PostFixEvaluation.java:140)
I tried many values but it prints the same exception all the time.
Here is my code:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.NoSuchElementException;
interface Stack<E> {
[Code] ....
View Replies
View Related
Apr 7, 2014
So I am supposed to be changing infix notation to postfix notation using stacks. This is simply taking a string "3 + 5 * 6" (infix) and turning it into (3 5 6 * +" (postfix).
To do this, we are to scan the string from left to right and when we encounter a number, we just add it to the final string, but when we encounter an operand, we throw it on the stack. Then if the next operand has a higher input precedence than the stack precedence of the operator on the top of the stack, we add that operator to the stack too, otherwise we pop from the stack THEN add the new operator.
I am supposed to be utilizing a hash map but I don't see how you would go about doing this. We are supposed to store operators on the hash map but operators need their own character, input precedence, stack precedence, and rank. How do you use a hash map when you need to tie a character to 3 values instead of just 1? I just don't get it.
The following is our Operator class that we are to use. Another problem is this isn't really supposed to be modified, yet we were given two important variables (inputPrecedence and outputPrecedence) that we can't have nothing to be initialized to and no way of accessing? So that might be where a hash map comes in but I am not sure. I am not very sure on how they exactly work anyway...
public class Operator implements Comparable<Operator>
{
public char operator; // operator
privateint inputPrecedence; // input precedence of operator in the range [0, 5]
privateint stackPrecedence; // stack precedence of operator in the range [-1, 3]
[Code] ....
So my question mostly revolves around how I tie an Operator character to its required values, so I can use it in my code to test two operators precedence values.
My original thought was turn string into character array, but then I would need nested for/while loops to check if it is a number or letter, or if it is an operator and thus result in O(n^2) time
View Replies
View Related
Sep 12, 2014
I have tried running the java application without adding the site to site list in java security tab. But I get a sand box message as APPLICATION BLOCKED BY SECURITY SETTINGS. How to run the java application without adding the site to site list in java security tab.
View Replies
View Related
Oct 24, 2014
I want to develop a Java program that uses OpenScript APIs to test my applications. The OpenScript framework automatically creates the Java Code so I was thinking of either using this code or create my own using the APIs.
I tried both options using NetBeans but I'm getting errors everywhere starting with the library import. I'm pretty new to Java so I'm sure I'm missing a lot of things here. I pasted the code below from the OpenScript framework that want to use in a stand-alone file for your reference.,
import oracle.oats.scripting.modules.basic.api.*;
import oracle.oats.scripting.modules.browser.api.*;
import oracle.oats.scripting.modules.functionalTest.api.*;
import oracle.oats.scripting.modules.utilities.api.*;
import oracle.oats.scripting.modules.utilities.api.sql.*;
[Code] ....
View Replies
View Related
Apr 9, 2015
I've written a java application with several classes all in the same .java file. It works just fine. Now, I've broken it up so that each class has its own .java file. Still works fine. My next step is to put those classes into a package, but I'm not about to get the program to run.The .java source files are all in /home/user/src
I've set the CLASSPATH to /home/user/src..All of the source files have "package com.myfirm.program" on the first line.I compiled the application with:
javac -d . File1.java File2.java File3.java (etc...)
the compiler created the directory: /home/user/src/com/myfirm/program and put all of the .class files in there.So how do I get the program to run? if I run from /home/usr/src
java File1
I get: Exception in thread "main" java.lang.NoClassDefFoundError: File1 (wrong name: com/myfirm/program/Program)
View Replies
View Related
Apr 14, 2015
I create 2 files:
CircleCalculationMethod.javaMain.java
In Main.java, How can i call method in CircleCalculationMethod.java ?
Should I put everything in same folder ??Should i do something like "import CircleCalculationMethod.java"Should i do something like create a package ...
I use Eclipse software
View Replies
View Related
Sep 19, 2014
The title of Question might seem old and previously asked.But I have a Question that what is difference between javaSE and Java EE.Although I knew what comes under JavaSE and What is under JavaEE.But My question is that.
What happens when we add PATH in our Environment Variable How does Eclipse or Other IDE use it?
Second Question is.
For Java SE we declare a Path Variable but for Java EE we do not add any library?(I know we add some jar file like for Servlet(Servlet-api.jar) and for EJB(Ejb.jar),But What is actaul difference?
View Replies
View Related
Oct 23, 2014
creating a program that will output something like this:
Enter an Integer: 1405302(user inputted)
Your integer contains 2 even digit(s), 3 odd digit(s), and 2 zero(s).
View Replies
View Related
Dec 4, 2014
I know about coding in general, Java, C, Python, SQL etc. but I barely know anything about making code come together on the web. I have a vague idea about what things like libraries and frameworks are,I'm interested in making a web application with which relies on Java do to the data processing. The idea is that the user inputs some messages, clicks submit, the text is taken away and processed, and the results are displayed on the screen. I would like the UI to be smooth with a modern look and feel.
Also, I usually do programming on Windows but I could also use Linux, so if I'll come across any specific drawbacks using Windows.
View Replies
View Related
Jan 9, 2015
How do I specify the Working directory where the Java app is located? It may be different on different machines.
View Replies
View Related
Apr 8, 2015
what is seriazable.But I am not able to come that why it is used and when should I declare my class(Object) as serialzable and when not?
View Replies
View Related
Aug 9, 2014
i need to develop a API in java. that API will be communicate with the some site. Need to import and export the contacts into that site databases.
View Replies
View Related
Oct 30, 2014
When I try to convert this value, "Testingu2120" (along with UTF coed u2120)comes as a string as part of SOAP response. I need to convert this UTF-8 characters in to a symbol, in this case it is SM (Service Mark) symbol and show it on the UI.
How can we achieve this in JAVA?
I have four different UTF-8 character set to convert.
TM - u2122
SM -u2120
R - u00AE
C - u00A9
View Replies
View Related
Sep 17, 2014
I would like my application to execute a command in cmd. The command looks like
start "" /D "C:Riot GamesLeague of LegendsRADSsolutionslol_game_client_sln
elease s .0.1.55deploy"
"League of Legends.exe" "8394" "LoLLauncher.exe" ""
"spectator 95.172.65.26:8088 P3hNrXYZlaM3iJ9ximtzJWHbwLhvbimJ 953089676 EUN1"
So my question is how do I do this?
I tried this, (just copy paste the command):
package MyProject;
import java.io.IOException;
import java.io.InputStream;
public class Cmd {
public static void main(String[] args) {
try {
final Process process = Runtime.getRuntime().exec("start "" /D "C:Riot GamesLeague of
[code]....
View Replies
View Related
Mar 22, 2015
We started learning about tables and have a little program. The teacher gave us an excercise and doesn't works (not running), I receive too many errors. So any simple java program with tables with 20 numbers, that is giving random numbers?
View Replies
View Related
Feb 4, 2014
Write a function (or functions) that given a collection of files will produce a sum of integers from each line of each file. Each file can have any number of lines from 1 to N. Each line can contain only one integer and no other alphanumeric characters. All of the numbers from all of the files should be added to the final result. The result is just one number.
For either, what we are looking for is:
1. Clear separation of concerns
2. Well defined objects / interfaces
3. Application of good OO design principles to solve the problem
4. No code duplication
5. Test Driven Development
6. Well refactored code
7. Well tested code
View Replies
View Related
Nov 13, 2014
I have to create a new project in which i have to take the inputs from the user and create the XML schema out of this. How can I do this the best way .
View Replies
View Related
Aug 12, 2014
I am trying to run a Powershell command from Java that creates an Active Directory group. I don't get any errors, but it doesn't work either. I can take the output from this class and plug it into the CMD prompt and it works fine.
Java Code:
public class CreateAD {
public int creategroup(String groupname, String description){
String runadcreate;
int errorfree =0;
runadcreate = "powershell Import-Module ActiveDirectory
[code]...
View Replies
View Related
Dec 22, 2014
I'm converting from ASP to Java for a legacy site. I believe the first part of the if statement is right but I'm having an issue within the else staetment. I'm getting date is undefined, I've tried using getYear and getDate but have not been successful.
ASP:
If Request("action") = "results" Then
aMonth = Request("selMonth")
aDate = cint(Request("selDate"))
aYear = cint(Request("selYear"))
Else
aMonth = UCase(MonthName(Month(Date()),true))
aDate = Day(DateAdd("d",-1,date()))
aYear = Year(Date())
End If
[code]....
View Replies
View Related