3/1/2023 0 Comments List stack queue exercisesFor example, "madam", "dad", and "abba" are palindromes. A palindrome is a string that is identical to itself when reversed. Return true if text is a palindrome, false otherwise. Here is the signature and documentation for the function which is declared in hw3.c: As a reminder, this function implements simple palindome verification. Use a stack and queue (using the dynarray_t structure) to implement a more powerful version of the is_palindrome() function from an earlier lab. NOTE: For the purposes of this lab, you may use this function as if it accepts and returns a char. If no conversion is possible, the value returned is unchanged. In addition, you may find the following function from ctype.h useful:Ĭonverts c to its lowercase equivalent. Size_t dynarray_is_empty(dynarray_t *a) // return true if empty /* Stack operations */ void dynarray_push(dynarray_t *a, data_t item) // add to backĭata_t dynarray_pop (dynarray_t *a) // remove from backĭata_t dynarray_top (dynarray_t *a) // return back /* Queue operations */ void dynarray_enqueue(dynarray_t *a, data_t item) // add to backĭata_t dynarray_dequeue(dynarray_t *a) // remove from frontĭata_t dynarray_front (dynarray_t *a) // return front Size_t dynarray_size (dynarray_t *a) // return element count Check out the documentation (linked above) on the add(object) (enqueue) and remove() (dequeue) methods.Typedef dynarray_t // dynamic array struct /* Basic/common operations */ void dynarray_init (dynarray_t *a) // initialize struct void dynarray_free (dynarray_t *a) // free struct Much like abstract classes, interfaces cannot be instantiated so we must declare a variable of type Queue and initialize it to reference a new LinkedList object. The java.util package has a Queue interface that can be implemented by a number of classes, including LinkedList.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |