Java efficiency question?
101512
It has to create a string, convert the integer to string & concatenate. It has 2 extra statements.
824959
Direct from the creators of the Java.The Java Programming Language is an indispensible resource for novice and advanced programmers alike. \n\nDevelopers around the world have used previous editions to quickly gain deep understanding of the Java programming language, its design goals, and how to use it most effectively in real-world development. Now, Ken Arnold, James Gosling, and David Holmes have updated this classic to reflect the major enhancements in JavaTM 2 Standard Edition 5.0 (J2SETM 5.0). \n\nThe authors systematically conver most classes in Java's main packages, java.lang.*, java.util, and java.io, presenting in-depth explanations of why these classes work as they do, with informative examples. Several new chapters and major sections have been added, and every chapter has been updated to reflect today's best practices for building robust, efficient, and maintainable Java software. \n______________________________________\n      Key changes in this edition include \n       ----------------------------------------\nNew chapters on generics, enums, and annotations, the most powerful new language features introduced in J2SE 5.0 \nChanges to classes and methods throughout to reflect the addition of generics \nMajor new sections on assertions and regular expressions \nCoverage of all the new language features, from autoboxing and variable argument methods to the enhanced for-loop and covariant return types \nCoverage of key new classes, such as Formatter and Scanner \nThe JavaTM Programming Language, Fourth Edition, is the definitive tutorial introduction to the Java language and essential libraries and an indispensible reference for all programmers, including those with extensive experience. It brings together insights you can only get from the creators of Java: insights that will help you write software of exceptional quality. \n------------------------------------------------------------\nDirect from the creators of the JavaTM programming language, this Third Edition of The JavaTM Programming Language is a valuable resource for both novice and advanced programmers. More than 100,000 developers who programmed with C, C++, Smalltalk, or other high-level languages have used this book to get a concise, intelligent, and deep understanding of the Java programming language. \n\nThis book is what you need to understand the basic design goals of the language and the application of the language in real-world development. It provides unique insights into why and how the language was designed and intended to be used. \n\nThe authors describe the latest version of the language, as defined by The JavaTM Language Specification, Second Edition and implemented in version 1.3 of the Java 2 SDK, Standard Edition. This third edition has been structured to give more in-depth treatment of the newer language features as well as informative examples on using some of the new APIs. \n\n         New and/or revised in this edition: \n         ----------------------------------------\n- more details on language features, including an expanded section on nested classes\n- more comprehensive treatment of garbage collection and related programming issues\n- coverage of new APIs, such as collections and internationalization\n\nThoroughly revised from start to finish, this edition fully covers the features of the current release of the Java programming language and class libraries. The book serves as a tutorial introduction to the language and essential libraries as well as a reference. \n\nExperienced programmers will find this new edition to be a valuable reference and will gain new insights into the subtleties of the language. Novice and intermediate programmers will benefit from the valuable examples and clear explanations of language and library features. Make sure you understand the contents of this book before you begin any serious development for the Java platform. \n\nKen Arnold, a Staff Engineer at Sun Microsystems Laboratories, is a
798447
as much as in .net or mainframe.
445796
Java can be faster than C++. \n\nA JIT (Just in time) compiler must be used.  The reason Java programs start slowly is because they start out being interpreted (the bytecode to machine code) but at the same time the speed is being profiled (tested for bottlenecks and places to perform optimizations), the JIT compiler will use the bytecode and the information from the profiling process and generate machine code (run on the hardware) which results in very fast execution times...  THe price you pay is startup speed...\n\nAll of that being said: if a major goal of a program you are writing is speed then you should use C++ because then you, the programmer, have more direct control of how fast your program will run.
919233
Yes, when a list is already sorted, bubblesort will pass through the list once, and find that it does not need to swap any elements. \n\nIt will also use considerably less time if the elements in the list are not too far from their sorted places.
2509
Here's a java solution that uses recursion.  The permute function takes two arguments: a done portion and a todo portion.   The basic idea is that each of the characters in the todo portion could be the next character.  So, at each step, n recursive calls are made, where n is the length of todo.  Each call chooses a different character as the next character to go into the done portion.  So, the first time the number of recursive calls will equal the number of characters in the initial string.  Each of these calls will make further recursive calls equal to the number of characters in the initial string minus one.  And so on.  Thus, the number of solutions will be n! = n*n-1*n-2*...*1, where n is the number of characters in the initial string.\n\nThe program below was tested with java's sun compiler 1.4.2.\npublic class perm\n{\n  public perm(String S)\n  {     \n    permute("", S);\n  }     \n  public void permute(String done, String todo) \n  {     \n    if ((todo.length()==0)||\n        (todo.equals("")))\n      System.out.println(done);\n    else        \n    {           \n      for (int i=0; i<todo.length(); i++)\n      {                 \n        String c = todo.substring(0,1);\n        todo = todo.substring(1);\n        permute(done+c, todo);  \n        todo = todo + c;        \n      }                 \n    }           \n  }     \n  public static void main(String args[])\n  {     \n    if ((args.length==0)||\n        (args[0].length()==0)||\n        (args[0].equals("")))\n      return;           \n    perm p = new perm(args[0]);\n  }     \n}
116814
No, it doesn't improve the method's performance but only substracts a hidden argument from the list. \n'static' is a semantic construct, by which you mean that a certain method belongs to the class, or it doesn't need internal data to deal with.\n\nOn the other side, if you care about 'calling' performance (again, not the performance of the method itself) then consider not using virtual methods unless really necessary. That should decrease calling overhead (virtual calls go through a vtable) a tiny little bit, which makes sense for functions that are called inside loops or the like.
1033944
Efficiency=Poutput/Psupplied\nEfficiency=3760/4000=0.94\nEfficiency(%)=94%\nThe answer is B
903318
Both have almost the same effect.\n\nbut it mostly depends on how efficient val.getName() works.\nbut if you using the same method to fetch the value and use it as a parameter,the first one would be better it will at least save a couple of object creations.
157926
Choose the most repeated operation and determine of what its repeat is dependent on (amount of input data).\n\nFor example: for (int i=0; i<N; i++) { /* do something */ )\nHas complexety N because /* do something */ is repeated N times. Here N is supplied to the algorightm.\n\nFor example: Two nested loops on of N and another of M operations have complexity of N*M.\n\nYou can ignore constant additions and substractions if they dont depend on the amount of the input data (as the are constant).\n\nFor example if you initialize an array of 100 elements in the begining of the algorithem, you can ignore it instead of include it as 100+N for example :)
393251
I'd dump it into a compiler and do it for you but you left too much out.  Impossible to return a syntax error free version without the whole program.\n\nAnyways, I get paid for this.  How many points is this worth?  ...to do someone's homework for him?  Or maybe he's doing contract work!  He's getting $70 and hour to let us do it for him!
418804
I'm a bit rusty with BASIC but both of them look ok (assuming the syntax is good).\n\nThe second one is more efficient because of the FOR loop.\n\nIf you always need to calculate the average for 6 students then you don't need to prompt for the number of students, although it does make the program more useful.
506746
BEST ONE!!!!!!!!!!!!!!!!!!!!!!!!!\nBEST ONE!!!!!!!!!!!!!!!!!!!!!!!!!\n\nJUST GIVE 24 HOURS 2 LEARN JAVA
673244
Function overloading doesn't affect a programs execution speed in any way because the overloads are resolved at compile time which is virtually free.\nIt makes your program more understandable. Take an example.\nYou want to convert an integer into its equivalent ascii representation. There are many integral types in every major language (C++, Java, C#, VB.Net). Tell me what would you like to have:\nchar* itoa(int);\nchar* ltoa(long);\nchar* stoa(short);\nchar* lltoa(long long);\n\nor the simplified versions:\n\nchar* itoa(int);\nchar* itoa(long);\nchar* itoa(short);\nchar* itoa(long long);\n\n?
645329
If you want the differences in detail go to http://java.sun.com Its the JAVA information superhighway.
440005
Pseudocode, I'm not up on my Java syntax:\n\nint sum=0;\nfor(int i=0;i<array.size;i++)\n  sum+=array[i];
304489
instead of wasting my fingers typing the answers - all the info you may need is listed here\nhttp://java.ittoolbox.com/topics/t.asp?t=366&p=366&h1=366