How to check whether a linked list is sorted or not using c++?

限于喜欢 提交于 2019-12-13 09:45:00

问题


How to check whether an array or a linked list is sorted or not given a set of numbers using c++?. Is there a function available to check that?


回答1:


Simply use std::is_sorted something like:

if (std::is_sorted(std::begin(linked_list), std::end(linked_list)) {
    //...
}



回答2:


Check this stack overflow link hope you get it your answer.

How do I code a function to test if a linked list is sorted



来源:https://stackoverflow.com/questions/35867423/how-to-check-whether-a-linked-list-is-sorted-or-not-using-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!