[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Hey /g/, I'm currently in a computer science I class at
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 7
Thread images: 2
File: 1438322788783.png (178 KB, 640x480) Image search: [Google]
1438322788783.png
178 KB, 640x480
Hey /g/, I'm currently in a computer science I class at my college and I'm doing some studying.
We are using C++.

I have some questions while I prep for my final.
>sequential sort
What is the best algorithm (most simple/efficient) way to implement a sequential sort function for a dynamic array?
I'm having trouble with this. My textbook has examples of a sort function written which calls the use of another function to first find the index of the smallest value. I feel like this is kind of convoluted and that there has to be an easier way to write a function to organize data an array from smallest to largest. Can anyone help me or provide me with some insight?
>>
File: smug anime slut.jpg (31 KB, 704x528) Image search: [Google]
smug anime slut.jpg
31 KB, 704x528
>>54312706
Rei a shit.
>>
>>54312706
dynamic array as in?
>>
>>54312706
If you mean a linked list, then it depends on how many elements you have. For very small lists, bubble sort is fine. For large sets of data, you really don't want to be using sequential sorting algorithms, but between bubble sort, insertion sort, and selection sort, I'd argue that selection sort is probably the most efficient.
>>
>>54312810
Better than a bipolar bitch i guess asukacuck
>>
>>54313825
we have learned about the concepts of linked lists and other ADT's but we don't have to write the code for any of them on the exam.

But yes, I'm aware sequential sorting isn't great for large sets of numbers. Though it's the only type of sorting we are tested on.

The way my textbook shows to do sequential sorting is to define a sort function that calls a separate swap function, and a function to find the smallest or largest member of the data. Is that the best way to do this?
>>
>>54313978
i'm just going on a whim here but if you are using the std libraries, use their underlying iterators to move from one index to another.
if not, have the dynamic array in a handler class where you have extra pointers pointing at first and last element. if its a linked list, make an extra node and make it as the last node.
the list would be empty if first == last. otherwise there are sons.
i'm fairly certain the books in the wiki can help a lot in this.
Thread replies: 7
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.