24 June 2022, Paper 4(2) 9618 CAIE Computer Science

Watch this thread
gangstersparrow
Badges: 2
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#1
Report Thread starter 4 weeks ago
#1
Hi, first post: Just realllyyy wanted to ask about how y'all felt about the paper.

I found the paper really strange this year? I think I still got the marks, but I don't really know why they gave us what they did.

The recursive binary search they asked us to directly copy caused a "maximum recursion depth" error, and so I changed the base/general case provided to make it run. (original: if upper >= 0, i changed it to: if upper > lower)

The "random integers between 1-100" thing was also pretty finicky, since it wanted a screenshot that was pretty annoying to obtain? I used randint to populate my array, which meant i just had to pray that the two search values would appear/not appear.

I used python btw!
0
reply
Wilcoo
Badges: 3
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#2
Report 4 weeks ago
#2
(Original post by gangstersparrow)
Hi, first post: Just realllyyy wanted to ask about how y'all felt about the paper.

I found the paper really strange this year? I think I still got the marks, but I don't really know why they gave us what they did.

The recursive binary search they asked us to directly copy caused a "maximum recursion depth" error, and so I changed the base/general case provided to make it run. (original: if upper >= 0, i changed it to: if upper > lower)

The "random integers between 1-100" thing was also pretty finicky, since it wanted a screenshot that was pretty annoying to obtain? I used randint to populate my array, which meant i just had to pray that the two search values would appear/not appear.

I used python btw!
Yeah I also use python and my binary search wasn’t working because I copied the Pseudocode like they wanted me to, I knew the correct code but I didn’t use it 😭😭, and for the question where we had to import random, idek how to use that so I manually created a 2D array and typed 100 random numbers in total so I could do the following questions 😭😭 it was so time consuming.
0
reply
Composure
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#3
Report 4 weeks ago
#3
Just curious, what did you have to do for this "random integers" exercise?
0
reply
gangstersparrow
Badges: 2
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#4
Report Thread starter 4 weeks ago
#4
(Original post by Composure)
Just curious, what did you have to do for this "random integers" exercise?
Basically, it said smthing along the lines of initialise a 2d array, and each element had to be a random integer from 1-100. I imported random and jist populated it with random.randint.

later, they give us the recursive binary search thing which had its own issues.

It later asked smthing like call the binary search algorithm twice, where one searchvalue is in the 1st array, and one where the searchvalue isn't in the 1st array. which meant you had to run the program on avg 12-13 times for 1 successful screenshot sometimes. you kind of had to sit there and run the code until you got a satisfactory ss.
1
reply
gangstersparrow
Badges: 2
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#5
Report Thread starter 4 weeks ago
#5
(Original post by Wilcoo)
Yeah I also use python and my binary search wasn’t working because I copied the Pseudocode like they wanted me to, I knew the correct code but I didn’t use it 😭😭, and for the question where we had to import random, idek how to use that so I manually created a 2D array and typed 100 random numbers in total so I could do the following questions 😭😭 it was so time consuming.
yeahhh i have no clue if i'm going to get marked down for changing the base case?? cause it said to copy it???
0
reply
Composure
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#6
Report 4 weeks ago
#6
(Original post by gangstersparrow)
Basically, it said smthing along the lines of initialise a 2d array, and each element had to be a random integer from 1-100. I imported random and jist populated it with random.randint.

later, they give us the recursive binary search thing which had its own issues.

It later asked smthing like call the binary search algorithm twice, where one searchvalue is in the 1st array, and one where the searchvalue isn't in the 1st array. which meant you had to run the program on avg 12-13 times for 1 successful screenshot sometimes. you kind of had to sit there and run the code until you got a satisfactory ss.
Thanks for the response. I don't quite see how it's a 2d array when it's populated with just integers. Also how many numbers in the array?

With the last part, there's a couple of ways I can think of where the unpredictable search values could be worked around. Simplest would be to run the code that generates the array, then overwrite the variable with the output and give a comment explaining why. So something like this:
Code:
arr = sorted([random.randint(1, 100) for _ in range(10)])
arr = [2, 16, 25, 35, ...]  # This output was generated by the above code
                            # I've reassigned to avoid unpredictability for the next part
Could instead populate a list of numbers which aren't in the array and then use the random.choice function to choose numbers from each list. So like this:
Code:
arr = sorted([random.randint(1, 100) for _ in range(10)])
present = random.choice(arr)
absent = random.choice([i for i in range(1, 100) if i not in arr])
Last edited by Composure; 4 weeks ago
0
reply
gangstersparrow
Badges: 2
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#7
Report Thread starter 4 weeks ago
#7
(Original post by Composure)
Thanks for the response. I don't quite see how it's a 2d array when it's populated with just integers. Also how many numbers in the array?

With the last part, there's a couple of ways I can think of where the unpredictable search values could be worked around. Simplest would be to run the code that generates the array, then overwrite the variable with the output and give a comment explaining why. So something like this:
Code:
arr = sorted([random.randint(1, 100) for _ in range(10)])
arr = [2, 16, 25, 35, ...]  # This output was generated by the above code
                            # I've reassigned to avoid unpredictability for the next part
Could instead populate a list of numbers which aren't in the array and then use the random.choice function to choose numbers from each list. So like this:
Code:
arr = sorted([random.randint(1, 100) for _ in range(10)])
present = random.choice(arr)
absent = random.choice([i for i in range(1, 100) if i not in arr])
It asked us to initialise a 10by10 2D array, so I used a nested for loop. theres a simpler way for sure, but i didnt wanna mess up, so i used that instead.

i don't know random.choice to be honest! I cant comment on whether that wouldve worked. but the binary search function searched through the first array of the 2d array, eg if arr[i][j], "i" would be 0. the question wanted us to use that function to search thru the first array, searching for a term found withim that first line and a term not found. would random.choice find a term thats within that first line?
0
reply
Composure
Badges: 9
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#8
Report 4 weeks ago
#8
(Original post by gangstersparrow)
It asked us to initialise a 10by10 2D array, so I used a nested for loop. theres a simpler way for sure, but i didnt wanna mess up, so i used that instead.

i don't know random.choice to be honest! I cant comment on whether that wouldve worked. but the binary search function searched through the first array of the 2d array, eg if arr[i][j], "i" would be 0. the question wanted us to use that function to search thru the first array, searching for a term found withim that first line and a term not found. would random.choice find a term thats within that first line?
So if I'm understanding correctly, something like this:
Code:
arr = [sorted([random.randint(1, 100) for _ in range(10)]) for _ in range(10)]
arr_0 = arr[0]
present = random.choice(arr_0)
absent = random.choice([i for i in range(1, 100) if i not in arr_0])
And then you can put these present and absent variables in the binary search function.
Last edited by Composure; 4 weeks ago
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest

Were exams easier or harder than you expected?

Easier (51)
26.15%
As I expected (64)
32.82%
Harder (72)
36.92%
Something else (tell us in the thread) (8)
4.1%

Watched Threads

View All