Computer Science Canada How to sort the integer by not using "array"  | 
  
| Author: | 8749236 [ Thu Feb 03, 2011 11:31 am ] | ||
| Post subject: | How to sort the integer by not using "array" | ||
What is it you are trying to achieve? Our teacher give us a class assignment, he want us to sort the integers by not using code :"array" What is the problem you are having? The only way i know is use the "if" statement. is their any easier way to sort the integers? Describe what you have tried to solve this problem i tried "label" but doesn't work well (maybe is my fault..) Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <Answer Here> 
 Please specify what version of Turing you are using Turing 4.1  | 
	|||
| Author: | Clayton [ Thu Feb 03, 2011 12:35 pm ] | 
| Post subject: | RE:How to sort the integer by not using "array" | 
I'm not exactly sure what you're asking here. Are you supposed to sort a bunch of given integers? Are you sorting one or two user-inputted integers? Why aren't you to use arrays?  | 
	|
| Author: | SNIPERDUDE [ Thu Feb 03, 2011 4:46 pm ] | 
| Post subject: | RE:How to sort the integer by not using "array" | 
A full description of the task required would be helpful.  | 
	|
| Author: | 8749236 [ Thu Feb 03, 2011 8:14 pm ] | 
| Post subject: | RE:How to sort the integer by not using "array" | 
we are trying to make a program.. the user input a bunch of integer, and our program need to reorganize it from smallest to biggest, but we cannot use the code "array"  | 
	|
| Author: | Tony [ Thu Feb 03, 2011 8:33 pm ] | 
| Post subject: | RE:How to sort the integer by not using "array" | 
How many integers? What's the range of valid values? Are you supposed to avoid just the keyword of "array" (build in implementation) or the concept of an array (let's say C's pointer + offsets)? Can you store integers in any other data-structure such as lists or trees?  | 
	|
| Author: | 8749236 [ Fri Feb 04, 2011 10:30 am ] | 
| Post subject: | RE:How to sort the integer by not using "array" | 
just avoiding the "array"... and others have no limit...  | 
	|
| Author: | Zren [ Fri Feb 04, 2011 1:48 pm ] | 
| Post subject: | RE:How to sort the integer by not using "array" | 
First lets get some questions out of the way. Do you know what arrays are? It's hard to not use something when you don't even understand what it is. Is there a maximum amount of numbers (Eg 5 numbers) that you need to sort? Do you understand the concept of sorting in general? If you had 3 different numbers in 3 different variables, how would you print them to the screen in ascending order (low->high)?  | 
	|
| Author: | TokenHerbz [ Fri Feb 04, 2011 8:06 pm ] | ||||
| Post subject: | RE:How to sort the integer by not using "array" | ||||
why cant i call same named variables differing in numbers 1 .. upper in a for loop to use them??? 
 I want wanting to just test something but This wont work, and imo it should. but alas turing cant use variables well... Is there a way to use them in this type of set up???? 
 THX  | 
	|||||
| Author: | DemonWasp [ Fri Feb 04, 2011 9:40 pm ] | 
| Post subject: | RE:How to sort the integer by not using "array" | 
Why not? Because that's what arrays are for. Duh. This concept is actually called "variable variables" and if used improperly, it's almost impossible to debug. Very few languages support it (those that do include PHP and Ant). Why aren't you using arrays, again?  | 
	|
| Author: | huskiesgoaler34 [ Sat Feb 05, 2011 4:08 pm ] | 
| Post subject: | Re: How to sort the integer by not using "array" | 
DemonWasp is correct. This would be a perfect time to use arrays. That's what they are supposed to do. I don't understand why your teacher wouldn't allow you to use arrays when arrays are the most efficent way to slove your problem.  | 
	|
| Author: | TokenHerbz [ Sat Feb 05, 2011 7:01 pm ] | 
| Post subject: | RE:How to sort the integer by not using "array" | 
perhaps they are trying to encourage an recursive type of answer or something, But yeah, arrays rule. I tried some other ways and well, I'm curious to know why you cant use them either.  | 
	|
| Author: | DemonWasp [ Sat Feb 05, 2011 7:26 pm ] | 
| Post subject: | RE:How to sort the integer by not using "array" | 
I mean, it's certainly possible to sort things in non-array objects, such as lists and trees. However, it seems unlikely that a course at that level would be writing in Turing.  | 
	|
| Author: | huskiesgoaler34 [ Sat Feb 05, 2011 8:45 pm ] | 
| Post subject: | Re: How to sort the integer by not using "array" | 
The author of the thread wrote that he thought of an if statement. An if statement is used only for conditions. If somethings happens then do this, etc. Label won't work very well for this program.  | 
	|
| Author: | huskiesgoaler34 [ Sat Feb 05, 2011 8:53 pm ] | ||
| Post subject: | Re: RE:How to sort the integer by not using "array" | ||
 THX[/quote] This program doesn't work. The variable num hasn't been declared nor has it been set a value.  | 
	|||
| Author: | Insectoid [ Sat Feb 05, 2011 8:57 pm ] | ||
| Post subject: | Re: RE:How to sort the integer by not using "array" | ||
huskiesgoaler34 @ Sat Feb 05, 2011 8:53 pm wrote: 
 THX This program doesn't work. The variable num hasn't been decalred nor has it been set a value.[/quote] If you'd care to read the entire post containing this code segment you'd see the author already knew it wouldn't work. Yeah, this can be done using conditions if you know EXACTLY how many numbers you're inputting but if it's a variable quantity then it's probably impossible in Turing.  | 
	|||
| Author: | huskiesgoaler34 [ Sat Feb 05, 2011 9:23 pm ] | 
| Post subject: | Re: How to sort the integer by not using "array" | 
Sorry, I didn't read the entire section. You are right that it's probably impossible unless you know the exact quantity.  | 
	|
| Author: | TokenHerbz [ Sat Feb 05, 2011 10:16 pm ] | ||||
| Post subject: | Re: How to sort the integer by not using "array" | ||||
Okay Iv'e figured this out, and made some Turing codes for you to have a ground start... I think I commented it good, and as we on compsci.ca goals are, to help you "LEARN" so I will not give you the completed source code. That is for you to work on, and Iv'e provided you with alot of good informtion and concepts to get this working. However if you do run into problems or more questions, Please don't hesitate in some replys, But You must tell me what you've done or tried to sort this out first, Because we arn't here to do your projects first. This was a very interesting question your presented us with and in programming, there are ALWAYS ways to do things, Cant be limited, just gotta try and think outside the box a bit, which can be hard to do sometimes, Anyways this should keep you busy for the night. Please post final SOURCE code when its complete so we may test it and critique it... Should be fun! 
 ****Ofcourse I can't give you all the free-be answers, but Here is a few more hints to help you figure this out!!!! (This method does work, its your best bet to use without arrays, IMO).. Feel free to try something else tho.**** 
  | 
	|||||
| Author: | Tony [ Sat Feb 05, 2011 10:31 pm ] | 
| Post subject: | RE:How to sort the integer by not using "array" | 
This is a neat idea, but it should be clear that: 1) a string is an array of characters 2) Turing's strings hold a max of 255 characters. If we are going to be building our own implementation of an array, File's read/write/seek (note: binary mode; not ASCII put/get) should work exceptionally well.  | 
	|
| Author: | TokenHerbz [ Sat Feb 05, 2011 10:38 pm ] | 
| Post subject: | RE:How to sort the integer by not using "array" | 
well i was under the assumption that he couldn't use "var array x .. y" style arrays lol... Okay but you got a point there tony, Tomorrow i shall see about posting this doing just that, Should be crazy. Although, This i think put my program within the acceptable limitations his teacher wanted, Do it without CODE : array. 8749236 @ Thu Feb 03, 2011 12:31 pm wrote: What is it you are trying to achieve?
 Our teacher give us a class assignment, he want us to sort the integers by not using code :"array"  | 
	|
| Author: | Tony [ Sat Feb 05, 2011 11:02 pm ] | 
| Post subject: | RE:How to sort the integer by not using "array" | 
That's true, but when asked about number of integers to be sorted, the answer was Quote: ...have no limit... If you are looking to build something interesting, I could suggest an abstract Array class that could then have a number of different underlying implementations, including strings (as you've done already), files, linked-lists, or anything else that could hold some amount of data. Allowing for some constrains, a single character could serve as a data-store for an array of 8 bits  | 
	|
| Author: | TokenHerbz [ Sun Feb 06, 2011 11:06 am ] | 
| Post subject: | RE:How to sort the integer by not using "array" | 
yeah i guess im crippled with up to 255 chars to use in that string (not that i think someone would use that many...) but a valid point. That would be something neat to look into indeed.  | 
	|