• Congratulations to the Class of 2024 on your results!
    Let us know how you went here
    Got a question about your uni preferences? Ask us here

Algorithms?? (1 Viewer)

pfft

New Member
Joined
Jan 31, 2008
Messages
13
Gender
Male
HSC
2008
Are we required to know how to write algorithms for like selection sort, insertion sort, bubble sort, etc??

i'm finding it hard to write up a selection sort
 

Graceofgod

Member
Joined
Feb 17, 2008
Messages
136
Location
Now? A computer.
Gender
Undisclosed
HSC
2008
pfft said:
Are we required to know how to write algorithms for like selection sort, insertion sort, bubble sort, etc??

i'm finding it hard to write up a selection sort
This was asked earlier. It is best if you could write one up in an exam.

You should at least be able to destiguish between the three sorts and be able to write up the two searches.
 

Fly Kite

Member
Joined
Aug 1, 2008
Messages
82
Gender
Male
HSC
2010
insertion and selection and bubble are pretty hard
iive no idea how to write insertion a little about selection and most of bubble
 

yoyojuan

New Member
Joined
Mar 10, 2009
Messages
3
Gender
Male
HSC
2009
I have been told by my teacher that you don't have to be able to write one one the spot, but you have to be able to tell what one is by reading it. It is obvous that it would be better if you could though.
 

spoonbender

Member
Joined
Mar 1, 2007
Messages
91
Gender
Male
HSC
2009
I've been told that the only ones you need to be able to replicate are Linear and Binary search. You would, however, need to know how the others work and be able to recognise them when reading the algorithm.

Don't quote me on it though.
 

Interdrama

#wang
Joined
Dec 16, 2006
Messages
89
Gender
Undisclosed
HSC
2011
bubble sort:

Code:
BEGIN bubbleSort
	set counter = 1
	set end = last index of array

	WHILE end>1
		counter=1
		WHILE counter < last
			IF thearray[current] > thearray[current+1] THEN
				temp=thearray[current]            //swaps the two 
				thearray[current]=thearray[current+1]
				thearray[current+1]=temp


				
			END IF
			increment counter
		ENDWHILE
		decrement end	
	ENDWHILE
END
i'm still learning how to make the swap a function though D: ... test on tuesday morning

EDIT: OMG TOMORROW

i just learnt the insertion sort, which i just learnt

Code:
BEGIN MAINPROGRAM
set first to 1
set last to 100
set positionofnext to last -1 
WHILE  positionofnext => first         //until there is no longer unsorted part
	next = thearray[positionofnext]
	current = positionofnext
	WHILE current<last and thearray[current]>thearray[current+1]
		increment current
		thearray[current-1]=thearray[current]
	ENDWHILE
	thearray[current]=next
	decrement positionofnext                        //reduces unsorted part by 1
ENDWHILE
END MAINPROGRAM
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top