Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,517 members, 7,958,565 topics. Date: Wednesday, 25 September 2024 at 05:23 PM |
Nairaland Forum / Science/Technology / Programming / Computer Science/programming Challenging Questions (11979 Views)
What's The Most In-demand Field Of Computer Science/programming? / How To Get Your First Data Science/programming Job / For Computer Science Students (2) (3) (4)
Re: Computer Science/programming Challenging Questions by airsaylongcon: 8:33am On Mar 02, 2016 |
ultimatex: Can you calculate the worst case scenario in big O notation of mergesort? |
Re: Computer Science/programming Challenging Questions by Fulaman198(m): 9:32am On Mar 02, 2016 |
I have a good problem for you guys to solve. I remember one of my professors years back giving me this one. Implement a method double getRoot(double x, int n, double tolerance) that returns the nth root of x to the given tolerance (plus or minus). Use a binary search algorithm Assume all parameters are positive. Avoid infinite loops when tolerance is too small. Make sure the code works when 0< x < 1. It should work for values of n in the hundreds, provided tolerance isn't too small. Only basic operations may be used (+, -, *, / etc.). Upload your function/method with a driver to prove that it works 2 Likes |
Re: Computer Science/programming Challenging Questions by airsaylongcon: 9:40am On Mar 02, 2016 |
Fulaman198: Explain the function of the tolerance variable and how it works |
Re: Computer Science/programming Challenging Questions by DonSegmond(m): 2:01pm On Mar 02, 2016 |
Tosinosu2011:I know this is for your homework, but I want to open your eyes that school might not be enough. I want you to know there is more out there, and that you can learn to do more and you should seize control of your life and constantly keep learning. Here is the solution in prolog.
When we solve, we get the truth. With 9 tires, there are 3 solutions. ?- solve(9, Car, Tricycle, Bicycle). Car = 0, Tricycle = 1, Bicycle = 3 ; Car = 0, Bicycle = 0, Tricycle = 3 ; Car = 1, Tricycle = 1, Bicycle = 1 ; Anyways, have fun with Java, but know there is more out there. 1 Like |
Re: Computer Science/programming Challenging Questions by Fulaman198(m): 7:44pm On Mar 02, 2016 |
Tosinosu2011: I would write it for you, but you need to be more serious and read your textbook. Who is the author of your text? |
Re: Computer Science/programming Challenging Questions by Fulaman198(m): 11:28pm On Mar 02, 2016 |
Tosinosu2011: If you attempt to write the program, I will help you with the rest. |
Re: Computer Science/programming Challenging Questions by airsaylongcon: 8:57am On Mar 03, 2016 |
I will post questions over the weekend as I am out of town guys |
Re: Computer Science/programming Challenging Questions by airsaylongcon: 2:50pm On Mar 07, 2016 |
Here we go guys Consider the following function int t () { int q, output; output = 0; for ( q = 0; q < 5; q++ ) { if ( ( q % 3 ) == 1 ) output = output + q; else output = output + 1; } return output; } What value is returned as a result of the call t () ? |
Re: Computer Science/programming Challenging Questions by codemarshal08(m): 5:44pm On Mar 07, 2016 |
airsaylongcon: A call to this function will cause an infinite loop. it will never return as the value of q is never incremented |
Re: Computer Science/programming Challenging Questions by airsaylongcon: 5:54pm On Mar 07, 2016 |
codemarshal08: Sorry that's a typo. My brain meant to type q++ while my hand typed k++. My apologies |
Re: Computer Science/programming Challenging Questions by codemarshal08(m): 6:02pm On Mar 07, 2016 |
airsaylongcon: OK. the return value is 8 ----------
|
Re: Computer Science/programming Challenging Questions by airsaylongcon: 6:11pm On Mar 07, 2016 |
codemarshal08: That was straight forward. Well done |
Re: Computer Science/programming Challenging Questions by airsaylongcon: 6:15pm On Mar 07, 2016 |
Consider the following pseudocode. program main () begin integer p, q, r, s p = 6 q = 7 r = 8 s = fxn (p, q, r) print s, p, q, r end integer fxn (integer a, integer b, integer c) begin if (a > 6) then b = 25 c = a + b return b + c end If fxn uses call-by-reference, what values would be printed as a result of executing the pseudocode? |
Re: Computer Science/programming Challenging Questions by codemarshal08(m): 6:32pm On Mar 07, 2016 |
airsaylongcon: Please, Does the if in the function have an [b]else [/b]part. Just want to be clear. I am not too convenient with pascal Syntax(i guess) |
Re: Computer Science/programming Challenging Questions by airsaylongcon: 6:36pm On Mar 07, 2016 |
codemarshal08: I have edited the problem. I tried to put a space indicating that the if applied only to b=25 but some how that space vanished |
Re: Computer Science/programming Challenging Questions by codemarshal08(m): 6:43pm On Mar 07, 2016 |
airsaylongcon:20, 6 , 7, 13 1 Like |
Re: Computer Science/programming Challenging Questions by asalimpo(m): 6:45pm On Mar 12, 2016 |
sad that this this thread dead. I wanted to learn from it. |
Re: Computer Science/programming Challenging Questions by Fulaman198(m): 8:05am On Mar 13, 2016 |
Tosinosu2011: Did you ever figure it out? Let me know so I can help you with it. |
Re: Computer Science/programming Challenging Questions by Argonn(m): 11:57am On Apr 07, 2017 |
Please I need a pro to check this code for m. Its a program should accept input for user and count the number of vowels and consonants. The Code: v_count = 0 c_count = 0 alphabets = [] vowels = ['a', 'e', 'i', 'o', 'u'] consonants [] for i in vowels: ....vowels.append(chr(ord(i)-32)) ....#update the vowels list with caps for i in range(65, 91): ....alphabet.append(chr(i)) ....alphabet.append(chr(i+32)) ....#update the alphabets list for i in alphabets: ....if i not in vowels: ........consonants.append(i) ........#update the consonants list text = input("Enter text:\t" ) for letter in text: ....if letter in vowels: ........v_count += 1 ....elif letter in consonants: ........c_count += 1 ....else: ........continue print("vowels: " + str(v_count)) print("consonants: " + str(c_count)) |
Re: Computer Science/programming Challenging Questions by Kidstell: 1:55am On May 12, 2017 |
airsaylongcon:Answer = 8 Given that I had to do it without paper. I think it's a very good brain task. Though I am yet to see another answer claiming that I am right I must also say that I noticed the condition for an even number input is never executed |
Re: Computer Science/programming Challenging Questions by Kidstell: 2:08am On May 12, 2017 |
airsaylongcon: answer = 8 |
Re: Computer Science/programming Challenging Questions by Craigston: 11:48am On May 14, 2017 |
airsaylongcon: The answer is E. If the loop runs until the first a < 10, we cannot compute a b *= 10, but we must have done that from a = {1, 2, ..., 9}. At that point, a >= 10 is true after the last iteration. Similarly, we introduced a second termination condition that brings the iteration count closer, at a = c. This condition will be reached only if the integer read into c is less than 10. The same procedure above applies, with the range of a being {a: 1 <= a < c} during the execution of the loop's body. Then b = (c -1)! Is true after the loop exits, since a = c terminates the loop, just after a become equal to c. |
Re: Computer Science/programming Challenging Questions by Craigston: 12:00pm On May 14, 2017 |
Damn! I thought it was an active topic. |
Programming Projects (individual) / Why Are Nigerian Programmers So Dumb? / I Want To Work At Google: Journey Of A Software Developer
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 49 |