Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int getListLength(Node list) {
- int count = 0;
- while (list) {
- count++;
- list = list->next;
- }
- return count;
- }
- bool isListSorted(Node list) {
- if (list == NULL) {
- return true;
- }
- int prev = list->x;
- list = list->next;
- while (list != NULL) {
- if (prev > list->x) {
- return false;
- }
- prev = list->x;
- list = list->next;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement