1. Write a function named "isBoundedArray" that accepts an array of integers and its size. The function will check the array to see whether the first and the last elements in the given array are the smallest and largest in the list, or the largest and smallest in the list. If they are, it will return true. Otherwise, it will return false. Requirement: please use only pointer notation in the function. No array notation.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 6PP: (Numerical) a. Define an array with a maximum of 20 integer values, and fill the array with numbers...
icon
Related questions
Question

1. Write a function named "isBoundedArray" that accepts an array of integers
and its size. The function will check the array to see whether the first and the last elements
in the given array are the smallest and largest in the list,
or the largest and smallest in the list.
If they are, it will return true. Otherwise, it will return false.

Requirement: please use only pointer notation in the function. No array notation.

For example, the following arrays will return true
   int numList0[] = {10} ;
   int numList1[] = {10, 20, 30, 40} ;
   int numList2[] = {40, 30, 20, 10} ;
   int numList3[] = {10, 30, 20, 40} ;
   int numList4[] = {40, 20, 30, 10} ;
And these arrays will return false
   int numList5[] = {10, 40, 20, 30} ;
   int numList6[] = {40, 20, 30, 50} ;


2. Write a function named “isBinaryString” that accepts a C-string (an array of characters
with a NULL terminating character)and returns true
if that C-string contains a valid binary number and false otherwise.

A valid binary string is defined as a string 
that must contain only '0' and '1' with the optional 'b' or 'B' at the end.
Please note that when 'b' or 'B' is at the end, it must precede with at least a '0' or '1'.

For example, "1010" or "10b" will return true 
"" or "b" or "b1" will return false.

The requirement is that you cannot use any string function such as strlen or string class and its method. 
This is an exercise on pointers and you are required to do the check 
by examining each character in the C-string using pointers.

This function works with C-string and not string class.
It also means that you should not pass the size of the string to the function as a parameter.
Please use only pointer notation. Please do not use or refer the string class in this function.

The following C-string will return true
   char s0[] = {'0', '\0'} ;
   char s1[] = {'1', '0', '\0'} ;
   char s2[] = {'1', 'b', '\0'} ;
   char s3[] = {'1', '0', '1', '0', '\0'} ;
   char s4[] = {'1', '0', '1', '0', 'b', '\0'} ;

And the following C-string will return false
   char s5[] = {'\0'} ;
   char s6[] = {'b', '\0'} ;
   char s7[] = {'1', 'b', '0', '\0'} ;
   char s8[] = {'1', '0', '1', '2', '\0'} ;

Expert Solution
steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning