Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework Assignment #7 Course: COP 3223C Intro to Programming with C Semester: Spring 2018 Credit Value: 4% of Final Grade Due Date: April 23, 2018;

Homework Assignment #7 Course: COP 3223C Intro to Programming with C Semester: Spring 2018 Credit Value: 4% of Final Grade Due Date: April 23, 2018; 2:59 PM Linked lists, Searching and Sorting This assignment involves two different and independent programs: The first program (Program A) will (must) build, print and search a linked list. The second program (Program B) will (must) build, print and sort a contiguous list (it is easier to sort a contiguous list than a linked list). A. Write a program (Program A) that creates a linked list of 100 nodes, each containing a random positive integer between 0 and 99. The program must provide the user with four choices: Build the list; Print out the list; Search the list; and Quit. Hint: Use a switch structure in a while loop, where each of the first three choices in the switch leads to a UFD that does the work (Build, Print out or Search the list). Of course, Quit is trivial and does not need a UFD. 1) (1 point) Build the list and assigns a value (random integer between 0 and 99) to each node. 2) (1 point) Prints out the contents of the list to screen. For example: (you can either start from 0 or from 1 it doesnt matter) Node #1 contains the value of 71 Node #2 contains the value of 36 Node #3 contains the value of 19 . . . Node #100 contains the value of 27 3) (1 point) Asks the user what number she wishes to find in the list and searches for the first instance of that number. The search must return (i.e., print to screen) the node number in which the entry was found, so the program must keep count of the nodes it has visited. Assume the list is unordered (which of course, it is). If the number is not found in the list, it must say: The search has failed. For output, the program must print out one line indicating that the value sought was found in the nth node. For example: Please enter the number to be sought in the list: >> 15 The number 15 was found in node #81 B. (1 point) Write a second program (Program B) that builds a contiguous list (i.e., array? based), also of 100 elements (cells), each containing a random integer between 0 and 99. You encouraged to re?use as much code from Program A as you wish (this is called code re? sue and it is a good thing). This program must: 1) Build the contiguous list (i.e., the properly populated array). 2) Print out the contents of the list. Use the same output format you used for part A.2 except call it a cell and not a node. 3) Sort the list using the insertSort algorithm. 4) Print out the list automatically after it has been sorted. Use the same printout format as in part B.2 above. Note: These are to be two separate programs and not one program in two separate files!! The names of the files you submit should be HW7 - - progA.c HW7 - - progB.c Musts: It should not need to be said, but .. the programs, of course, must be written in C and compile in the gcc compiler. The files must be submitted through Canvas by the due date above. Because it is the last assignment of the semester, it cannot be submitted late. No other musts other than those explicitly stated in the program descriptions above.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

2. What do you know about the Privacy Act?

Answered: 1 week ago