Register and join over 40,000 other developers!
Recent Topics
-
Print specific values from dictionary with a specific key name
Siten0308 - Jun 20 2019 01:43 PM
-
Learn algorithms and programming concepts
johnnylo - Apr 23 2019 07:49 AM
-
Job Gig PHP Form Needed
PJohnson - Apr 18 2019 03:55 AM
-
How to make code run differently depending on the platform it is running on?
xarzu - Apr 05 2019 09:17 AM
-
How do I set a breakpoint in an attached process in visual studio
xarzu - Apr 04 2019 11:47 AM
Recent Blog Entries
Recent Status Updates
Popular Tags
- networking
- Managed C++
- stream
- console
- database
- authentication
- Visual Basic 4 / 5 / 6
- session
- Connection
- asp.net
- import
- syntax
- hardware
- html5
- array
- mysql
- java
- php
- c++
- string
- C#
- html
- loop
- timer
- jquery
- ajax
- javascript
- programming
- android
- css
- assembly
- c
- form
- vb.net
- xml
- linked list
- login
- encryption
- pseudocode
- calculator
- sql
- python
- setup
- help
- game
- combobox
- binary
- hello world
- grid
- innerHTML

5 replies to this topic
#1
Posted 22 October 2012 - 01:46 AM
hi i am new to this site so i hope i have posted this in the right place
This is for a assignment, I just want some one to double check before submission please i submitted the top code but my teacher sent it back with the following remarks I have a rewritten version below but as this is my final hange for submission I was hoping some one could please proof it for me
Selection sort pseudo-code
The outer loop repeats the selection process n-1 times. For each iteration it is initially assumed that the first entry (index 0) contains the highest value (max = 0). The inner loop then examines the array from left to right and whenever a higher value is found, it's locations in the list is stored in the value "max".
At the end of the first iteration, the last entry in the list has it's value swapped with the entry containing the highest value. The counter of the outer loop is then decremented
For K= 0 to n-1 Max= 0 For J = 0 to n-K-1 If item (J) > Item (Max) Max = Item (J) End If End For Swap item n-k-1 with Max End for End
Your code has the following expression:
If item (J) > Item (Max)
Max = Item (J)
End If
The algorithm requires the variable “Max” to hold the location or position in the array of the next highest value to be swapped. You are assigning to Max the value stored inside that location in the array.
You also need to show step-by-step how the value stored in Item[n-k-1] with the value stored in location Max. This is requested because data can be lost if a swap is not fully understood.
I have since changed it to
for K = 0 to n-1
Max = 0
for j= 0 to n - K-1
if Num[j]> Num[Max]
Max = j
End if
End for
temp = Num[n-k-1]
Num[n-k-1] = Num[Max]
Num[Max] = temp
End for
sorry dont know why the code is all on 1 line there
This is for a assignment, I just want some one to double check before submission please i submitted the top code but my teacher sent it back with the following remarks I have a rewritten version below but as this is my final hange for submission I was hoping some one could please proof it for me
Selection sort pseudo-code
The outer loop repeats the selection process n-1 times. For each iteration it is initially assumed that the first entry (index 0) contains the highest value (max = 0). The inner loop then examines the array from left to right and whenever a higher value is found, it's locations in the list is stored in the value "max".
At the end of the first iteration, the last entry in the list has it's value swapped with the entry containing the highest value. The counter of the outer loop is then decremented
For K= 0 to n-1 Max= 0 For J = 0 to n-K-1 If item (J) > Item (Max) Max = Item (J) End If End For Swap item n-k-1 with Max End for End
Your code has the following expression:
If item (J) > Item (Max)
Max = Item (J)
End If
The algorithm requires the variable “Max” to hold the location or position in the array of the next highest value to be swapped. You are assigning to Max the value stored inside that location in the array.
You also need to show step-by-step how the value stored in Item[n-k-1] with the value stored in location Max. This is requested because data can be lost if a swap is not fully understood.
I have since changed it to
for K = 0 to n-1
Max = 0
for j= 0 to n - K-1
if Num[j]> Num[Max]
Max = j
End if
End for
temp = Num[n-k-1]
Num[n-k-1] = Num[Max]
Num[Max] = temp
End for
sorry dont know why the code is all on 1 line there
#2
Posted 22 October 2012 - 03:40 AM
Use Code tags even if it is pseudocode
anyways... your code seems valid, but I just gave it a quick once-over... The only problem might be that you declared K as capital, but changed to lowercase k further down... I don't know how strict your markers may be...

No harm was done to the world in sending this message, but a few million electrons have been SERIOUSLY inconvenienced...
#3
Posted 22 October 2012 - 12:54 PM
thanks for looking it over
much appreciated, sorry about the tags i thought i had taged it as homwork but must not of worked,

#4
Posted 22 October 2012 - 10:27 PM
Not those kind of tags 
I meant like this:
See the Code tags?

I meant like this:
for(int i = 0 ; i < 50 ; i++) { cout << "I like apples" << endl; }
See the Code tags?

No harm was done to the world in sending this message, but a few million electrons have been SERIOUSLY inconvenienced...
#5
Posted 23 October 2012 - 05:35 AM
He was talking about code tags as in : [ CODE ] your code here and [ / CODE ] tags (without the spaces). The button on the editor looks like <>. If just makes things more readable by putting it in a different color background and uses a fixed size font.
So, your code would look like this:
Nothing major, just easier on the eyes.
So, your code would look like this:
for K = 0 to n-1 Max = 0 for j= 0 to n - K-1 if Num[j]> Num[Max] Max = j End if End for temp = Num[n-k-1] Num[n-k-1] = Num[Max] Num[Max] = temp End for
Nothing major, just easier on the eyes.
My Blog: http://forum.codecal...699-blog-77241/
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth
#6
Posted 23 October 2012 - 01:27 PM
Oh ok thanks, passed the assessment thanks for every ones help,
Also tagged with one or more of these keywords: pseudocode
General Forums →
General Programming →
Pseudocode BasicsStarted by Veals12, 24 Mar 2016 ![]() |
|
![]() |
||
General Forums →
General Programming →
[Homework] Loading and finding integers in an arrayStarted by Kaiser, 24 Nov 2015 ![]() |
|
![]() |
||
General Forums →
General Programming →
Writing a time calculator in PseudocodeStarted by SoloDoloPyro, 10 Sep 2015 ![]() |
|
![]() |
||
General Forums →
General Programming →
Pseudocode and flowchart helpStarted by xgen, 27 Jul 2015 ![]() |
|
![]() |
||
General Forums →
General Programming →
How to create a flowchart for this qestion.Started by BeckBeishen, 09 Jun 2015 ![]() |
|
![]() |
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download