Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(C programming) 3.2 Problem D Subject Passing array as argument allow the function to modify argument array. of array index notation. Pointer notion in place

image text in transcribed

image text in transcribed

(C programming)

3.2 Problem D Subject Passing array as argument allow the function to modify argument array. of array index notation. Pointer notion in place Specification Write an ANSI-C program that reads inputs line by line, and sorts each line of input alphabetically, according to the indexes of the characters in ASCII table, in ascending order. That is, the letter that appear earlier in the ASCII table should appear earlier in the sorted array. The program terminates when quit is read in. Implementation Assume that each line of input contains at most 30 characters and may contain blanks. . Use fgets to read line by line . Define a function void sortArray (char which sorts characters in the argument array according to the index in the ASCIl table. Do not use extra arrays. sortArry should sort and modify the argument array directly . .Do not use array indexing throughout the program, except for array declarations in main. Instead, use pointers and pointer arithmetic to manipulate arrays. . Do not use global variables .People have been investigating sorting problems for centuries and there exist various sorting algorithms, so don't try to invent a new one. Instead, you can implement any one of the existing sorting algorithms, e.g., Bubble Sort, Insertion Sort, Selection Sort. (Compared against other sorting algorithms such as Quick Sort, Merge Sort, these algorithms are simpler but slower O(n2) complexity). Pseudo-code for Selection Sort is given below for you. SELECTION-SORT(A) 0. number of elements in A for i 0 to n-1 2. smallest 3. for smallest: index of current smallest, initially i ton if AjAI smallestfind a smaller smallest J // update smallest 6. L swap A[ ]A[ smallest ] // move smallest element to index i Sample Inputs/Outputs: red 340 % a-out hello ehllo 7356890 0356789 DBECHAGIE ABCDEFGHI quit red 341 % a.out

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_2

Step: 3

blur-text-image_3

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

Data Analytics Systems Engineering Cybersecurity Project Management

Authors: Christopher Greco

1st Edition

168392648X, 978-1683926481

More Books

Students also viewed these Databases questions

Question

How am I communicating feedback and learnings back to my team?

Answered: 1 week ago