about | help | code help+videos | done | prefs |
Write a method named isSorted accepts a stack of integers as a parameter and returns true if the elements in the stack occur in ascending (non-decreasing) order from top to bottom, else false. That is, the smallest element should be on top at the head, growing larger toward the bottom at the tail. An empty or one-element stack is considered to be sorted. You may use one stack as auxiliary storage. isSorted([42]) → true isSorted([]) → true isSorted([20, 20, 17, 11, 8, 8, 3, 2]) → true ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 300
Copyright Nick Parlante 2017 - privacy