943,725 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 2040
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Oct 10th, 2008
0

Question about a simple sorting method without arrays

Expand Post »
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!!!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wqzerboom is offline Offline
9 posts
since Oct 2008
Oct 10th, 2008
0

Re: Question about a simple sorting method without arrays

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...
Reputation Points: 10
Solved Threads: 5
Junior Poster in Training
Rhohitman is offline Offline
81 posts
since Dec 2007
Oct 10th, 2008
0

Re: Question about a simple sorting method without arrays

Click to Expand / Collapse  Quote originally posted by Rhohitman ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wqzerboom is offline Offline
9 posts
since Oct 2008
Oct 10th, 2008
0

Re: Question about a simple sorting method without arrays

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++...
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008
Oct 10th, 2008
0

Re: Question about a simple sorting method without arrays

Click to Expand / Collapse  Quote originally posted by Rhohitman ...
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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wqzerboom is offline Offline
9 posts
since Oct 2008
Oct 10th, 2008
0

Re: Question about a simple sorting method without arrays

Click to Expand / Collapse  Quote originally posted by ArkM ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wqzerboom is offline Offline
9 posts
since Oct 2008
Oct 10th, 2008
0

Re: Question about a simple sorting method without arrays

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.
Reputation Points: 12
Solved Threads: 5
Junior Poster in Training
gregorynoob is offline Offline
86 posts
since Jun 2008
Oct 10th, 2008
0

Re: Question about a simple sorting method without arrays

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wqzerboom is offline Offline
9 posts
since Oct 2008
Oct 10th, 2008
0

Re: Question about a simple sorting method without arrays

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wqzerboom is offline Offline
9 posts
since Oct 2008
Oct 10th, 2008
0

Re: Question about a simple sorting method without arrays

Click to Expand / Collapse  Quote originally posted by wqzerboom ...
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.
Reputation Points: 10
Solved Threads: 5
Junior Poster in Training
Rhohitman is offline Offline
81 posts
since Dec 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: what does it mean by shadowing
Next Thread in C++ Forum Timeline: C++ template





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC