Question about a simple sorting method without arrays

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2008
Posts: 9
Reputation: wqzerboom is an unknown quantity at this point 
Solved Threads: 0
wqzerboom wqzerboom is offline Offline
Newbie Poster

Question about a simple sorting method without arrays

 
0
  #1
Oct 10th, 2008
The requirements are actually simple, just asking to sort a few, say 10, 20 or so, intergers in ascending order. However, array and pointers are not allowed to be used, and just the fundamental knowledge about flow control are permitted. The hints are as follows:
1. Initialize a variable F that keeps a very large number (larger than any number in the to-be -sorted batch)
2. Search among the batch for the biggest number, which is smaller F
3. Show that number on the screen
4. Save that number to F and take away the number from the batch
5. Repeat steps 2,3 and 4 until all the 5 numbers in the batch are shown on the screen

Many thanks to anyone who can help!!!
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 68
Reputation: Rhohitman is an unknown quantity at this point 
Solved Threads: 4
Rhohitman's Avatar
Rhohitman Rhohitman is offline Offline
Junior Poster in Training

Re: Question about a simple sorting method without arrays

 
0
  #2
Oct 10th, 2008
Its the simple question ... When we use to learn the C++
This type of Sorting is known as Selection sorting...

Rest you figure it out...
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 9
Reputation: wqzerboom is an unknown quantity at this point 
Solved Threads: 0
wqzerboom wqzerboom is offline Offline
Newbie Poster

Re: Question about a simple sorting method without arrays

 
0
  #3
Oct 10th, 2008
Originally Posted by Rhohitman View Post
Its the simple question ... When we use to learn the C++
This type of Sorting is known as Selection sorting...

Rest you figure it out...
Thanks a lot
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Question about a simple sorting method without arrays

 
0
  #4
Oct 10th, 2008
OK: "array and pointers are not allowed to be used". What is it "batch"? I don't know such type (I hope, it's not an array ) in C++...
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 9
Reputation: wqzerboom is an unknown quantity at this point 
Solved Threads: 0
wqzerboom wqzerboom is offline Offline
Newbie Poster

Re: Question about a simple sorting method without arrays

 
0
  #5
Oct 10th, 2008
Originally Posted by Rhohitman View Post
Its the simple question ... When we use to learn the C++
This type of Sorting is known as Selection sorting...

Rest you figure it out...
Using selection sorting without using arrays, can you provide any ideas how to get the numbers into the loop, and take away the number from the batch?
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 9
Reputation: wqzerboom is an unknown quantity at this point 
Solved Threads: 0
wqzerboom wqzerboom is offline Offline
Newbie Poster

Re: Question about a simple sorting method without arrays

 
0
  #6
Oct 10th, 2008
Originally Posted by ArkM View Post
OK: "array and pointers are not allowed to be used". What is it "batch"? I don't know such type (I hope, it's not an array ) in C++...
"batch" simply means the collection of the numbers to be sorted, that's not a keyword.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 86
Reputation: gregorynoob is an unknown quantity at this point 
Solved Threads: 5
gregorynoob gregorynoob is offline Offline
Junior Poster in Training

Re: Question about a simple sorting method without arrays

 
0
  #7
Oct 10th, 2008
you can access them by memory addresses... so the integers should be given addresses that are consecutive. could count as pointing really.
Last edited by gregorynoob; Oct 10th, 2008 at 11:30 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 9
Reputation: wqzerboom is an unknown quantity at this point 
Solved Threads: 0
wqzerboom wqzerboom is offline Offline
Newbie Poster

Re: Question about a simple sorting method without arrays

 
0
  #8
Oct 10th, 2008
Originally Posted by gregorynoob View Post
you can access them by memory addresses... so the integers should be given addresses that are consecutive. could count as pointing really.
Thank you any way, but you didn't see the question carefully, arrays and pointers are not
allowed to be used, only the fundamental knowledge of the flow control are permited and
that's why the hints, the initialization of the large number F are for.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 9
Reputation: wqzerboom is an unknown quantity at this point 
Solved Threads: 0
wqzerboom wqzerboom is offline Offline
Newbie Poster

Re: Question about a simple sorting method without arrays

 
0
  #9
Oct 10th, 2008
This website doesn't provide source code, and I understand that, however, is there anybody who manages this website can come up with some useful ideas. I'm only a
new learner of C++, and what I'm asking is
only some fundamental thing.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 68
Reputation: Rhohitman is an unknown quantity at this point 
Solved Threads: 4
Rhohitman's Avatar
Rhohitman Rhohitman is offline Offline
Junior Poster in Training

Re: Question about a simple sorting method without arrays

 
0
  #10
Oct 10th, 2008
Originally Posted by wqzerboom View Post
This website doesn't provide source code, and I understand that, however, is there anybody who manages this website can come up with some useful ideas. I'm only a
new learner of C++, and what I'm asking is
only some fundamental thing.
According to the sorting algorithm I have already told you its the Selection sorting.
But i don't think so you can possibly create the batch of no without using array or pointer.

Other crazy solutions might be using link list or objects or blah blah blah.. for just a simple sorting.
Last edited by Rhohitman; Oct 10th, 2008 at 1:35 pm.
Chazing Dreams ;'P
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC