Skip to content
This repository has been archived by the owner on Mar 13, 2022. It is now read-only.

CS-162-nilsstreedain/lab8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Sorting

(20 pts) Sort the array and check prime numbers

Create a program which will sort an array of integers in ascending order using one of the sorting algorithms we discussed in class (selection, insertion, or merge--NOT BUBBLE), and indicate whether each integer element is a prime number.

You must code the sorting algorithm yourself (no library)

  • (2 pt) Create a 1-D dynamic array of integers which is randomly filled with values between 1 and 100
  • (2 pt) Establish the length of the array based on user input
  • (2 pt) Error handle the user input to make sure it is a valid number greater than zero and less than or equal to twenty-five
  • (2 pt) Print the elements of the array
  • (4 pt) Create a copy of the array and use your chosen sorting algorithm to sort it in ascending order
  • (2 pt) Print the elements of the sorted array
  • (2 pt) Print out all prime numbers of the array
  • (4 pt) End the program and make sure all memory has been freed (there should be no memory leaks!)

Make sure your program is decomposed into appropriate functions which could be reused on other data structures.