Starting from:
$30

$24

Computer Science Assignment 1 Solution

Exercise 1




Write an algorithm and a C++ program that create an array that can hold 100 integers, and initialize it where each element of the array is equal to 2 ∗ + 1, and is the index of the element. Display those values on the screen. Search through the array, and count the number of elements that are between 15 and 65.




Exercise 2




Write an algorithm and a C++ program that ask the user to type 10 integers of an array and an integer value . The program must search if the value exists in the array and must remove the first occurrence of , shifting each following element left and adding a zero at the end of the array. The program must then write the final array.




Exercise 3: Maximum and minimum values of an array




Write an algorithm and a C++ program that determine the largest and the smallest value in an array of integers A. Next, display the value and position of the maximum and minimum. If the array contains several maxima or minima, the program will retain the position of the first maximum or minimum encountered.




Exercise 4: Insert a value into a sorted array




An array of size contains (< ) integer values sorted in ascending order; the ( + 1) ℎ value is undefined. Write an algorithm and a C++ program that inserts a given VAL value into the keyboard in the array A to obtain an array of N + 1 sorted values.




Exercise 6: Finding a value in an array




Write an algorithm and a C++ program that search in an array of integers a VAL value entered on the keyboard by using a serial searching. Display the position of VAL if it is in the table, otherwise display a corresponding message. The POS value that is













1




used to memorize the position of the value in the array, will have the value -1 as long as VAL was not found.




Do the same thing but by using a binary search. What is the benefit of binary search? Explain briefly.




Exercise 7




Write an algorithm and a C ++ program to find the most existing element in an array of integers.














































































































































2

More products