| | |
Time of a java method
Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
![]() |
•
•
Join Date: Mar 2006
Posts: 3
Reputation:
Solved Threads: 0
try {
for (int j=0; j < length; j++) {
int indx = s.indexOf(text.charAt(j));
if (indx >= 27 && indx <= 36) {
code += ((indx + key)%26);
}
else {
code += s.charAt((indx + key)%36);
}
}
} It is O(length), but what is the variable s? Is it a string of fixed size? Is it a variable length string? If so, then generally, your running time is O(length * s.length()), because the indexOf method should take O(s.length()) time in the average and worst case. Holding s.length() fixed, your running time is O(length).
All my posts may be redistributed under the GNU Free Documentation License.
•
•
Join Date: Mar 2006
Posts: 3
Reputation:
Solved Threads: 0
S = a string of 36 letters and numbers.
Thanks for the replies.
So s is fixed so the running time in O(length)?! What does that actually mean, is that a good running time? Im guessing here, but is that this big O theory? Sorry for being stupid, but my course don't cover this and the info about it on the net is very confusing!
Thanks for the replies.
So s is fixed so the running time in O(length)?! What does that actually mean, is that a good running time? Im guessing here, but is that this big O theory? Sorry for being stupid, but my course don't cover this and the info about it on the net is very confusing!
http://www.eternallyconfuzzled.com/articles/bigo.html
I usually don't plug my own stuff out of principle, but any other explanations I've found have been overly mathematical and confusing even to me. And I like to think that I have an above average understanding of these things. :rolleyes:
I usually don't plug my own stuff out of principle, but any other explanations I've found have been overly mathematical and confusing even to me. And I like to think that I have an above average understanding of these things. :rolleyes:
New members chased away this month: 4
![]() |
Similar Threads
- How to call Client.java from HTML? (Java)
- how to capture the system idle time using java (Java)
- Question about read method of InputStream (Java)
- Who can help a student with her exams in Java?? (Java)
Other Threads in the Computer Science Forum
- Previous Thread: Modular Arithmetic
- Next Thread: Raw PC development project - help needed
Views: 2427 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for Computer Science
ai algorithm algorithms amazon assignment assignmenthelp assignments battery bigbrother binary bittorrent bletchleypark blogging bomb business clueless codebreaker compiler computer computers computerscience computertrackingsoftware conversion csc data dataanalysis dataintepretation development dfa dissertation dissertationtopic ebook employment energy extensions floatingpoint foreclosure foreclosuresoftware fuel geeks givemetehcodez government hardware homeowners homework homeworkassignment homeworkhelp ibm idea ideas internet iphone ipod itcontracts jobs kindle laser laws lazy linkbait lsmeans mainframes marketing mining mobileapplication nano netbeans networking news os p2p parser piracy piratebay programming rasterizer research sam-being-cute sas science security simulation software spoonfeeding spying sql stephenfry student study supercomputer supercomputing sweden syntactic technology textfield tree two'scompliment uk virus ww2






