funim
Badges: 7
Rep:
?
#1
Report Thread starter 1 year ago
#1
Do I need to learn the pseudocodes for linear and binary search off by heart?
e.g. Binary Search

data_set = [2, 4, 5, 6, 9, 21, 50, 77, 91]
data_set_length = 9
search_criteria = 50
LB = 0
UB = data_set_length - 1
match = false

WHILE match == false AND LB != UB
MidPoint = roundup((UB - LB)/2) + LB
IF data_set[MidPoint] == search_criteria THEN
match = true
ELSE IF data_set[MidPoint] < search_criteria THEN
LB = MidPoint + 1
ELSE
UB = MidPoint - 1
END IF
END WHILE

IF match == true THEN
PRINT 'Match found'
ELSE
PRINT 'Match not found'
END IF


Thanks
0
reply
Blue_Cow
Badges: 22
Rep:
?
#2
Report 1 year ago
#2
(Original post by funim)
Do I need to learn the pseudocodes for linear and binary search off by heart?
e.g. Binary Search

data_set = [2, 4, 5, 6, 9, 21, 50, 77, 91]
data_set_length = 9
search_criteria = 50
LB = 0
UB = data_set_length - 1
match = false

WHILE match == false AND LB != UB
MidPoint = roundup((UB - LB)/2) + LB
IF data_set[MidPoint] == search_criteria THEN
match = true
ELSE IF data_set[MidPoint] < search_criteria THEN
LB = MidPoint + 1
ELSE
UB = MidPoint - 1
END IF
END WHILE

IF match == true THEN
PRINT 'Match found'
ELSE
PRINT 'Match not found'
END IF


Thanks
Check the specification and see if they require you to learn the algorithm.

You shouldn't have to remember any specific syntax/lines of code if you actually understand what linear and binary search does.
0
reply
winterscoming
Badges: 19
Rep:
?
#3
Report 1 year ago
#3
(Original post by funim)
Do I need to learn the pseudocodes for linear and binary search off by heart?
No - Computer Science is all about having skills in problem solving and understanding the underlying concepts, so in the case of algorithms, you just need to understand how a particular algorithm works. CompSci isn't really a "knowledge"-based subject, it's a lot deeper than that - it's based very heavily around having the skills and gaining a full understanding of concepts.

Psuedocode is just a Plain-English Language way of being able to express those concepts, so if you're ever trying to memorise pseudocode then you're doing something wrong!

Don't spend (waste) time trying to memorise pseudocode, instead use your time wisely so that you're confident with those algorithms at a conceptual level, and make sure you're confident in thinking computationally as well so that you can cope with absolutely any exam question which comes along for writing pseudocode to solve a problem.

There's a proverb: "Give a man a fish, he'll feed himself for a day. Teach a man to fish and he'll feed himself for the rest of his life". Learning the concepts and knowing the mindset of problem solving is like the proverbial 'learning to fish'.


I believe the exam boards usually provide a pseudocode reference in the exam so that you don't need to memorise the syntax either.
Last edited by winterscoming; 1 year ago
0
reply
X

Quick Reply

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

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

Current uni students - are you thinking of dropping out of university?

Yes, I'm seriously considering dropping out (101)
13.4%
I'm not sure (32)
4.24%
No, I'm going to stick it out for now (236)
31.3%
I have already dropped out (18)
2.39%
I'm not a current university student (367)
48.67%

Watched Threads

View All