Question: Computer programming 1. Write a method that searches an sorted array of integers for a value x. If x is in the array, remove it
Computer programming
1. Write a method that searches an sorted array of integers for a value x. If x is in the array, remove it from the array. Return true or false depending on whether you find x or not. You need to maintain the sorted order of the array.
2. Write two methods that could be used to implement a stack on an array of integers. One to push a new integer on the stack and one to pop (that is remove and return) the last integer added to the stack. Do not worry about checking for the array being empty on pop or full on push.
3. Write a wrapper class that implements a queue on a doubly linked list. The queue only needs to implement addTail and removeHead methods. Assume the linked list already has methods for: void headInsert(int value) // inserts a new node at head containing value void tailInsert(int value) // inserts a new node at tail containing value int headShow() // returns the value of the first node in the list void headDelete() // deletes the first node at the head of the list int tailShow() // returns the value of the last node in the list void tailDelete() // deletes the last node in the list boolean find(int value) // returns true if value is in the list bool delete(int value) // removes the link containing value if it is present
4. write a method that performs a recursive find on a sorted integer array. You are given the name of the array as theArray, the size as SIZE, the number of elements as count.
5. Write a method to add an integer to an unsorted array. If the array is full, create a new array twice its size and copy all the items over to it.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
