User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 425,963 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,676 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1277 | Replies: 4
Reply
Join Date: Dec 2007
Posts: 157
Reputation: atish00 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 4
atish00 atish00 is offline Offline
Junior Poster

Arranging 1D int. array in ascending order.

  #1  
Feb 10th, 2008
Can anyone help me wiht the prog.

arrange a 1D array in ascending order.

No need for the prog. code just explain me the logic.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2006
Location: UK
Posts: 468
Reputation: Bench has a spectacular aura about Bench has a spectacular aura about Bench has a spectacular aura about 
Rep Power: 5
Solved Threads: 42
Bench's Avatar
Bench Bench is offline Offline
Posting Pro in Training

Re: Arranging 1D int. array in ascending order.

  #2  
Feb 10th, 2008
Assuming you're supposed to write your own, rather than use the standard C++ sort function, You'll need to implement a sort algorithm. a bubble sort or a selection sort should be fairly easy to write.

You'll find pseudocode for these here
http://en.wikipedia.org/wiki/Bubble_sort
http://en.wikipedia.org/wiki/Selection_sort
Last edited by Bench : Feb 10th, 2008 at 11:04 am.
¿umop apisdn upside down?
Reply With Quote  
Join Date: Jul 2005
Posts: 1,157
Reputation: Lerner is just really nice Lerner is just really nice Lerner is just really nice Lerner is just really nice 
Rep Power: 9
Solved Threads: 150
Lerner Lerner is offline Offline
Veteran Poster

Re: Arranging 1D int. array in ascending order.

  #3  
Feb 10th, 2008
There are any number of ways to sort an array. Some of them are called bubble sort, qsort, sort(), merge sort, selection sort, etc. Each has their attractions and detractions. For arrays of relatively small size the bubble sort seems to be very popular with beginning programers because of the "simplicity" of implementation. The basic principle of bubble sort is to compare each element of the array, starting the index 0, with every other element in the array and swapping them if the desired criteria is satisfied.
Last edited by Lerner : Feb 10th, 2008 at 11:05 am.
Reply With Quote  
Join Date: Dec 2007
Posts: 157
Reputation: atish00 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 4
atish00 atish00 is offline Offline
Junior Poster

Re: Arranging 1D int. array in ascending order.

  #4  
Feb 10th, 2008
my assingment says use selection sort duno what that is.
Reply With Quote  
Join Date: Jul 2005
Posts: 1,157
Reputation: Lerner is just really nice Lerner is just really nice Lerner is just really nice Lerner is just really nice 
Rep Power: 9
Solved Threads: 150
Lerner Lerner is offline Offline
Veteran Poster

Re: Arranging 1D int. array in ascending order.

  #5  
Feb 10th, 2008
You can look it up using your favorite search engine. Basically, it means first find the smallest in the array and swap it with the element in the first position, then find the second smallest element and swap it with the element in the second position, and continue in this way until the entire array is sorted.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 10:45 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC