|
||||||
| General Programming Non language specific, Assembly, Linux/Unix, Mac and anything not covered in other topics. Talk about Programming Theory here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
I'm not complety sure if this is the right place but i need A LOT of help learning array processing in pseudocode. is their anyone that could direct me to a tutorial where you break it down step by step?
|
| Sponsored Links |
|
|
|
|||||
|
If you do a search for array tutorials in almost any language, you should get the idea. You will find very few tutorials on anything in pseudocode.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
|
|||||
|
One other point about "setting an element to false".
Sometimes, when using an array, you might want to remove an element from the array but not incur the cost of moving everything below the deleted element up one position. To avoid this, you can mark an element as "deleted", so that it can be removed quickly from the array. You just have to remember when processing the array, not to process the deleted items. For example, say you are storing numbers in your array and you have an array like this: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] You want to delete item 5. One way to do this would be to shift item 6 into position 5, shift item 7 into position 6, shift item 8 into position 7, etc. to end up with this: [1, 2, 3, 4, 6, 7, 8, 9, 10] This takes a lot of time, as you have to move 5 items in order to delete just one. Using the alternative method, you would replace item 5 with a "deleted" symbol, like this: [1, 2, 3, 4, X, 6, 7, 8, 9, 10] This is much quicker, as you only have to do one thing to the array. The problems with this method are that you have to remember to ignore the "X" element when you process the array (e.g. to print out the elements), and you have to make sure that you are not wanting to store the item "X" in your array. This is ok in this example because we're storing numbers in the array and "X" is not a number, it's a character. The usual thing to use instead of "X" is a symbol called "null". This is built into most languages and means "an empty space in memory". But there are some situations in which you would want to store "null" in an array, so this approach does not always work. As void said, you must always know what data types are being stored in your array. Hope that helps.
__________________
My fun, friendly online games website: Cygnet Games My Squidoo page on Cygnet Games. |
|
|||
|
4. An elementary school contains 30 classrooms numbered 1 through 30. Each classroom can contain any number of students up to 35. Each student takes an achievement test at the end of the school year and receives a score from 0 through 100. One record is created for each student in the school; each record contains a student ID, classroom number, and score on the achievement test.
Design a Student class and the logic for an application that lists the total points scored for each of the 30 classrooms. Student -studentId: numeric -classroomNumber: numeric -score: numeric +getStudentId(): numeric +getClassroomNumber(): numeric +getScore(): numeric +setStudentId(numeric id): void +setClassroomNumber(numeric number): void +setScore(numeric score): void public class CountTotalPoints constant numeric NUM_CLASSROOMS = 30 numeric points[NUM_ CLASSROOMS] numeric sub = 0 while sub < NUM_ CLASSROOMS points[sub] = 0 sub = sub + 1 endwhile public static void main() Student stu open(inputFile) stu = read(inputFile) while stu not EOF countPoints(stu) stu = read(inputFile) endwhile printReport() close(inputFile) return public static void countPoints(Student stu) numeric class class = stu.getClassroomNumber() points[class-1] = points[class-1] + stu.getScore() return public static void printReport() numeric class print “Classroom Report” print “Classroom # Total points scored” class = 0 while class < NUM_ CLASSROOMS print (class+1), points[class] class = class+1 endwhile return endClass The question is how to modify this pseudocode so that each classroom’s average of the test scores prints, rather than each classroom’s total. I ll appriciate the help Thank You |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Dealing with Arrays | sthenri | Java Help | 2 | 12-11-2007 01:22 AM |
| Dynamic Arrays | Fedex | C and C++ | 3 | 12-02-2007 05:45 PM |
| Help regarding the sorting of arrays with flags! | Yuriy M | C and C++ | 3 | 10-12-2007 11:30 PM |
| Python arrays... | Sir_Rimo | Python | 3 | 06-20-2007 09:54 AM |
| Arrays | clookid | PHP Tutorials | 1 | 01-11-2007 09:30 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |
Goal: 100,000 Posts
Complete: 98%